I tried to code a small client for connecting to CRX 2.2
I followed the steps here:
http://helpx.adobe.com/adobe-cq/using/programmatically-accessing-cq-content-using.html
Had problems, found out that I was missing libs and added the jars i found in comment 4 here.
http://forums.adobe.com/message/4734716#4734716
My code is
import java.util.logging.Level; import java.util.logging.Logger; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import javax.jcr.Workspace; import javax.jcr.nodetype.NodeTypeManager; import org.apache.jackrabbit.commons.JcrUtils; public class CRXConn { public static void main(String[] args) { try { Repository repository = JcrUtils.getRepository("http://MYSERVERNAME/crx/server"); SimpleCredentials creds = new SimpleCredentials("admin", "MYLOGIN".toCharArray()); Session session = null; session = repository.login(creds, "crx.default"); /*KAABOOOOM*/ Workspace ws = session.getWorkspace(); Node rootNode = session.getRootNode(); NodeTypeManager ntMgr = ws.getNodeTypeManager();
However, when to code comes to the login row i get an DAVexception "Unauthorized".
2013-aug-13 09:03:58 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
2013-aug-13 09:03:58 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: Failure authenticating with BASIC
However, thats not true, the account is valid, and I have no problems to login the regular way. What to check next?
Am I still missing some library? Do i need some special setting for weblogic (which it runs on)?
Solved! Go to Solution.
Found the error: It was a weblogic one. I needed to put
the <enforce-valid-basic-auth-credentials> element to config.xml within the <security-configuration> element.
<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>
</security-configuration>
Anyway, thanks for suggestions!
Views
Replies
Total Likes
You should omit "crx.default" from the repository login. I get the same effect when I add the "crx.default" in our unit test cases but when I use
session = repository.login( new SimpleCredentials(USERNAME,PASSWORD.toCharArray()) );
it works.
SimpleCredentials creds = new SimpleCredentials("admin", "MYLOGIN".toCharArray());
session = repository.login(creds);
should work.
Views
Replies
Total Likes
Tried removing that as suggested, but get the same exception.
Views
Replies
Total Likes
Found the error: It was a weblogic one. I needed to put
the <enforce-valid-basic-auth-credentials> element to config.xml within the <security-configuration> element.
<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>
</security-configuration>
Anyway, thanks for suggestions!
Views
Replies
Total Likes
Hi , I am getting the same exception....Where can I apply the fix as I am connecting to CRX with default Felix server. Please help.
Views
Replies
Total Likes
Views
Likes
Replies