cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf-fediz git commit: Adding an option to strip a path comp off from the dynamically calculated issuer uri
Date Fri, 08 Sep 2017 10:59:12 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/1.4.x-fixes e22353152 -> 81e0b796a


Adding an option to strip a path comp off from the dynamically calculated issuer uri


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

Branch: refs/heads/1.4.x-fixes
Commit: 81e0b796a7d4a786197ec5c38d46ae2bc4ad5ffb
Parents: e223531
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Sep 8 11:58:40 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Sep 8 11:58:40 2017 +0100

----------------------------------------------------------------------
 .../fediz/service/oidc/FedizSubjectCreator.java   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/81e0b796/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/FedizSubjectCreator.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/FedizSubjectCreator.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/FedizSubjectCreator.java
index eb495f9..e8ad831 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/FedizSubjectCreator.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/FedizSubjectCreator.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.fediz.service.oidc;
 
+import java.net.URI;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -51,6 +52,7 @@ import org.opensaml.saml.saml2.core.Issuer;
 
 public class FedizSubjectCreator implements SubjectCreator {
     private static final String ROLES_SCOPE = "roles";
+    private boolean stripPathFromIssuerUri;
     private String issuer;
     private long defaultTimeToLive = 3600L;
     private Map<String, String> supportedClaims = Collections.emptyMap();
@@ -132,7 +134,17 @@ public class FedizSubjectCreator implements SubjectCreator {
             String realIssuer = null;
             if (issuer.startsWith("/")) {
                 UriBuilder ub = mc.getUriInfo().getBaseUriBuilder();
-                realIssuer = ub.path(issuer).build().toString();
+                URI uri = ub.path(issuer).build();
+                if (this.stripPathFromIssuerUri) {
+                    StringBuilder sb = new StringBuilder();
+                    sb.append(uri.getScheme()).append("://").append(uri.getHost());
+                    if (uri.getPort() != -1) {
+                        sb.append(':').append(uri.getPort());
+                    }
+                    realIssuer = sb.toString();
+                } else {
+                    realIssuer = uri.toString();
+                }
             } else {
                 realIssuer = issuer;
             }
@@ -256,4 +268,8 @@ public class FedizSubjectCreator implements SubjectCreator {
         this.supportedClaims = supportedClaims;
     }
 
+    public void setStripPathFromIssuerUri(boolean stripPathFromIssuerUri) {
+        this.stripPathFromIssuerUri = stripPathFromIssuerUri;
+    }
+
 }


Mime
View raw message