cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1349481 - in /cxf/fediz/trunk: plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java pom.xml
Date Tue, 12 Jun 2012 19:23:49 GMT
Author: owulff
Date: Tue Jun 12 19:23:48 2012
New Revision: 1349481

URL: http://svn.apache.org/viewvc?rev=1349481&view=rev
Log:
Metadata document support added for Tomcat plugin

Modified:
    cxf/fediz/trunk/plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
    cxf/fediz/trunk/pom.xml

Modified: cxf/fediz/trunk/plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java?rev=1349481&r1=1349480&r2=1349481&view=diff
==============================================================================
--- cxf/fediz/trunk/plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
(original)
+++ cxf/fediz/trunk/plugins/tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
Tue Jun 12 19:23:48 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.fediz.tomcat;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Date;
@@ -30,6 +31,8 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.bind.JAXBException;
 
+import org.w3c.dom.Document;
+
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.Session;
 import org.apache.catalina.authenticator.Constants;
@@ -48,6 +51,8 @@ import org.apache.cxf.fediz.core.config.
 import org.apache.cxf.fediz.core.exception.ProcessingException;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.ws.security.util.DOM2Writer;
+
 
 public class FederationAuthenticator extends FormAuthenticator {
 
@@ -148,6 +153,30 @@ public class FederationAuthenticator ext
     ServletException {
 
         LOG.debug("WsFedAuthenticator:invoke()");
+        if (request.getRequestURL().indexOf(FederationConstants.METADATA_PATH_URI) != -1)
{
+            if (LOG.isInfoEnabled()) {
+                LOG.info("WS-Federation Metadata document requested");
+            }
+            response.setContentType("text/xml");
+            PrintWriter out = response.getWriter();
+            
+            String contextName = request.getServletContext().getContextPath();
+            if (contextName == null || contextName.isEmpty()) {
+                contextName = "/";
+            }
+            FederationContext fedConfig = getContextConfiguration(contextName);
+            FederationProcessor wfProc = new FederationProcessorImpl();
+            try {
+                Document metadata = wfProc.getMetaData(fedConfig);
+                out.write(DOM2Writer.nodeToString(metadata));
+                return;
+            } catch (Exception ex) {
+                LOG.error("Failed to get metadata document: " + ex.getMessage());
+                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                return;
+            }            
+        }
+        
         super.invoke(request, response);
 
     }

Modified: cxf/fediz/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/pom.xml?rev=1349481&r1=1349480&r2=1349481&view=diff
==============================================================================
--- cxf/fediz/trunk/pom.xml (original)
+++ cxf/fediz/trunk/pom.xml Tue Jun 12 19:23:48 2012
@@ -30,7 +30,7 @@
     <parent>
         <groupId>org.apache</groupId>
         <artifactId>apache</artifactId>
-        <version>9</version>
+        <version>10</version>
     </parent>
 
     <properties>



Mime
View raw message