从CQ5中的存储库访问页面时出现授权问题。 [英] Authorisation issue while accessing a page from repository in CQ5.

查看:71
本文介绍了从CQ5中的存储库访问页面时出现授权问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问一个包含xml结构的页面。为此,我正在使用此代码

I'm trying to hit a page which contains a xml structure. for that i'm using this code

            @Reference
            private SlingRepository repository;

            adminSession = repository.loginAdministrative( repository.getDefaultWorkspace());
            String pageUrl = "http://localhost:4504"+page+".abc.htm";
            conn = (HttpURLConnection)new URL(pageUrl).openConnection();
            conn.setRequestProperty("Accept-Charset", charset);
            conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401"); // Do as if you'rusing Firefox 3.6.3
            urlResponse = new BufferedInputStream(conn.getInputStream());
            BufferedReader reader = new BufferedReader( new InputStreamReader(urlResponse) );

访问该页面时,我遇到了这个问题

While accesing the page i'm getting this issue

org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: `Anonymous access not allowed by configuration - requesting credentials`

我以管理员身份登录,每当我直接从浏览器中访问此url时,在通过我的代码访问它时,它都可以正常工作bt

I'm logged in as an admin and whenever i'm directly hitting this urlfrom browser it is working properly bt while accessing it thriugh my code i'm getting this error.

有任何建议吗?

推荐答案

您正在混合吊索凭证& http凭证。在sling储存库中登录时,http会话不知道任何身份验证信息!

You are mixing up sling credentials & http credentials. While you are logged in at the sling-repository the http session is not aware of any authentication informations!

这篇关于从CQ5中的存储库访问页面时出现授权问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆