Example usage for org.springframework.security.web.authentication.www BasicAuthenticationFilter getClass

List of usage examples for org.springframework.security.web.authentication.www BasicAuthenticationFilter getClass

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication.www BasicAuthenticationFilter getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.springframework.cloud.dataflow.server.config.security.OAuthSecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    final RequestMatcher textHtmlMatcher = new MediaTypeRequestMatcher(
            new BrowserDetectingContentNegotiationStrategy(), MediaType.TEXT_HTML);

    final BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint();
    basicAuthenticationEntryPoint.setRealmName(securityProperties.getBasic().getRealm());
    basicAuthenticationEntryPoint.afterPropertiesSet();

    final Filter oauthFilter = oauthFilter();
    BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter(providerManager(),
            basicAuthenticationEntryPoint);

    http.addFilterAfter(oauthFilter, basicAuthenticationFilter.getClass());
    http.addFilterBefore(basicAuthenticationFilter, oauthFilter.getClass());
    http.addFilterBefore(oAuth2AuthenticationProcessingFilter(), basicAuthenticationFilter.getClass());

    http.authorizeRequests()//ww w . j  a v a2s .  com
            .antMatchers("/security/info**", "/login**", dashboard("/logout-success-oauth.html"),
                    dashboard("/styles/**"), dashboard("/images/**"), dashboard("/fonts/**"),
                    dashboard("/lib/**"))
            .permitAll().anyRequest().authenticated().and().httpBasic().and().logout()
            .logoutSuccessUrl(dashboard("/logout-success-oauth.html")).and().csrf().disable()
            .exceptionHandling()
            .defaultAuthenticationEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), textHtmlMatcher)
            .defaultAuthenticationEntryPointFor(basicAuthenticationEntryPoint, AnyRequestMatcher.INSTANCE);

    securityStateBean.setAuthenticationEnabled(true);
    securityStateBean.setAuthorizationEnabled(false);
}