String token = LoginServlet.getOauthRememberMeTokenCookie(req);
if(token != null) {
ExoContainer container = getContainer();
CookieTokenService tokenService = container.getComponentInstanceOfType(CookieTokenService.class);
Credentials credentials = tokenService.validateToken(token, false);
AuthenticationRegistry authRegistry = container.getComponentInstanceOfType(AuthenticationRegistry.class);
OrganizationService orgService = container.getComponentInstanceOfType(OrganizationService.class);
if (credentials != null) {
ServletContainer servletContainer = ServletContainerFactory.getServletContainer();
try {
String username = credentials.getUsername();
User portalUser = orgService.getUserHandler().findUserByName(username, UserStatus.ENABLED);
if(portalUser != null) {
authRegistry.setAttributeOfClient(req, ATTRIBUTE_AUTHENTICATED_PORTAL_USER_FOR_JAAS, portalUser);
servletContainer.login(req, resp, credentials);
}
} catch (Exception e) {
// Could not authenticate