cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1432506 - in /cxf/fediz/branches/1.0.x-fixes/services/idp/src/main: java/org/apache/cxf/fediz/service/idp/IdpServlet.java webapp/WEB-INF/applicationContext.xml webapp/WEB-INF/web.xml
Date Sat, 12 Jan 2013 20:31:07 GMT
Author: owulff
Date: Sat Jan 12 20:31:07 2013
New Revision: 1432506

URL: http://svn.apache.org/viewvc?rev=1432506&view=rev
Log:
[FEDIZ-43] No dependency on TCP port of IDP container in fedizidp.war

Modified:
    cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
    cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
    cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/web.xml

Modified: cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
URL: http://svn.apache.org/viewvc/cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java?rev=1432506&r1=1432505&r2=1432506&view=diff
==============================================================================
--- cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
(original)
+++ cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
Sat Jan 12 20:31:07 2013
@@ -19,6 +19,8 @@
 package org.apache.cxf.fediz.service.idp;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -94,16 +96,30 @@ public class IdpServlet extends HttpServ
      */
     private static final long serialVersionUID = -9019993850246851112L;
 
+    protected boolean isPortSet;
+    
+    protected String stsWsdlUrl;
+    
     private String tokenType;
 
     private Bus bus;
 
     @Override
     public void init() throws ServletException {
-        if (getInitParameter(S_PARAM_STS_WSDL_URL) == null) {
+        stsWsdlUrl = getInitParameter(S_PARAM_STS_WSDL_URL);
+        if (stsWsdlUrl == null) {
             throw new ServletException(
                 "Parameter '" + S_PARAM_STS_WSDL_URL + "' not configured");
         }
+        try {
+            URL url = new URL(stsWsdlUrl);
+            isPortSet = url.getPort() > 0;
+            if (!isPortSet) {
+                LOG.info("Port is 0 for '" + S_PARAM_STS_WSDL_URL + "'. Port evaluated when
processing first request.");
+            }
+        } catch (MalformedURLException e) {
+            LOG.error("Invalid Url '" + stsWsdlUrl + "': "  + e.getMessage());
+        }
         if (getInitParameter(S_PARAM_STS_WSDL_SERVICE) == null) {
             throw new ServletException(
                 "Parameter '" + S_PARAM_STS_WSDL_SERVICE + "' not configured");
@@ -139,6 +155,17 @@ public class IdpServlet extends HttpServ
     public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
 
+        if (!isPortSet) {
+            try {
+                URL url = new URL(stsWsdlUrl);
+                URL updatedUrl = new URL(url.getProtocol(), url.getHost(), request.getLocalPort(),
url.getFile());
+                setSTSWsdlUrl(updatedUrl.toString());
+                LOG.info("STS WSDL URL updated to " + updatedUrl.toString());
+            } catch (MalformedURLException e) {
+                LOG.error("Invalid Url '" + stsWsdlUrl + "': "  + e.getMessage());
+            }
+        }
+
         String action = request.getParameter(PARAM_ACTION);
         String wtrealm = request.getParameter(PARAM_WTREALM);
         String wctx = request.getParameter(PARAM_WCONTEXT);
@@ -307,7 +334,7 @@ public class IdpServlet extends HttpServ
         }
         sts.setKeyType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer");
 
-        sts.setWsdlLocation(getInitParameter(S_PARAM_STS_WSDL_URL) + getInitParameter(S_PARAM_STS_UT_URI)
+ "?wsdl");
+        sts.setWsdlLocation(this.stsWsdlUrl + getInitParameter(S_PARAM_STS_UT_URI) + "?wsdl");
         sts.setServiceQName(new QName(
                                       "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
                                       getInitParameter(S_PARAM_STS_WSDL_SERVICE)));
@@ -357,7 +384,7 @@ public class IdpServlet extends HttpServ
             }
             sts.setKeyType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer");
 
-            sts.setWsdlLocation(getInitParameter(S_PARAM_STS_WSDL_URL) + getInitParameter(S_PARAM_STS_RP_URI)
+ "?wsdl");
+            sts.setWsdlLocation(this.stsWsdlUrl + getInitParameter(S_PARAM_STS_RP_URI) +
"?wsdl");
             sts.setServiceQName(new QName(
                                           "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
                                           getInitParameter(S_PARAM_STS_WSDL_SERVICE)));
@@ -412,6 +439,11 @@ public class IdpServlet extends HttpServ
 
         return writer.getDocument().getDocumentElement();
     }
+    
+    private synchronized void setSTSWsdlUrl(String wsdlUrl) {
+        this.stsWsdlUrl = wsdlUrl;
+        this.isPortSet = true;
+    }
 
     public void setBus(Bus bus) {
         this.bus = bus;

Modified: cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/applicationContext.xml?rev=1432506&r1=1432505&r2=1432506&view=diff
==============================================================================
--- cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
(original)
+++ cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
Sat Jan 12 20:31:07 2013
@@ -27,7 +27,7 @@
 	</cxf:bus>
 
     
-    <http:conduit name="https://localhost:9443/.*">
+    <http:conduit name="*.http-conduit">
       <http:tlsClientParameters disableCNCheck="true">
         <sec:trustManagers>
           <sec:keyStore type="jks" password="ispass" resource="idpstore.jks"/>

Modified: cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/web.xml?rev=1432506&r1=1432505&r2=1432506&view=diff
==============================================================================
--- cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/fediz/branches/1.0.x-fixes/services/idp/src/main/webapp/WEB-INF/web.xml Sat Jan 12
20:31:07 2013
@@ -27,7 +27,7 @@
 		<servlet-class>org.apache.cxf.fediz.service.idp.IdpServlet</servlet-class>
 		<init-param>
 			<param-name>sts.wsdl.url</param-name>
-			<param-value>https://localhost:9443/fedizidpsts/</param-value>
+			<param-value>https://localhost:0/fedizidpsts/</param-value>
 		</init-param>
 		<init-param>
 			<param-name>sts.wsdl.service</param-name>



Mime
View raw message