Codota Logo
org.springframework.security.web.access
Code IndexAdd Codota to your IDE (free)

How to use org.springframework.security.web.access

Best Java code snippets using org.springframework.security.web.access (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-security

/**
 * Gets the {@link WebInvocationPrivilegeEvaluator} to be used.
 * @return the {@link WebInvocationPrivilegeEvaluator} for further customizations
 */
public WebInvocationPrivilegeEvaluator getPrivilegeEvaluator() {
  if (privilegeEvaluator != null) {
    return privilegeEvaluator;
  }
  return filterSecurityInterceptor == null ? null
      : new DefaultWebInvocationPrivilegeEvaluator(filterSecurityInterceptor);
}
origin: spring-projects/spring-security

private AccessDeniedHandler createDefaultDeniedHandler(H http) {
  if (this.defaultDeniedHandlerMappings.isEmpty()) {
    return new AccessDeniedHandlerImpl();
  }
  if (this.defaultDeniedHandlerMappings.size() == 1) {
    return this.defaultDeniedHandlerMappings.values().iterator().next();
  }
  return new RequestMatcherDelegatingAccessDeniedHandler(
      this.defaultDeniedHandlerMappings,
      new AccessDeniedHandlerImpl());
}
origin: spring-projects/spring-security

/**
 * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error
 * page
 *
 * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401)
 * @return the {@link ExceptionHandlingConfigurer} for further customization
 * @see AccessDeniedHandlerImpl
 * @see #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler)
 */
public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) {
  AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
  accessDeniedHandler.setErrorPage(accessDeniedUrl);
  return accessDeniedHandler(accessDeniedHandler);
}
origin: spring-projects/spring-security

@Before
public void setUp() throws Exception {
  AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
  fsi = new FilterSecurityInterceptor();
  fsi.setAccessDecisionManager(accessDecisionManager);
  fsi.setSecurityMetadataSource(metadataSource);
  AuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(
      "/login");
  ExceptionTranslationFilter etf = new ExceptionTranslationFilter(
      authenticationEntryPoint);
  DefaultSecurityFilterChain securityChain = new DefaultSecurityFilterChain(
      AnyRequestMatcher.INSTANCE, aaf, etf, fsi);
  fcp = new FilterChainProxy(securityChain);
  validator = new DefaultFilterChainValidator();
  ReflectionTestUtils.setField(validator, "logger", logger);
}
origin: geoserver/geoserver

ExceptionTranslationFilter filter = new ExceptionTranslationFilter(ep, cache);
AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
    accessDeniedHandler.setErrorPage(authConfig.getAccessDeniedErrorPage());
  else LOGGER.warning("Cannot find: " + authConfig.getAccessDeniedErrorPage());
filter.setAccessDeniedHandler(accessDeniedHandler);
filter.afterPropertiesSet();
getNestedFilters().add(filter);
origin: spring-projects/spring-security

    || !(etf.getAuthenticationEntryPoint() instanceof LoginUrlAuthenticationEntryPoint)) {
  return;
    .getAuthenticationEntryPoint()).getLoginFormUrl();
logger.info("Checking whether login URL '" + loginPage
    + "' is accessible with your configuration");
FilterInvocationSecurityMetadataSource fids = fsi.getSecurityMetadataSource();
Collection<ConfigAttribute> attributes = fids.getAttributes(loginRequest);
  if (fsi.isRejectPublicInvocations()) {
    logger.warn("FilterSecurityInterceptor is configured to reject public invocations."
        + " Your login page may not be accessible.");
    anonPF.getPrincipal(), anonPF.getAuthorities());
try {
  fsi.getAccessDecisionManager().decide(token, loginRequest, attributes);
origin: spring-projects/spring-security

@Override
public void configure(H http) throws Exception {
  AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http);
  ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(
      entryPoint, getRequestCache(http));
  AccessDeniedHandler deniedHandler = getAccessDeniedHandler(http);
  exceptionTranslationFilter.setAccessDeniedHandler(deniedHandler);
  exceptionTranslationFilter = postProcess(exceptionTranslationFilter);
  http.addFilter(exceptionTranslationFilter);
}
origin: spring-projects/spring-security

/**
 * Gets the default {@link AccessDeniedHandler} from the
 * {@link ExceptionHandlingConfigurer#getAccessDeniedHandler()} or create a
 * {@link AccessDeniedHandlerImpl} if not available.
 *
 * @param http the {@link HttpSecurityBuilder}
 * @return the {@link AccessDeniedHandler}
 */
@SuppressWarnings("unchecked")
private AccessDeniedHandler getDefaultAccessDeniedHandler(H http) {
  ExceptionHandlingConfigurer<H> exceptionConfig = http
      .getConfigurer(ExceptionHandlingConfigurer.class);
  AccessDeniedHandler handler = null;
  if (exceptionConfig != null) {
    handler = exceptionConfig.getAccessDeniedHandler();
  }
  if (handler == null) {
    handler = new AccessDeniedHandlerImpl();
  }
  return handler;
}
origin: psi-probe/psi-probe

/**
 * Gets the exception translation filter.
 *
 * @return the exception translation filter
 */
@Bean(name = "etf")
public ExceptionTranslationFilter getExceptionTranslationFilter() {
 return new ExceptionTranslationFilter(getHttp403ForbiddenEntryPoint());
}
origin: spring-projects/spring-security-oauth

/**
 * Common logic for OAuth failed. (Note that the default logic doesn't pass the failure through so as to not mess
 * with the current authentication.)
 *
 * @param request  The request.
 * @param response The response.
 * @param failure  The failure.
 * @throws ServletException in the case of an underlying Servlet API exception
 * @throws IOException in the case of general IO exceptions
 */
protected void fail(HttpServletRequest request, HttpServletResponse response, OAuthRequestFailedException failure) throws IOException, ServletException {
  try {
    //attempt to set the last exception.
    request.getSession().setAttribute(OAUTH_FAILURE_KEY, failure);
  }
  catch (Exception e) {
    //fall through....
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug(failure);
  }
  if (getOAuthFailureHandler() != null) {
    getOAuthFailureHandler().handle(request, response, failure);
  }
  else {
    throw failure;
  }
}
origin: spring-projects/spring-security

/**
 * Creates the {@link AccessDeniedHandler} from the result of
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} and
 * {@link #getInvalidSessionStrategy(HttpSecurityBuilder)}. If
 * {@link #getInvalidSessionStrategy(HttpSecurityBuilder)} is non-null, then a
 * {@link DelegatingAccessDeniedHandler} is used in combination with
 * {@link InvalidSessionAccessDeniedHandler} and the
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)}. Otherwise, only
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} is used.
 *
 * @param http the {@link HttpSecurityBuilder}
 * @return the {@link AccessDeniedHandler}
 */
private AccessDeniedHandler createAccessDeniedHandler(H http) {
  InvalidSessionStrategy invalidSessionStrategy = getInvalidSessionStrategy(http);
  AccessDeniedHandler defaultAccessDeniedHandler = getDefaultAccessDeniedHandler(
      http);
  if (invalidSessionStrategy == null) {
    return defaultAccessDeniedHandler;
  }
  InvalidSessionAccessDeniedHandler invalidSessionDeniedHandler = new InvalidSessionAccessDeniedHandler(
      invalidSessionStrategy);
  LinkedHashMap<Class<? extends AccessDeniedException>, AccessDeniedHandler> handlers = new LinkedHashMap<Class<? extends AccessDeniedException>, AccessDeniedHandler>();
  handlers.put(MissingCsrfTokenException.class, invalidSessionDeniedHandler);
  return new DelegatingAccessDeniedHandler(handlers, defaultAccessDeniedHandler);
}
origin: spring-projects/spring-security-oauth

String failurePage = element.getAttribute("oauth-failure-page");
if (StringUtils.hasText(failurePage)) {
 AccessDeniedHandlerImpl failureHandler = new AccessDeniedHandlerImpl();
 failureHandler.setErrorPage(failurePage);
 consumerContextFilterBean.addPropertyValue("OAuthFailureHandler", failureHandler);
origin: org.springframework.security/spring-security-config

@Override
public void configure(H http) throws Exception {
  AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http);
  ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(
      entryPoint, getRequestCache(http));
  AccessDeniedHandler deniedHandler = getAccessDeniedHandler(http);
  exceptionTranslationFilter.setAccessDeniedHandler(deniedHandler);
  exceptionTranslationFilter = postProcess(exceptionTranslationFilter);
  http.addFilter(exceptionTranslationFilter);
}
origin: spring-projects/spring-security

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    // @formatter:off
    http
      .authorizeRequests()
        .anyRequest().denyAll()
        .and()
      .exceptionHandling()
        .defaultAccessDeniedHandlerFor(
            this.teapotDeniedHandler,
            new AntPathRequestMatcher("/hello/**"))
        .defaultAccessDeniedHandlerFor(
            new AccessDeniedHandlerImpl(),
            AnyRequestMatcher.INSTANCE);
    // @formatter:on
  }
}
origin: org.springframework.security/spring-security-config

private AccessDeniedHandler createDefaultDeniedHandler(H http) {
  if (this.defaultDeniedHandlerMappings.isEmpty()) {
    return new AccessDeniedHandlerImpl();
  }
  if (this.defaultDeniedHandlerMappings.size() == 1) {
    return this.defaultDeniedHandlerMappings.values().iterator().next();
  }
  return new RequestMatcherDelegatingAccessDeniedHandler(
      this.defaultDeniedHandlerMappings,
      new AccessDeniedHandlerImpl());
}
origin: org.springframework.security/spring-security-config

/**
 * Gets the {@link WebInvocationPrivilegeEvaluator} to be used.
 * @return the {@link WebInvocationPrivilegeEvaluator} for further customizations
 */
public WebInvocationPrivilegeEvaluator getPrivilegeEvaluator() {
  if (privilegeEvaluator != null) {
    return privilegeEvaluator;
  }
  return filterSecurityInterceptor == null ? null
      : new DefaultWebInvocationPrivilegeEvaluator(filterSecurityInterceptor);
}
origin: org.springframework.security/spring-security-config

/**
 * Creates the {@link AccessDeniedHandler} from the result of
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} and
 * {@link #getInvalidSessionStrategy(HttpSecurityBuilder)}. If
 * {@link #getInvalidSessionStrategy(HttpSecurityBuilder)} is non-null, then a
 * {@link DelegatingAccessDeniedHandler} is used in combination with
 * {@link InvalidSessionAccessDeniedHandler} and the
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)}. Otherwise, only
 * {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} is used.
 *
 * @param http the {@link HttpSecurityBuilder}
 * @return the {@link AccessDeniedHandler}
 */
private AccessDeniedHandler createAccessDeniedHandler(H http) {
  InvalidSessionStrategy invalidSessionStrategy = getInvalidSessionStrategy(http);
  AccessDeniedHandler defaultAccessDeniedHandler = getDefaultAccessDeniedHandler(
      http);
  if (invalidSessionStrategy == null) {
    return defaultAccessDeniedHandler;
  }
  InvalidSessionAccessDeniedHandler invalidSessionDeniedHandler = new InvalidSessionAccessDeniedHandler(
      invalidSessionStrategy);
  LinkedHashMap<Class<? extends AccessDeniedException>, AccessDeniedHandler> handlers = new LinkedHashMap<Class<? extends AccessDeniedException>, AccessDeniedHandler>();
  handlers.put(MissingCsrfTokenException.class, invalidSessionDeniedHandler);
  return new DelegatingAccessDeniedHandler(handlers, defaultAccessDeniedHandler);
}
origin: org.springframework.security/spring-security-config

/**
 * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error
 * page
 *
 * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401)
 * @return the {@link ExceptionHandlingConfigurer} for further customization
 * @see AccessDeniedHandlerImpl
 * @see #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler)
 */
public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) {
  AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
  accessDeniedHandler.setErrorPage(accessDeniedUrl);
  return accessDeniedHandler(accessDeniedHandler);
}
origin: spring-projects/spring-security

@Override
protected void configure(HttpSecurity http) throws Exception {
  // @formatter:off
  http
    .authorizeRequests()
      .anyRequest().denyAll()
      .and()
    .exceptionHandling()
      .defaultAccessDeniedHandlerFor(new AccessDeniedHandlerImpl(), request -> false)
      .and()
    .httpBasic()
      .and()
    .oauth2ResourceServer()
      .jwt();
  // @formatter:on
}
origin: org.springframework.security/spring-security-config

/**
 * Gets the default {@link AccessDeniedHandler} from the
 * {@link ExceptionHandlingConfigurer#getAccessDeniedHandler()} or create a
 * {@link AccessDeniedHandlerImpl} if not available.
 *
 * @param http the {@link HttpSecurityBuilder}
 * @return the {@link AccessDeniedHandler}
 */
@SuppressWarnings("unchecked")
private AccessDeniedHandler getDefaultAccessDeniedHandler(H http) {
  ExceptionHandlingConfigurer<H> exceptionConfig = http
      .getConfigurer(ExceptionHandlingConfigurer.class);
  AccessDeniedHandler handler = null;
  if (exceptionConfig != null) {
    handler = exceptionConfig.getAccessDeniedHandler();
  }
  if (handler == null) {
    handler = new AccessDeniedHandlerImpl();
  }
  return handler;
}
org.springframework.security.web.access

Most used classes

  • AccessDeniedHandlerImpl
    Base implementation of AccessDeniedHandler. This implementation sends a 403 (SC_FORBIDDEN) HTTP erro
  • ExceptionTranslationFilter
  • FilterSecurityInterceptor
    Performs security handling of HTTP resources via a filter implementation. The SecurityMetadataSource
  • WebInvocationPrivilegeEvaluator
    Allows users to determine whether they have privileges for a given web URI.
  • DefaultWebSecurityExpressionHandler
  • FilterInvocationSecurityMetadataSource,
  • WebExpressionVoter,
  • AccessDeniedHandler,
  • ExpressionBasedFilterInvocationSecurityMetadataSource,
  • DefaultWebInvocationPrivilegeEvaluator,
  • ChannelDecisionManagerImpl,
  • ChannelProcessingFilter,
  • InsecureChannelProcessor,
  • RetryWithHttpEntryPoint,
  • RetryWithHttpsEntryPoint,
  • SecureChannelProcessor,
  • WebSecurityExpressionRoot,
  • DelegatingAccessDeniedHandler,
  • RequestMatcherDelegatingAccessDeniedHandler
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now