Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Get User after SAML login

Avatar

Level 2

I have SAML 2.0 Authentication Handler working (ootb) and directing to my AEM html page after login.

This page is secured via the Authentication Requirements property in Apache Sling Authentication Service.

It creates a rep:User node (Autocreate CRX Users is enabled) and Properties according to the Synchronized Attributes.

I now want to get those Properties from my AEM html page.

Can someone explain how this is achieved?

1 Accepted Solution

Avatar

Correct answer by
Employee

The Profile interface has been deprecated since CQ 5.5 The preferred way to do this now is:

UserProperties userProps = slingRequest.adaptTo(UserProperties.class); String email = userProps.getProperty("email"); // or whatever

See http://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/security/user/UserProperties.html

View solution in original post

4 Replies

Avatar

Level 6

Are you trying to fetch user info in your jsp? You can always iterate over the fetch user profile node  -

Profile currentProfile = slingRequest.adaptTo(Profile.class);

String profilePath = currentProfile.getPath() ;

 if(session.itemExists(profilePath )) {
                     Node n = session.getNode(profilePath );
                      String id = n.getProperty("<your node prop>").getString();

                // do your stuff

}

Avatar

Correct answer by
Employee

The Profile interface has been deprecated since CQ 5.5 The preferred way to do this now is:

UserProperties userProps = slingRequest.adaptTo(UserProperties.class); String email = userProps.getProperty("email"); // or whatever

See http://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/security/user/UserProperties.html

Avatar

Level 6

Appreciate for this info Justin!

I've seen Profile interface is being used in some OOTB component in 5.6.1 but in AEM6 uses UserProperties