This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf-fediz.git
The following commit(s) were added to refs/heads/master by this push:
new 117f271 Provide a custom way of handling a request + exception in the
Spring plugin
117f271 is described below
commit 117f271770dded3e1039c77948a76f39ded6314c
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Thu Sep 6 10:47:15 2018 +0100
Provide a custom way of handling a request + exception in the Spring plugin
---
.../spring/web/FederationAuthenticationEntryPoint.java | 16 ++++++++++++++++
.../web/FederationAuthenticationFailureHandler.java | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
diff --git
a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
index 16dfbf4..9da52e7 100644
---
a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
+++
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpSession;
import org.apache.cxf.fediz.core.config.FedizContext;
import org.apache.cxf.fediz.core.exception.ProcessingException;
+import org.apache.cxf.fediz.core.handler.RequestHandler;
import org.apache.cxf.fediz.core.metadata.MetadataDocumentHandler;
import org.apache.cxf.fediz.core.processor.FedizProcessor;
import org.apache.cxf.fediz.core.processor.FedizProcessorFactory;
@@ -65,6 +66,15 @@ public class FederationAuthenticationEntryPoint implements
AuthenticationEntryPo
private ApplicationContext appContext;
private FederationConfig federationConfig;
+ private RequestHandler<?> requestHandler;
+
+ public RequestHandler<?> getRequestHandler() {
+ return requestHandler;
+ }
+
+ public void setRequestHandler(RequestHandler<?> requestHandler) {
+ this.requestHandler = requestHandler;
+ }
public FederationConfig getFederationConfig() {
return federationConfig;
@@ -85,6 +95,12 @@ public class FederationAuthenticationEntryPoint implements
AuthenticationEntryPo
FedizContext fedContext = federationConfig.getFedizContext();
LOG.debug("Federation context: {}", fedContext);
+ // First see if we want to handle the request in some custom way
+ if (requestHandler != null &&
requestHandler.canHandleRequest(servletRequest)) {
+ requestHandler.handleRequest(servletRequest, response);
+ return;
+ }
+
// Check to see if it is a metadata request
MetadataDocumentHandler mdHandler = new
MetadataDocumentHandler(fedContext);
if (mdHandler.canHandleRequest(servletRequest)) {
diff --git
a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationFailureHandler.java
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationFailureHandler.java
index 99d9f5d..942a566 100644
---
a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationFailureHandler.java
+++
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationFailureHandler.java
@@ -25,6 +25,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.cxf.fediz.core.handler.RequestHandler;
import org.apache.cxf.fediz.spring.FederationConfig;
import org.apache.cxf.fediz.spring.authentication.ExpiredTokenException;
import org.springframework.security.core.AuthenticationException;
@@ -36,6 +37,7 @@ import
org.springframework.security.web.authentication.SimpleUrlAuthenticationFa
public class FederationAuthenticationFailureHandler extends
SimpleUrlAuthenticationFailureHandler {
private FederationConfig federationConfig;
+ private RequestHandler<?> requestHandler;
public FederationAuthenticationFailureHandler() {
super();
@@ -45,6 +47,12 @@ public class FederationAuthenticationFailureHandler extends
SimpleUrlAuthenticat
public void onAuthenticationFailure(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException exception)
throws IOException, ServletException {
+ // First see if we want to handle the request in some custom way
+ if (requestHandler != null &&
requestHandler.canHandleRequest(request)) {
+ requestHandler.handleRequest(request, response);
+ return;
+ }
+
if (exception instanceof ExpiredTokenException) {
// Just redirect back to the original URL and re-start the
authentication process.
response.sendRedirect(request.getRequestURL().toString());
@@ -62,4 +70,12 @@ public class FederationAuthenticationFailureHandler extends
SimpleUrlAuthenticat
this.federationConfig = fedConfig;
}
+ public RequestHandler<?> getRequestHandler() {
+ return requestHandler;
+ }
+
+ public void setRequestHandler(RequestHandler<?> requestHandler) {
+ this.requestHandler = requestHandler;
+ }
+
}
\ No newline at end of file