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


Java ExceptionTranslationFilter类代码示例

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


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

示例1: configure

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
@Override
    protected void configure(HttpSecurity http) throws Exception
    {
        super.configure(http);
        http
                .authorizeRequests()
//                .antMatchers("/customers*").hasRole("USER")
//                .antMatchers("/admin*").hasRole("ADMIN")
                .antMatchers(HttpMethod.GET, "/api/account").permitAll()
                .anyRequest().authenticated()
                .and()
                    .logout()
                    .logoutUrl("/api/logout")
                    .logoutSuccessHandler(ajaxLogoutSuccessHandler)
                    .deleteCookies("JSESSIONID", "CSRF-TOKEN")
                    .permitAll()
                .and().exceptionHandling();

        if (!csrfEnabled) {
            http.csrf().disable();
        } else {
            http.csrf().csrfTokenRepository(tokenRepository());
        }
        http.addFilterAfter(this.customRedirectFilter(), ExceptionTranslationFilter.class);
    }
 
开发者ID:giovannicandido,项目名称:generator-spring-spa,代码行数:26,代码来源:SecurityConfig.java

示例2: configure

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
    if (noauthdevmode && devmode) {
        // don't configure any security
    } else {
        http
            .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessHandler(logoutHandler()).and()
            .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint()).and()
            .authorizeRequests()
            .antMatchers("/my/**").authenticated()
            .anyRequest().permitAll().and()
            .addFilterBefore(oasisAuthenticationFilter(), AbstractPreAuthenticatedProcessingFilter.class);
    }
    http
        .addFilterAfter(oasisExceptionTranslationFilter(authenticationEntryPoint()), ExceptionTranslationFilter.class);
}
 
开发者ID:ozwillo,项目名称:ozwillo-portal,代码行数:17,代码来源:OasisPortalSecurity.java

示例3: configure

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
	// @formatter:off
   	    http.authorizeRequests()
               .antMatchers("/sparklr/**","/facebook/**","/xvia/**","/xvscribe/**").hasRole("USER")
               .anyRequest().permitAll()
               .and()
           .addFilterAfter(oauth2ClientFilter(), ExceptionTranslationFilter.class)
           .logout()
               .logoutSuccessUrl("/login.jsp")
               .logoutUrl("/logout.do")
               .permitAll()
               .and()
           .formLogin()
               .loginPage("/login.jsp")
               .loginProcessingUrl("/login.do")
               .failureUrl("/login.jsp?authentication_error=true")
               .usernameParameter("j_username")
               .passwordParameter("j_password")
               .permitAll();
   	// @formatter:on
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:23,代码来源:SecurityConfig.java

示例4: configure

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
    configureHeaders(http.headers());
    http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint())
            .and().requestMatchers().antMatchers("/admin/**", "/signout").and()
            .addFilterAfter(new OncePerRequestFilter() {

                // TODO this filter needs to be removed once basic auth is removed
                @Override
                protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
                                                FilterChain filterChain) throws ServletException, IOException {
                    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
                    if (authentication == null || !authentication.isAuthenticated()
                            || !(authentication.getPrincipal() instanceof Long)) {
                        throw new BadCredentialsException("Not a github user!");
                    }
                    filterChain.doFilter(request, response);
                }
            }, ExceptionTranslationFilter.class);
    http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/signout"))
            .logoutSuccessUrl("/").and().authorizeRequests().anyRequest()
            .authenticated();
    if (isForceHttps()) {
        http.requiresChannel().anyRequest().requiresSecure();
    }
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:27,代码来源:SecurityConfig.java

示例5: exceptionTranslationFilter

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
@Bean
public ExceptionTranslationFilter exceptionTranslationFilter(){
    LoginUrlAuthenticationEntryPoint entryPoint = new LoginUrlAuthenticationEntryPoint("/index.xhtml");
    entryPoint.setForceHttps(false);
    AccessDeniedHandlerImpl handler = new AccessDeniedHandlerImpl();
    handler.setErrorPage("/index.xhtml");
    ExceptionTranslationFilter bean = new ExceptionTranslationFilter(entryPoint);
    bean.setAccessDeniedHandler(handler);
    return bean;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:11,代码来源:SecurityConfiguration.java

示例6: insertIndex

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
/**
 * Attempts to find the place in the filter chain to insert the spring security oauth filters. Currently,
 * these filters are inserted after the ExceptionTranslationFilter.
 *
 * @param filterChain The filter chain configuration.
 * @return The insert index.
 */
private int insertIndex(List<BeanMetadataElement> filterChain) {
  int i;
  for (i = 0; i < filterChain.size(); i++) {
    BeanMetadataElement filter = filterChain.get(i);
    if (filter instanceof BeanDefinition) {
      String beanName = ((BeanDefinition) filter).getBeanClassName();
      if (beanName.equals(ExceptionTranslationFilter.class.getName())) {
         return i + 1;
      }
    }
  }
  return filterChain.size();
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:21,代码来源:OAuthProviderBeanDefinitionParser.java

示例7: ssoHttpConfiguration

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
private static HttpSecurity ssoHttpConfiguration(HttpSecurity http, OAuth2ClientContextFilter client) throws Exception {
    // @formatter:off
    http
        .addFilterAfter(client, ExceptionTranslationFilter.class)
        .anonymous()
            .disable()
        .logout()
            .logoutUrl("/logout")
            .logoutSuccessUrl("/");
    // @formatter:on

    return http;
}
 
开发者ID:pivotalsoftware,项目名称:github-cla-integration,代码行数:14,代码来源:SecurityConfiguration.java

示例8: getExceptionTranslationFilter

import org.springframework.security.web.access.ExceptionTranslationFilter; //导入依赖的package包/类
/**
 * Gets the exception translation filter.
 *
 * @return the exception translation filter
 */
@Bean(name = "etf")
public ExceptionTranslationFilter getExceptionTranslationFilter() {
  return new ExceptionTranslationFilter(getHttp403ForbiddenEntryPoint());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:10,代码来源:ProbeSecurityConfig.java


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