本文整理汇总了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;
}
示例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());
}
示例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);
}
示例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);
}
}
}
示例5:
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
@Override
public void setAuthenticationDetailsSource
(AuthenticationDetailsSource
authenticationDetailsSource) {
log.debug("Invoking setAuthenticationDetailsSource");
super.setAuthenticationDetailsSource(authenticationDetailsSource);
}
示例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;
}
示例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;
}
示例8: getAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
return authenticationDetailsSource;
}
示例9: setAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
this.authenticationDetailsSource = authenticationDetailsSource;
}
示例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);
};
}
示例12: setAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(
AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
Assert.notNull(authenticationDetailsSource,
"AuthenticationDetailsSource required");
this.authenticationDetailsSource = authenticationDetailsSource;
}
示例13: setAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource) {
impl.setAuthenticationDetailsSource(authenticationDetailsSource);
}
示例14: getAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public AuthenticationDetailsSource<HttpServletRequest, ?> getAuthenticationDetailsSource() {
return authenticationDetailsSource;
}
示例15: setAuthenticationDetailsSource
import org.springframework.security.authentication.AuthenticationDetailsSource; //导入依赖的package包/类
public void setAuthenticationDetailsSource(
AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource) {
this.authenticationDetailsSource = authenticationDetailsSource;
}