Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Error fetching users information from a group

Avatar

Level 2

Hi,

Im working in a proof of concept in order to display some user information based on a group. Follow my jsp snippet.

<%@ page import="java.util.ArrayList,
        java.util.Iterator,
        java.util.List,
        org.apache.jackrabbit.api.security.user.*,
        org.apache.jackrabbit.api.*,
        org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials,
        javax.jcr.Credentials" %>
<% 

 

   final List<String> members = new ArrayList<String>();
    final UserManager userManager = resource.adaptTo(UserManager.class);
    
    final Authorizable auth2 = userManager.getAuthorizable("content-authors");
    
    if (auth2 == null) {
        //SOMETHING HERE
    } else if (auth2.isGroup()) {
            Group group = (Group) auth2;
            Iterator<Authorizable> iter = group.getMembers();
            while (iter.hasNext()) {
                Authorizable auth = iter.next();
                if (!auth.isGroup()) {
                    User user = (User) auth;
                    Credentials cred  = user.getCredentials();
                    if (cred instanceof CryptedSimpleCredentials) {
                        //DO THINGS HERE
                    }
                }
        }
    }

%>

This is the exception i got. Any clues what is the problem?

12.03.2014 17:47:28.336 *ERROR* [127.0.0.1 [1394606848286] GET /content/demo/en/homepage.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDebugFilter Error during include of SlingRequestPathInfo: path='/content/demo/en/homepage/jcr:content/title', selectorString='null', extension='html', suffix='null' org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 26 in the jsp file: /apps/demo/components/users/users.jsp
CryptedSimpleCredentials cannot be resolved to a type
23:                 if (!auth.isGroup()) {
24:                     User user = (User) auth;
25:                     Credentials cred  = user.getCredentials();
26:                     if (cred instanceof CryptedSimpleCredentials) {
27:                         //DO SOMETHING HERE
28:                     }
29:                 }

    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171)

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Likely the class "org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials" is not exported by any OSGI service. You can check via the depfinder utility (http://localhost:4502/system/console/depfinder) if it's exported.

Jörg

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Likely the class "org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials" is not exported by any OSGI service. You can check via the depfinder utility (http://localhost:4502/system/console/depfinder) if it's exported.

Jörg