use of com.enonic.xp.security.auth.VerifiedUsernameAuthToken in project xp by enonic.
the class SchedulableTaskImpl method taskContext.
private Context taskContext() {
if (job.getUser() == null) {
return ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.unAuthenticated()).build();
}
final AuthenticationInfo authInfo = OsgiSupport.withService(SecurityService.class, securityService -> {
final VerifiedUsernameAuthToken token = new VerifiedUsernameAuthToken();
token.setIdProvider(job.getUser().getIdProviderKey());
token.setUsername(job.getUser().getId());
return securityService.authenticate(token);
});
return ContextBuilder.from(ContextAccessor.current()).authInfo(authInfo).build();
}
use of com.enonic.xp.security.auth.VerifiedUsernameAuthToken in project app-auth0-idprovider by enonic.
the class Auth0LoginService method authenticate.
private void authenticate(final HttpServletRequest request, final PrincipalKey principalKey) {
final VerifiedUsernameAuthToken verifiedUsernameAuthToken = new VerifiedUsernameAuthToken();
verifiedUsernameAuthToken.setIdProvider(principalKey.getIdProviderKey());
verifiedUsernameAuthToken.setUsername(principalKey.getId());
verifiedUsernameAuthToken.setRememberMe(true);
final AuthenticationInfo authenticationInfo = runAs(() -> securityService.authenticate(verifiedUsernameAuthToken), RoleKeys.AUTHENTICATED);
if (authenticationInfo.isAuthenticated()) {
final HttpSession httpSession = request.getSession(true);
httpSession.setAttribute(authenticationInfo.getClass().getName(), authenticationInfo);
}
}
Aggregations