Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Error fetching users information from a group

doriguetto
Level 2
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
Jörg_Hoh
Correct answer by
Employee
Employee

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

0 Replies
Jörg_Hoh
Correct answer by
Employee
Employee

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