String userName = request.getUser();
Session userSession = request.getResourceResolver.adaptTo(Session.class);
JackrabbitSession jrSession = (JackrabbitSession) userSession;
UserManager um = jrSession.getUserManager();
User u = (User) um.getAuthorizable (userName);
u.changePassword ("myNewPassword");
In java:
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.sling.jcr.base.util.AccessControlUtil;
UserManager userManager = AccessControlUtil.getUserManager(jcrSession); Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof User) { user = (User)authorizable;
user.changePassword("new password");
}
if (authorizable instanceof Group) { user = (Group)authorizable; }
No comments:
Post a Comment
If you have any doubts or questions, please let us know.