Author: owulff
Date: Sat Jan 12 20:05:09 2013
New Revision: 1432499

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

Modified:
    
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
    cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
    cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml

Modified: 
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java?rev=1432499&r1=1432498&r2=1432499&view=diff
==============================================================================
--- 
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
 (original)
+++ 
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
 Sat Jan 12 20:05:09 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;
 
@@ -89,6 +91,7 @@ public class STSClientFilter extends Abs
     protected String tokenStoreName;
     protected String appliesTo; // $wtrealm
     protected String contentType;  //token, rstr
+    protected boolean isPortSet;
 
     protected Bus bus;
 
@@ -105,6 +108,17 @@ public class STSClientFilter extends Abs
             throw new ServletException(
                                        "Parameter '" + PARAM_STS_WSDL_URL + "' 
not configured");
         }
+        
+        try {
+            URL url = new URL(stsWsdlUrl);
+            isPortSet = url.getPort() > 0;
+            if (!isPortSet) {
+                LOG.info("Port is 0 for '" + PARAM_STS_WSDL_URL + "'. Port 
evaluated when processing first request.");
+            }
+        } catch (MalformedURLException e) {
+            LOG.error("Invalid Url '" + stsWsdlUrl + "': "  + e.getMessage());
+        }
+        
 
         stsWsdlService = filterConfig.getInitParameter(PARAM_STS_WSDL_SERVICE);
         if (stsWsdlService == null) {
@@ -200,7 +214,17 @@ public class STSClientFilter extends Abs
                 sts.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
             }
             
sts.setKeyType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer";);
-
+            
+            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());
+                }
+            }
             sts.setWsdlLocation(stsWsdlUrl);
             sts.setServiceQName(new QName(
                                           
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/";,
@@ -345,6 +369,11 @@ public class STSClientFilter extends Abs
 
         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/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml?rev=1432499&r1=1432498&r2=1432499&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml 
(original)
+++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/applicationContext.xml 
Sat Jan 12 20:05:09 2013
@@ -26,8 +26,7 @@
                </cxf:features>
        </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"/>
@@ -35,7 +34,6 @@
       </http:tlsClientParameters>
    </http:conduit>
     
-   
    <import resource="RPClaims.xml" />
 
 </beans>

Modified: cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml?rev=1432499&r1=1432498&r2=1432499&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml Sat Jan 12 
20:05:09 2013
@@ -78,7 +78,7 @@
                </init-param>                   
                <init-param>
                        <param-name>sts.wsdl.url</param-name>
-                       
<param-value>https://localhost:9443/fedizidpsts/STSService?wsdl</param-value>
+                       
<param-value>https://localhost:0/fedizidpsts/STSService?wsdl</param-value>
                </init-param>
                <init-param>
                        <param-name>sts.wsdl.service</param-name>
@@ -125,7 +125,7 @@
                </init-param>                   
                <init-param>
                        <param-name>sts.wsdl.url</param-name>
-                       
<param-value>https://localhost:9443/fedizidpsts/STSServiceTransport?wsdl</param-value>
+                       
<param-value>https://localhost:0/fedizidpsts/STSServiceTransport?wsdl</param-value>
                </init-param>
                <init-param>
                        <param-name>sts.wsdl.service</param-name>


Reply via email to