use of org.springframework.security.web.access.AccessDeniedHandlerImpl in project spring-security by spring-projects.
the class CsrfConfigurer method getDefaultAccessDeniedHandler.
/**
* Gets the default {@link AccessDeniedHandler} from the
* {@link ExceptionHandlingConfigurer#getAccessDeniedHandler(HttpSecurityBuilder)} 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(http);
}
if (handler == null) {
handler = new AccessDeniedHandlerImpl();
}
return handler;
}
use of org.springframework.security.web.access.AccessDeniedHandlerImpl in project midpoint by Evolveum.
the class MidpointExceptionHandlingConfigurer method accessDeniedPage.
public MidpointExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) {
AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
accessDeniedHandler.setErrorPage(accessDeniedUrl);
return accessDeniedHandler(accessDeniedHandler);
}
use of org.springframework.security.web.access.AccessDeniedHandlerImpl in project spring-security-oauth by spring-projects.
the class OAuthConsumerBeanDefinitionParser method parse.
public BeanDefinition parse(Element element, ParserContext parserContext) {
BeanDefinitionBuilder consumerContextFilterBean = BeanDefinitionBuilder.rootBeanDefinition(OAuthConsumerContextFilter.class);
String failureHandlerRef = element.getAttribute("failure-handler-ref");
if (StringUtils.hasText(failureHandlerRef)) {
consumerContextFilterBean.addPropertyReference("OAuthFailureHandler", failureHandlerRef);
} else {
String failurePage = element.getAttribute("oauth-failure-page");
if (StringUtils.hasText(failurePage)) {
AccessDeniedHandlerImpl failureHandler = new AccessDeniedHandlerImpl();
failureHandler.setErrorPage(failurePage);
consumerContextFilterBean.addPropertyValue("OAuthFailureHandler", failureHandler);
}
}
String resourceDetailsRef = element.getAttribute("resource-details-service-ref");
String supportRef = element.getAttribute("support-ref");
if (!StringUtils.hasText(supportRef)) {
BeanDefinitionBuilder consumerSupportBean = BeanDefinitionBuilder.rootBeanDefinition(CoreOAuthConsumerSupport.class);
if (StringUtils.hasText(resourceDetailsRef)) {
consumerSupportBean.addPropertyReference("protectedResourceDetailsService", resourceDetailsRef);
}
parserContext.getRegistry().registerBeanDefinition("oauthConsumerSupport", consumerSupportBean.getBeanDefinition());
supportRef = "oauthConsumerSupport";
}
consumerContextFilterBean.addPropertyReference("consumerSupport", supportRef);
String tokenServicesFactoryRef = element.getAttribute("token-services-ref");
if (StringUtils.hasText(tokenServicesFactoryRef)) {
consumerContextFilterBean.addPropertyReference("tokenServices", tokenServicesFactoryRef);
}
String rememberMeServicesRef = element.getAttribute("remember-me-services-ref");
if (StringUtils.hasText(rememberMeServicesRef)) {
consumerContextFilterBean.addPropertyReference("rememberMeServices", rememberMeServicesRef);
}
String redirectStrategyRef = element.getAttribute("redirect-strategy-ref");
if (StringUtils.hasText(redirectStrategyRef)) {
consumerContextFilterBean.addPropertyReference("redirectStrategy", redirectStrategyRef);
}
parserContext.getRegistry().registerBeanDefinition("oauthConsumerContextFilter", consumerContextFilterBean.getBeanDefinition());
List<BeanMetadataElement> filterChain = ConfigUtils.findFilterChain(parserContext, element.getAttribute("filter-chain-ref"));
filterChain.add(filterChain.size(), new RuntimeBeanReference("oauthConsumerContextFilter"));
BeanDefinition fids = ConfigUtils.createSecurityMetadataSource(element, parserContext);
if (fids != null) {
BeanDefinitionBuilder consumerAccessFilterBean = BeanDefinitionBuilder.rootBeanDefinition(OAuthConsumerProcessingFilter.class);
if (StringUtils.hasText(resourceDetailsRef)) {
consumerAccessFilterBean.addPropertyReference("protectedResourceDetailsService", resourceDetailsRef);
}
String requireAuthenticated = element.getAttribute("requireAuthenticated");
if (StringUtils.hasText(requireAuthenticated)) {
consumerAccessFilterBean.addPropertyValue("requireAuthenticated", requireAuthenticated);
}
consumerAccessFilterBean.addPropertyValue("objectDefinitionSource", fids);
parserContext.getRegistry().registerBeanDefinition("oauthConsumerFilter", consumerAccessFilterBean.getBeanDefinition());
filterChain.add(filterChain.size(), new RuntimeBeanReference("oauthConsumerFilter"));
}
return null;
}
use of org.springframework.security.web.access.AccessDeniedHandlerImpl in project spring-security by spring-projects.
the class ExceptionHandlingConfigurer method accessDeniedPage.
/**
* 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);
}
Aggregations