Permalink
Browse files

SECOAUTH-234: register failure handler with authorization filter.

  • Loading branch information...
1 parent e7ed78c commit 6280254e061690d8d13c248e1d0b21bd5482a254 Geert van der Ploeg committed Apr 4, 2012
@@ -86,15 +86,15 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
if (StringUtils.hasText(callbackUrlParam)) {
successfulAuthenticationHandler.addPropertyValue("callbackParameterName", callbackUrlParam);
}
-
+
// create a AuthenticationFailureHandler
- BeanDefinitionBuilder simpleUrlAuthenticationFailureHandler = BeanDefinitionBuilder.rootBeanDefinition(SimpleUrlAuthenticationFailureHandler.class);
+ BeanDefinitionBuilder failedAuthenticationHandler = BeanDefinitionBuilder.rootBeanDefinition(SimpleUrlAuthenticationFailureHandler.class);
String authenticationFailedURL = element.getAttribute("authentication-failed-url");
if (StringUtils.hasText(authenticationFailedURL)) {
- simpleUrlAuthenticationFailureHandler.addConstructorArgValue (authenticationFailedURL);
+ failedAuthenticationHandler.addConstructorArgValue (authenticationFailedURL);
}
else {
- simpleUrlAuthenticationFailureHandler.addConstructorArgValue ("/");
+ failedAuthenticationHandler.addConstructorArgValue ("/");
}
String tokenIdParam = element.getAttribute("token-id-param");
@@ -165,6 +165,11 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
parserContext.getRegistry().registerBeanDefinition(oauthSuccessfulAuthenticationHandlerRef, successfulAuthenticationHandler.getBeanDefinition());
authenticateTokenFilterBean.addPropertyReference("authenticationSuccessHandler", oauthSuccessfulAuthenticationHandlerRef);
+ // register the failure handler with the UserAuthorizationFilter
+ String oauthFailedAuthenticationHandlerRef = "oauthFailedAuthenticationHandler";
+ parserContext.getRegistry().registerBeanDefinition(oauthFailedAuthenticationHandlerRef, failedAuthenticationHandler.getBeanDefinition());
+ authenticateTokenFilterBean.addPropertyReference("authenticationFailureHandler", oauthFailedAuthenticationHandlerRef);
+
List<BeanMetadataElement> filterChain = ConfigUtils.findFilterChain(parserContext, element.getAttribute("filter-chain-ref"));
int index = insertIndex(filterChain);
parserContext.getRegistry().registerBeanDefinition("oauthRequestTokenFilter", requestTokenFilterBean.getBeanDefinition());

0 comments on commit 6280254

Please sign in to comment.