HI,
on Adobe Aem Author in a java class that implements AuthenticationHandler, AuthenticationFeedbackHandler I have the following method:
public boolean authenticationSucceeded(HttpServletRequest request, HttpServletResponse response, AuthenticationInfo authInfo) {
…
}
How can I obtain the email address of the logged in user within the authenticationSucceeded method ?
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
@robertol6836527 within authenticationSucceeded method, you can use authInfo object to get username like authInfo.getUser() and then use AEM UserManager API to get further details about user.
https://www.albinsblog.com/2015/03/how-to-get-userinfo-through-java-api-in.html
You can use below code snippet to get user details available in session
import javax.jcr.Session;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
...
UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Session session = resourceResolver.adaptTo(Session.class);
log.info("User="+session.getUserID());
or..
Authorizable auth = userManager.getAuthorizable(session.getUserID());
log.info("\n--- User,
Principal="+auth.getID()+","+auth.getPrincipal().getName());
https://stackoverflow.com/questions/33132102/aem-get-current-userid
@robertol6836527 within authenticationSucceeded method, you can use authInfo object to get username like authInfo.getUser() and then use AEM UserManager API to get further details about user.
https://www.albinsblog.com/2015/03/how-to-get-userinfo-through-java-api-in.html
From AuthenticationInfo you will get User ID only.
public boolean authenticationSucceeded(HttpServletRequest request, HttpServletResponse response, AuthenticationInfo authInfo) {
String userId = authInfo.getUser();
//======
//===
}
Views
Likes
Replies