protected Authentication createAnonymousAuthentication(Request request,Response response,AuthenticationContext context) { return new SimpleAuthentication(createAnonymous(request, response, context)); }
SimpleAuthentication sa = new SimpleAuthentication(user); sa.setClientPrincipal(client); authc = sa;
SimpleAuthentication authc = new SimpleAuthentication(user); authc.setRememberMe(true);
protected Authentication authentication(CredentialsAuthenticationContext context, Credentials credentials,Out<UserPrincipal> user){ for(CredentialsAuthenticator a : credentialsAuthenticators) { if(a.authenticate(context, credentials, user)) { break; } } Authentication authentication = null; if(null != user.getValue()) { authentication = new SimpleAuthentication(user.getValue(), credentials); } return authentication; }
protected Authentication authenticate(Request request, Response response, OAuth2Params params, String idToken, WacIdToken details) throws Throwable { String clientId = details.getClientId(); String userId = details.getUserId(); UserPrincipal user = null; ClientPrincipal client = null; if(!Strings.isEmpty(userId)) { UserDetails userDetails = um.loadUserDetails(userId); if(null == userDetails) { log.debug("The user id '{}' created with id token '{}' is not found", userId, idToken); return null; }else{ user = userDetails; } } if(!Strings.isEmpty(clientId)) { client = new ResClientPrincipal(clientId); } SimpleAuthentication authc = new SimpleAuthentication(user, details); if(null != client) { authc.setClientPrincipal(client); } return authc; }
@Override public Result<Authentication> createAuthenticationByUserId(String userid) { UserDetails details = sc.getUserStore().loadUserDetailsByIdString(userid); if(null == details) { return Result.empty(); } return Result.of(new SimpleAuthentication(details, new TrustedUserIdCredentials(userid))); } }
@Override public Result<Authentication> createAuthenticationByUsername(String username) { UserDetails details = sc.getUserStore().loadUserDetailsByLoginName(username); //TODO : check user enabled? if(null == details) { return Result.empty(); } return Result.of(new SimpleAuthentication(details, new TrustedLoginNameCredentials(username))); }
@Override public Authentication authenticate(CredentialsAuthenticationContext context, Credentials credentials) { Out<UserPrincipal> user = new Out<>(); State s = beforeAuthenticate(context,credentials,user); if(State.isIntercepted(s)){ if(null != user.getValue()) { return new SimpleAuthentication(user.getValue(), credentials); }else { return null; } } Authentication authentication = authentication(context,credentials,user); return afterAuthenticate(context,credentials,authentication); }
Authentication authc = new SimpleAuthentication(context.getUser(), context.getCredentials());