cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Allow setting a relative path for the metadata services
Date Thu, 16 Apr 2015 15:29:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 3ed213519 -> 4146fe4d8


Allow setting a relative path for the metadata services


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4146fe4d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4146fe4d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4146fe4d

Branch: refs/heads/3.0.x-fixes
Commit: 4146fe4d811506f7d6d09832ccdbefc765b28902
Parents: 3ed2135
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Apr 16 16:27:21 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Apr 16 16:28:22 2015 +0100

----------------------------------------------------------------------
 .../rs/security/saml/sso/MetadataService.java   | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4146fe4d/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/MetadataService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/MetadataService.java
b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/MetadataService.java
index fc7a424..266518b 100644
--- a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/MetadataService.java
+++ b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/MetadataService.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.rs.security.saml.sso;
 
+import java.net.URI;
 import java.security.PrivateKey;
 import java.security.cert.X509Certificate;
 import java.util.ResourceBundle;
@@ -30,10 +31,11 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 
 import org.w3c.dom.Document;
-
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.utils.ExceptionUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Message;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoType;
 import org.apache.wss4j.common.ext.WSPasswordCallback;
@@ -45,6 +47,7 @@ public class MetadataService extends AbstractSSOSpHandler {
     
     private String serviceAddress;
     private String logoutServiceAddress;
+    private boolean addEndpointAddressToContext;
     
     @GET
     @Produces("text/xml")
@@ -85,8 +88,18 @@ public class MetadataService extends AbstractSSOSpHandler {
             // Get the private key
             PrivateKey privateKey = crypto.getPrivateKey(signatureUser, password);
             
-            return metadataWriter.getMetaData(serviceAddress, logoutServiceAddress, privateKey,
issuerCerts[0], 
+            if (addEndpointAddressToContext) {
+                Message message = JAXRSUtils.getCurrentMessage();
+                String httpBasePath = (String)message.get("http.base.path");
+                String rawPath = URI.create(httpBasePath).getRawPath();
+                return metadataWriter.getMetaData(rawPath + serviceAddress, 
+                                                  rawPath + logoutServiceAddress, 
+                                                  privateKey, issuerCerts[0], 
+                                                  true);
+            } else {
+                return metadataWriter.getMetaData(serviceAddress, logoutServiceAddress, privateKey,
issuerCerts[0], 
                                               true);
+            }
         } catch (Exception ex) {
             LOG.log(Level.FINE, ex.getMessage(), ex);
             throw ExceptionUtils.toInternalServerErrorException(ex, null);
@@ -116,5 +129,7 @@ public class MetadataService extends AbstractSSOSpHandler {
         this.logoutServiceAddress = logoutServiceAddress;
     }
 
-
+    public void setAddEndpointAddressToContext(boolean add) {
+        addEndpointAddressToContext = add;
+    }
 }


Mime
View raw message