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

项目:smt-spring-security-parent    文件:JwtSuccessHandlerWrapperTest.java   
@Test
public void Can_wrap_a_success_handler() {

    final UsernamePasswordAuthenticationFilter filter = mock(UsernamePasswordAuthenticationFilter.class);

    final AuthenticationSuccessHandler oldSuccessHandler = mock(AuthenticationSuccessHandler.class);
    final JwtAuthenticationSuccessHandler newSuccessHandler = mock(JwtAuthenticationSuccessHandler.class);

    // Given
    given(mutator.retrieve(filter, "successHandler", AuthenticationSuccessHandler.class))
        .willReturn(oldSuccessHandler);
    given(successHandler.withDelegate(oldSuccessHandler)).willReturn(newSuccessHandler);

    // When
    successHandlerWrapper.modify(filter);

    // Then
    verify(filter).setAuthenticationSuccessHandler(newSuccessHandler);
}
项目:smt-spring-security-parent    文件:CookieAndHeaderJwtAuthenticationSuccessHandlerTest.java   
@Test
public void Can_update_the_delegate() throws IOException, ServletException {

    final HttpServletRequest request = mock(HttpServletRequest.class);
    final HttpServletResponse response = mock(HttpServletResponse.class);
    final Authentication authentication = mock(Authentication.class);

    final AuthenticationSuccessHandler delegate = mock(AuthenticationSuccessHandler.class);

    // Given
    successHandler.withDelegate(delegate);

    // When
    successHandler.onAuthenticationSuccess(request, response, authentication);

    // Then
    final InOrder order = inOrder(authenticationApplier, delegate);
    order.verify(authenticationApplier).apply(authentication, response);
    order.verify(delegate).onAuthenticationSuccess(request, response, authentication);
}
项目:smt-spring-security-parent    文件:WrappedUsernamePasswordAuthenticationFilterTest.java   
@Test
public void Can_set_a_wrapped_authentication_success_handler() throws IllegalAccessException {

    final AuthenticationSuccessHandler newSuccessHandler = mock(AuthenticationSuccessHandler.class);

    final JwtAuthenticationSuccessHandler withSuccessHandler = mock(JwtAuthenticationSuccessHandler.class);

    // Given
    final Object successHandler = extractFiledValue(filter, "successHandler");
    given(jwtSuccessHandler.withDelegate((AuthenticationSuccessHandler) successHandler))
        .willReturn(withSuccessHandler);

    // When
    final WrappedUsernamePasswordAuthenticationFilter wrappedFilter
        = new WrappedUsernamePasswordAuthenticationFilter(reflectionFieldMutator, filter, jwtSuccessHandler);
    wrappedFilter.setAuthenticationSuccessHandler(newSuccessHandler);

    // Then
    verify(jwtSuccessHandler).withDelegate(newSuccessHandler);
    assertThat(wrappedFilter.getSuccessHandler(), is((AuthenticationSuccessHandler) withSuccessHandler));
}
项目:find    文件:IdolSecurityCustomizerImpl.java   
@SuppressWarnings("ProhibitedExceptionDeclared")
@Override
public void customize(final HttpSecurity http, final AuthenticationManager authenticationManager) throws Exception {
    final AuthenticationSuccessHandler successHandler = new IdolLoginSuccessHandler(
            FindController.CONFIG_PATH,
            FindController.APP_PATH,
            FindRole.CONFIG.toString(),
            authenticationInformationRetriever
    );

    http.formLogin()
            .loginPage(FindController.DEFAULT_LOGIN_PAGE)
            .loginProcessingUrl("/authenticate")
            .successHandler(successHandler)
            .failureUrl(FindController.DEFAULT_LOGIN_PAGE + "?error=auth");
}
项目:kinota-server    文件:AgentLoginProcessingFilter.java   
public AgentLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                      AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:DiscussionPortal    文件:AuthenticationHandler.java   
protected AuthenticationSuccessHandler successHandler() {
 return new AuthenticationSuccessHandler() {
     @Override
     public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
         httpServletResponse.getWriter().append("OK");
         httpServletResponse.setStatus(200);
     }
 };
}
项目:OpenLRW    文件:AjaxLoginProcessingFilter.java   
public AjaxLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler, 
        AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:OpenLRW    文件:AdminUserProcessingFilter.java   
public AdminUserProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:InfoSys-1D    文件:ProfChoperSecurityConfig.java   
@Autowired
public ProfChoperSecurityConfig(@Qualifier("profChoperDataSource") DataSource dataSource,
                                AccessDeniedHandler accessDeniedHandler,
                                AuthenticationSuccessHandler successHandler) {

    this.dataSource = dataSource;
    this.accessDeniedHandler = accessDeniedHandler;
    this.successHandler = successHandler;
}
项目:infotaf    文件:AjaxLoginProcessingFilter.java   
public AjaxLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler, 
        AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:iotplatform    文件:RefreshTokenProcessingFilter.java   
public RefreshTokenProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:iotplatform    文件:RestPublicLoginProcessingFilter.java   
public RestPublicLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:iotplatform    文件:RestLoginProcessingFilter.java   
public RestLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:oma-riista-web    文件:OneTimePasswordFilterConfigurer.java   
public OneTimePasswordFilterConfigurer(final String loginProcessingUrl,
                                       AuthenticationSuccessHandler successHandler,
                                       AuthenticationFailureHandler failureHandler,
                                       AuthenticationEntryPoint entryPoint) {
    this.authFilter = new OneTimePasswordAuthenticationFilter(loginProcessingUrl);
    this.authFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher(loginProcessingUrl, "POST"));
    this.authFilter.setAuthenticationSuccessHandler(successHandler);
    this.authFilter.setAuthenticationFailureHandler(failureHandler);
    this.authFilter.setAllowSessionCreation(true);
    this.authenticationEntryPoint = entryPoint;
}
项目:smt-spring-security-parent    文件:JwtSuccessHandlerWrapper.java   
@Override
public void modify(final UsernamePasswordAuthenticationFilter filter) {
    filter.setAuthenticationSuccessHandler(
        successHandler.withDelegate(
            mutator.retrieve(filter, "successHandler", AuthenticationSuccessHandler.class)
        )
    );
}
项目:smt-spring-security-parent    文件:CookieAndHeaderJwtAuthenticationSuccessHandler.java   
public CookieAndHeaderJwtAuthenticationSuccessHandler(
    JwtAuthenticationApplier authenticationApplier,
    AuthenticationSuccessHandler delegate
) {
    this.authenticationApplier = authenticationApplier;
    this.delegate = delegate;
}
项目:smt-spring-security-parent    文件:CookieAndHeaderJwtAuthenticationSuccessHandlerTest.java   
@Before
@SuppressWarnings("unchecked")
public void setUp() {
    delegate = mock(AuthenticationSuccessHandler.class);
    authenticationApplier = mock(JwtAuthenticationApplier.class);
    successHandler = new CookieAndHeaderJwtAuthenticationSuccessHandler(authenticationApplier, delegate);
}
项目:thingsboard    文件:RefreshTokenProcessingFilter.java   
public RefreshTokenProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:thingsboard    文件:RestPublicLoginProcessingFilter.java   
public RestPublicLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                 AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:thingsboard    文件:RestLoginProcessingFilter.java   
public RestLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                 AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:stateless-rest-jwtcookie-demo    文件:SecurityInternalConfig.java   
/**
 * Success login hander, adding cookie auth
 *
 * @return
 */
@Bean
public AuthenticationSuccessHandler successHandler() {
    return new SavedRequestAwareAuthenticationSuccessHandler() {
        @Override
        public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
            LOG.info("LOGIN >>> " + authentication.getPrincipal());
            UserAuth userAuth = (UserAuth) authentication.getPrincipal();
            apiAuth.put(userAuth, response);
            PrintWriter writer = response.getWriter();
            mapper.writeValue(writer, userAuth);
            writer.flush();
        }
    };
}
项目:music-for-all-application    文件:SecurityConfig.java   
@Bean
public AuthenticationSuccessHandler successHandler() {

    final CustomAuthenticationSuccessHandler authSuccessHandler =
            new CustomAuthenticationSuccessHandler();
    authSuccessHandler.setDefaultTargetUrl(MAIN);
    authSuccessHandler.setTargetUrlParameter("targetUrl");
    return authSuccessHandler;
}
项目:recaptcha-spring-boot-starter    文件:RecaptchaAuthenticationFilter.java   
@Override
public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) {
    if (!LoginFailuresClearingHandler.class.isAssignableFrom(successHandler.getClass())) {
        throw new IllegalArgumentException("Invalid login success handler. Handler must be an instance of " + LoginFailuresClearingHandler.class.getName() + " but is " + successHandler);
    }
    super.setAuthenticationSuccessHandler(successHandler);
}
项目:spring-oauth2-jwt-minimal    文件:OAuth2ClientConfigurer.java   
private OAuth2ClientAuthenticationProcessingFilter createSsoFilter(ClientResourceDetails clientDetails, AuthenticationSuccessHandler successHandler, String path) {
    OAuth2ClientAuthenticationProcessingFilter ssoFilter = new OAuth2ClientAuthenticationProcessingFilter(path);
    ssoFilter.setAllowSessionCreation(false);
    OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(clientDetails.getClient(), oAuth2ClientContext);
    ssoFilter.setRestTemplate(restTemplate);
    ssoFilter.setTokenServices(new UserInfoTokenServices(clientDetails.getResource().getUserInfoUri(), clientDetails.getClient().getClientId()));
    ssoFilter.setAuthenticationSuccessHandler(successHandler);
    return ssoFilter;
}
项目:eHMP    文件:AjaxAuthenticationSuccessHandlerTests.java   
@Before
public void setUp() throws Exception {
    mockRequest = new MockHttpServletRequest();
    mockRequest.addHeader("X-Requested-With", "XMLHttpRequest");

    mockResponse = new MockHttpServletResponse();

    delegateSuccessHandler = mock(AuthenticationSuccessHandler.class);

    ajaxAuthenticationSuccessHandler = new AjaxAuthenticationSuccessHandler(delegateSuccessHandler);
}
项目:one-decision    文件:Application.java   
private AuthenticationSuccessHandler getSuccessHandler() {
    RedirectingAuthenticationSuccessHandler successHandler = new RedirectingAuthenticationSuccessHandler(
            "/");
    successHandler.setDefaultTargetUrl("/index.html");
    successHandler.setTargetUrlParameter("redirect");
    return successHandler;
}
项目:find    文件:InMemoryHodSecurity.java   
@SuppressWarnings("ProhibitedExceptionDeclared")
@Override
protected void configure(final HttpSecurity http) throws Exception {
    final AuthenticationSuccessHandler loginSuccessHandler = new LoginSuccessHandler(FindRole.CONFIG.toString(), FindController.CONFIG_PATH, "/p/");
    final HttpSessionRequestCache requestCache = new HttpSessionRequestCache();

    requestCache.setRequestMatcher(new OrRequestMatcher(
            new AntPathRequestMatcher("/p/**"),
            new AntPathRequestMatcher(FindController.CONFIG_PATH)
    ));

    http.regexMatcher("/p/.*|/config/.*|/authenticate|/logout")
        .authorizeRequests()
            .antMatchers("/p/**").hasRole(FindRole.ADMIN.name())
            .antMatchers(FindController.CONFIG_PATH).hasRole(FindRole.CONFIG.name())
            .and()
        .requestCache()
            .requestCache(requestCache)
            .and()
        .formLogin()
            .loginPage(FindController.DEFAULT_LOGIN_PAGE)
            .loginProcessingUrl("/authenticate")
            .successHandler(loginSuccessHandler)
            .failureUrl(FindController.DEFAULT_LOGIN_PAGE + "?error=auth")
            .and()
        .logout()
            .logoutSuccessHandler(new HodLogoutSuccessHandler(new HodTokenLogoutSuccessHandler(SsoController.SSO_LOGOUT_PAGE, tokenRepository), FindController.APP_PATH))
            .and()
        .csrf()
            .disable();
}
项目:springfield    文件:UserSuccessHandlerDetector.java   
@Override
public void afterPropertiesSet() throws Exception {
       try{
        Map<String,AuthenticationSuccessHandler> beans = applicationContext.getBeansOfType(AuthenticationSuccessHandler.class);

        for(AuthenticationSuccessHandler h : beans.values()){
            if(! ClassUtils.isAssignableValue(getClass(), h)){
                this.handler = h;
                break;
            }
        }
       }catch(Exception e){
        logger.debug("", e);
       }
}
项目:loafer    文件:SecurityConfiguration.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    return new AuthenticationSuccessHandlerImpl();
}
项目:JenkinsHue    文件:SecurityConfiguration.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    return (req, res, aut) -> res.setStatus(HttpServletResponse.SC_OK);
}
项目:spring-backend-boilerplate    文件:OpenApiSecurityConfigurer.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandlerImpl() {
    return new AuthenticationSuccessHandlerRestImpl();
}
项目:springuni-particles    文件:ProceedingRememberMeAuthenticationFilter.java   
@Override
public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) {
  this.successHandler = successHandler;
}
项目:springuni-particles    文件:SecurityConfigurationSupport.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler(
    JwtTokenService jwtTokenService) {
  return new DefaultAuthenticationSuccessHandler(jwtTokenService);
}
项目:cfsummiteu2017    文件:UaaRelyingPartyFilter.java   
public AuthenticationSuccessHandler getSuccessHandler() {
    return successHandler;
}
项目:cfsummiteu2017    文件:UaaRelyingPartyFilter.java   
public void setSuccessHandler(AuthenticationSuccessHandler successHandler) {
    this.successHandler = successHandler;
}
项目:FCat    文件:WebSecurityConfig.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
  return new CustomAuthenticationSuccessHandler();
}
项目:programmeren3    文件:ApplicationSecurityConfig.java   
@Bean
public AuthenticationSuccessHandler successHandler() {
    return new LoginSuccessHandler("/");
}
项目:graviteeio-access-management    文件:OAuth2SecurityConfiguration.java   
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
    successHandler.setRedirectStrategy(new XForwardedAwareRedirectStrategy());
    return successHandler;
}
项目:bag-database    文件:SecurityConfig.java   
@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    return new AjaxAuthenticationSuccessHandler("/");
}
项目:smt-spring-security-parent    文件:CookieAndHeaderJwtAuthenticationSuccessHandler.java   
@Override
public JwtAuthenticationSuccessHandler withDelegate(AuthenticationSuccessHandler delegate) {
    this.delegate = delegate;
    return this;
}