cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbernha...@apache.org
Subject cxf git commit: Prefer Subject Name over E-Mail address when creating the users principal
Date Mon, 14 Dec 2015 16:12:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 474369eb0 -> d05a928ae


Prefer Subject Name over E-Mail address when creating the users principal


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

Branch: refs/heads/master
Commit: d05a928aee3e4c6976e2ad5d1b9b044560519168
Parents: 474369e
Author: Jan Bernhardt <jbernhardt@talend.com>
Authored: Mon Dec 14 16:16:45 2015 +0100
Committer: Jan Bernhardt <jbernhardt@talend.com>
Committed: Mon Dec 14 17:12:26 2015 +0100

----------------------------------------------------------------------
 .../security/oidc/rp/OidcSecurityContext.java   | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d05a928a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcSecurityContext.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcSecurityContext.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcSecurityContext.java
index d31c189..2c50bb8 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcSecurityContext.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcSecurityContext.java
@@ -27,33 +27,43 @@ import org.apache.cxf.rs.security.oidc.common.IdToken;
 
 public class OidcSecurityContext extends SimpleSecurityContext implements SecurityContext
{
     private OidcClientTokenContext oidcContext;
+
     public OidcSecurityContext(IdToken token) {
         this(new OidcClientTokenContextImpl(token));
     }
+
     public OidcSecurityContext(OidcClientTokenContext oidcContext) {
         super(getPrincipalName(oidcContext));
         this.oidcContext = oidcContext;
     }
+
     public OidcClientTokenContext getOidcContext() {
         return oidcContext;
     }
-    private static String getPrincipalName(OidcClientTokenContext oidcContext) {
+
+    protected static String getPrincipalName(OidcClientTokenContext oidcContext) {
+        String name = null;
         if (oidcContext.getUserInfo() != null) {
-            return oidcContext.getUserInfo().getEmail();
-        } else {
-            IdToken token = oidcContext.getIdToken();
-            String name = token.getEmail();
+            name = oidcContext.getUserInfo().getSubject();
             if (name == null) {
-                name = token.getSubject();
+                name = oidcContext.getUserInfo().getEmail();
             }
-            return name;
         }
+        if (name == null && oidcContext.getIdToken() != null) {
+            name = oidcContext.getIdToken().getSubject();
+            if (name == null) {
+                name = oidcContext.getIdToken().getEmail();
+            }
+        }
+        return name;
     }
+
     @Override
     public boolean isSecure() {
         String value = HttpUtils.getEndpointAddress(JAXRSUtils.getCurrentMessage());
         return value.startsWith("https://");
     }
+
     @Override
     public String getAuthenticationScheme() {
         return "OIDC";


Mime
View raw message