Java 类org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails 实例源码

项目:syndesis    文件:SecurityConfiguration.java   
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() throws Exception {
    RequestHeaderAuthenticationFilter f = new RequestHeaderAuthenticationFilter();
    f.setPrincipalRequestHeader("X-Forwarded-User");
    f.setCredentialsRequestHeader("X-Forwarded-Access-Token");
    f.setAuthenticationManager(authenticationManager());
    f.setAuthenticationDetailsSource(
        (AuthenticationDetailsSource<HttpServletRequest, PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>)
            (request) ->new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(
                request,
                AuthorityUtils.createAuthorityList("ROLE_AUTHENTICATED")
            )
    );
    f.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
    f.setExceptionIfHeaderMissing(false);
    return f;
}
项目:syndesis-rest    文件:SecurityConfiguration.java   
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() throws Exception {
    RequestHeaderAuthenticationFilter f = new RequestHeaderAuthenticationFilter();
    f.setPrincipalRequestHeader("X-Forwarded-User");
    f.setCredentialsRequestHeader("X-Forwarded-Access-Token");
    f.setAuthenticationManager(authenticationManager());
    f.setAuthenticationDetailsSource(
        (AuthenticationDetailsSource<HttpServletRequest, PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>)
            (request) ->new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(
                request,
                AuthorityUtils.createAuthorityList("ROLE_AUTHENTICATED")
            )
    );
    f.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
    f.setExceptionIfHeaderMissing(false);
    return f;
}
项目:duo-registration    文件:DuoAuthenticationDetailsSource.java   
@Override
public GrantedAuthoritiesContainer buildDetails(HttpServletRequest request) {

    List gal = new ArrayList();
    try {
        GrantedAuthority ga = null;

        if (StringUtils.hasLength(request.getHeader("uid"))) {
            ga = new SimpleGrantedAuthority("ROLE_USER");
        } else {
            ga = new SimpleGrantedAuthority("ROLE_ANONYMOUS");
        }

        log.debug("UID=" + request.getHeader("uid") + "|Granted:" + ga);

        gal.add(ga);
    } catch (Exception e) {
        throw new AuthenticationServiceException("Error..", e);
    }

    return new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(request, gal);
}
项目:putput    文件:AccessTokenAuthenticationFilter.java   
private AuthenticationDetailsSource<HttpServletRequest, ?> detailsSource() {
    return (request) -> {
        Collection<? extends GrantedAuthority> authorities = Collections.singleton(new SimpleGrantedAuthority("ROLE_USER"));
        return new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(request, authorities);
    };
}