Java 类org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint 实例源码

项目:mojito    文件:WebSecurityConfig.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    logger.debug("Configuring web security");

    http.headers().cacheControl().disable();
    http.authorizeRequests()
            // TODO (move img to images)
            // TODO (move intl to js/intl)
            .antMatchers("/intl/*", "/img/*", "/fonts/*", "/webjars/**", "/cli/**").permitAll()
            .regexMatchers("/login\\?.*").permitAll()
            .anyRequest().fullyAuthenticated()
            .and()
            .formLogin()
            .loginPage("/login").permitAll()
            .successHandler(new ShowPageAuthenticationSuccessHandler())
            .and()
            .logout().logoutSuccessUrl("/login?logout").permitAll();

    http.exceptionHandling().defaultAuthenticationEntryPointFor(new Http401AuthenticationEntryPoint("API_UNAUTHORIZED"), new AntPathRequestMatcher("/api/*"));
    http.exceptionHandling().defaultAuthenticationEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), new AntPathRequestMatcher("/*"));
}
项目:SpringBootDemoApp    文件:SecurityConfiguration.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.addFilterBefore(corsFilter, UsernamePasswordAuthenticationFilter.class)
        .exceptionHandling()
        .authenticationEntryPoint(new Http401AuthenticationEntryPoint("TBD"))
        .and()
        .csrf()
        .disable()
        .headers()
        .frameOptions()
        .disable()
        .and()
        .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
        .authorizeRequests()
        .antMatchers("/api/register")
        .permitAll()
        .antMatchers("/api/activate")
        .permitAll()
        .antMatchers("/api/authenticate")
        .permitAll()
        .antMatchers("/api/account/reset_password/init")
        .permitAll()
        .antMatchers("/api/account/reset_password/finish")
        .permitAll()
        .antMatchers("/api/**")
        .authenticated()
        .and()
        .apply(securityConfigurerAdapter());

}
项目:cas-security-spring-boot-starter    文件:CasSecuritySpringBootSampleApplication.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.antMatcher("/api/**").authorizeRequests().anyRequest().authenticated();
    // Applying CAS security on current HttpSecurity (FilterChain)
    // I'm not using .apply() from HttpSecurity due to following issue
    // https://github.com/spring-projects/spring-security/issues/4422
    CasHttpSecurityConfigurer.cas().configure(http);
    http.exceptionHandling().authenticationEntryPoint(new Http401AuthenticationEntryPoint("CAS"));
}
项目:uaa-service    文件:WebSecurityConfig.java   
@Bean
public Http401AuthenticationEntryPoint securityException401EntryPoint() {
    return new Http401AuthenticationEntryPoint("401 Authentification Exception");
}