当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationDetailsSource类代码示例

本文整理汇总了Java中org.springframework.security.authentication.AuthenticationDetailsSource的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationDetailsSource类的具体用法?Java AuthenticationDetailsSource怎么用?Java AuthenticationDetailsSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationDetailsSource类属于org.springframework.security.authentication包,在下文中一共展示了AuthenticationDetailsSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestHeaderAuthenticationFilter

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@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;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:SecurityConfiguration.java

示例2: attemptAuthenticationWithDetailSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@Test
public void attemptAuthenticationWithDetailSource() throws IOException, ServletException {
    final OAuth2Authentication oAuth2Authentication = createAuthentication();
    final Object details = "details";
    final Authentication resultAuthentication = createResultAuthentication(oAuth2Authentication);

    final HttpServletRequest request = createRequest();
    final AuthenticationDetailsSource<HttpServletRequest, ?> detailsSource = createDetailsSource(request, details);

    final DashboardAuthenticationProcessingFilter filter =
          createFilter(oAuth2Authentication, resultAuthentication, detailsSource);

    final Authentication actualResultAuthentication = filter.attemptAuthentication(request, createResponse());

    assertSame(resultAuthentication, actualResultAuthentication);
    assertEquals(details, oAuth2Authentication.getDetails());
}
 
开发者ID:bsblabs,项目名称:cf-sample-service,代码行数:18,代码来源:DashboardAuthenticationProcessingFilterTest.java

示例3: setPublicUserToSecurityContext

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
/**
 * Set the public user as authenticated user to the current SecurityContext. If the
 * SecurityContext is shared between all threads of the current session.
 *
 * @param request
 *            the servlet request
 */
public static void setPublicUserToSecurityContext(ServletRequest request) {
    org.springframework.security.core.userdetails.User user = new PublicUserDetails();
    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
            user, user.getPassword(), user.getAuthorities());
    AuthenticationDetailsSource<Object, Object> authenticationDetailsSource = new AuthenticationDetailsSourceImpl();
    authentication.setDetails(authenticationDetailsSource.buildDetails(request));
    SecurityContextHolder.getContext().setAuthentication(authentication);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:16,代码来源:AuthenticationHelper.java

示例4: useAnonymousIfPossible

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
private void useAnonymousIfPossible(HttpServletRequest request, HttpServletResponse response,
        FilterChain chain, SecurityContext securityContext) throws IOException, ServletException {
    boolean anonAccessEnabled = context.getAuthorizationService().isAnonAccessEnabled();
    if (anonAccessEnabled || authInterceptors.accept(request)) {
        log.debug("Using anonymous");
        Authentication authentication = getNonUiCachedAuthentication(request);
        if (authentication == null) {
            log.debug("Creating the Anonymous token");
            final UsernamePasswordAuthenticationToken authRequest =
                    new UsernamePasswordAuthenticationToken(UserInfo.ANONYMOUS, "");
            AuthenticationDetailsSource ads = new HttpAuthenticationDetailsSource();
            //noinspection unchecked
            authRequest.setDetails(ads.buildDetails(request));
            // explicitly ask for the default spring authentication manager by name (we have another one which
            // is only used by the basic authentication filter)
            AuthenticationManager authenticationManager =
                    context.beanForType("authenticationManager", AuthenticationManager.class);
            authentication = authenticationManager.authenticate(authRequest);
            if (authentication != null && authentication.isAuthenticated() && !RequestUtils.isUiRequest(request)) {
                AuthCacheKey authCacheKey = new AuthCacheKey(authFilter.getCacheKey(request),
                        request.getRemoteAddr());
                nonUiAuthCache.put(authCacheKey, authentication);
                log.debug("Added anonymous authentication {} to cache", authentication);
            }
        } else {
            log.debug("Using cached anonymous authentication");
        }
        useAuthentication(request, response, chain, authentication, securityContext);
    } else {
        if (authFilter.acceptEntry(request)) {
            log.debug("Sending request requiring authentication");
            authFilter.commence(request, response,
                    new InsufficientAuthenticationException("Authentication is required"));
        } else {
            log.debug("No filter or entry just chain");
            chain.doFilter(request, response);
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:41,代码来源:AccessFilter.java

示例5:

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@Override
public void setAuthenticationDetailsSource
        (AuthenticationDetailsSource
                 authenticationDetailsSource) {
    log.debug("Invoking setAuthenticationDetailsSource");
    super.setAuthenticationDetailsSource(authenticationDetailsSource);
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:8,代码来源:AuthenticationFilter.java

示例6: createFilter

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
private DashboardAuthenticationProcessingFilter createFilter(OAuth2Authentication oAuth2Authentication,
                                                             Authentication resultAuthentication,
                                                             AuthenticationDetailsSource<HttpServletRequest, ?> source) {
    final String token = "TOKEN";
    final DashboardAuthenticationProcessingFilter filter = new DashboardAuthenticationProcessingFilter();

    filter.setAuthenticationManager(createAuthenticationManagerForUserAuth(oAuth2Authentication, resultAuthentication));
    filter.setRestTemplate(createRestTemplate(token));
    filter.setTokenServices(createResourceTokenServices(oAuth2Authentication, token));
    filter.setDetailsSource(source);

    return filter;
}
 
开发者ID:bsblabs,项目名称:cf-sample-service,代码行数:14,代码来源:DashboardAuthenticationProcessingFilterTest.java

示例7: createDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private AuthenticationDetailsSource<HttpServletRequest, ?> createDetailsSource(HttpServletRequest request,
                                                                               Object details) {
    final AuthenticationDetailsSource<HttpServletRequest, ?> source = mock(AuthenticationDetailsSource.class);

    when(source.buildDetails(request))
          .thenReturn(details);

    return source;
}
 
开发者ID:bsblabs,项目名称:cf-sample-service,代码行数:11,代码来源:DashboardAuthenticationProcessingFilterTest.java

示例8: getAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
    return authenticationDetailsSource;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:4,代码来源:TokenAuthFilterConfigurer.java

示例9: setAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
    this.authenticationDetailsSource = authenticationDetailsSource;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:4,代码来源:TokenAuthFilterConfigurer.java

示例10: setAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
/**
 * @param authenticationDetailsSource
 *            the {@link AuthenticationDetailsSource} to use, cannot be null
 */
public void setAuthenticationDetailsSource(
        AuthenticationDetailsSource<Object, Object> authenticationDetailsSource) {
    Assert.notNull(authenticationDetailsSource, "AuthenticationDetailsSource required");
    this.authenticationDetailsSource = authenticationDetailsSource;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:10,代码来源:RequestParameterAuthenticationProcessingFilter.java

示例11: detailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
private AuthenticationDetailsSource<HttpServletRequest, ?> detailsSource() {
    return (request) -> {
        Collection<? extends GrantedAuthority> authorities = Collections.singleton(new SimpleGrantedAuthority("ROLE_USER"));
        return new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(request, authorities);
    };
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:7,代码来源:AccessTokenAuthenticationFilter.java

示例12: setAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(
		AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
	Assert.notNull(authenticationDetailsSource,
			"AuthenticationDetailsSource required");
	this.authenticationDetailsSource = authenticationDetailsSource;
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:7,代码来源:CustomOAuth2RequestFilter.java

示例13: setAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void  setAuthenticationDetailsSource(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource) {
  impl.setAuthenticationDetailsSource(authenticationDetailsSource);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:4,代码来源:BasicAuthenticationFilter.java

示例14: getAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
	return authenticationDetailsSource;
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:4,代码来源:RestLoginFilter.java

示例15: setAuthenticationDetailsSource

import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(
		AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
	this.authenticationDetailsSource = authenticationDetailsSource;
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:5,代码来源:RestLoginFilter.java


注:本文中的org.springframework.security.authentication.AuthenticationDetailsSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。