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 void processProperties() { Out<String> out = new Out<>(); for(Map.Entry<String, AppProperty> entry : this.properties.entrySet()) { String name = entry.getKey(); AppProperty prop = entry.getValue(); if(propertyProcessor.process(name, prop.getValue(), out)) { prop.updateProcessedValue(out.getValue()); } } for(Map.Entry<String,List<String>> p : this.arrayProperties.entrySet()) { String name = p.getKey(); List<String> values = p.getValue(); boolean processed = false; for(int i=0;i<values.size();i++) { String value = values.get(i); if(propertyProcessor.process(name, value, out)) { value = out.getValue(); processed = true; values.set(i, value); } } if(processed) { arrayProperties.put(name, values); } } }
private AuthzAuthentication createAuthzAuthenticationFromHandler(OAuth2Params oauthParam,AuthzClient client,Object ud){ AuthzAuthenticationContext context=new AuthzAuthenticationContext(oauthParam, client, ud); Out<AuthzAuthentication> authc = new Out<>(); for(AuthzAuthenticationHandler handler : authzAuthenticationHandlers) { if(handler.createAuthzAuthentication(context, authc)){ break; } } return authc.getValue(); }
private AuthzAuthentication createAuthzAuthenticationFromHandler(OAuth2Params oauthParam,AuthzClient client,Object ud){ AuthzAuthenticationContext context=new AuthzAuthenticationContext(oauthParam, client, ud); Out<AuthzAuthentication> authc = new Out<>(); for(AuthzAuthenticationHandler handler : authzAuthenticationHandlers) { if(handler.createAuthzAuthentication(context, authc)){ break; } } return authc.getValue(); }
public static <T> T toBean(Map<String, ?> map,Class<T> beanClass) { Out<Object> out = new Out<>(); try { beanConverter.convertFrom(map, beanClass, null, out, null); } catch (ConvertException e){ throw e; } catch (Throwable e) { throw new ConvertException(Strings.format("Error converting map to bean '{0}'",beanClass.getName()),e); } return (T)out.getValue(); }
@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); }
@Override public State handleLoginAuthentication(Request request, Response response, LoginContext context) throws Throwable { if(!context.isCredentialsResolved()){ Out<Credentials> out = new Out<Credentials>(); for(CredentialsResolver resolver : credentialsResolver){ if(resolver.resolveCredentials(context, request, out)){ context.setCredentials(out.getValue()); break; } } } return State.CONTINUE; }
UserPrincipal principal = outPrincipal.getValue(); if(null == principal){ throw new IllegalStateException("Credentials '" + credentials + "' authenticated but no principal was returned");