cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Making it easier to inject IdToken/UserInfo as context proxies
Date Tue, 15 Dec 2015 12:41:38 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 332551899 -> b316007cc


Making it easier to inject IdToken/UserInfo as context proxies


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

Branch: refs/heads/master
Commit: b316007cc8c78508b006dcfc99c8398f516cc37a
Parents: 3325518
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Dec 15 12:41:23 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Dec 15 12:41:23 2015 +0000

----------------------------------------------------------------------
 .../cxf/rs/security/oidc/rp/IdTokenContext.java | 25 ++++++++++++++++++++
 .../oidc/rp/OidcClientTokenContext.java         |  7 ++----
 .../security/oidc/rp/OidcIdTokenProvider.java   | 19 +++++++++++----
 .../security/oidc/rp/OidcUserInfoProvider.java  | 22 +++++++++++++----
 .../rs/security/oidc/rp/UserInfoContext.java    | 25 ++++++++++++++++++++
 5 files changed, 83 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b316007c/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenContext.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenContext.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenContext.java
new file mode 100644
index 0000000..7e4cc2f
--- /dev/null
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenContext.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rs.security.oidc.rp;
+
+import org.apache.cxf.rs.security.oidc.common.IdToken;
+
+public interface IdTokenContext {
+    IdToken getIdToken();
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/b316007c/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcClientTokenContext.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcClientTokenContext.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcClientTokenContext.java
index 5a1e136..5187392 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcClientTokenContext.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcClientTokenContext.java
@@ -19,10 +19,7 @@
 package org.apache.cxf.rs.security.oidc.rp;
 
 import org.apache.cxf.rs.security.oauth2.client.ClientTokenContext;
-import org.apache.cxf.rs.security.oidc.common.IdToken;
-import org.apache.cxf.rs.security.oidc.common.UserInfo;
 
-public interface OidcClientTokenContext extends ClientTokenContext {
-    IdToken getIdToken();
-    UserInfo getUserInfo();
+public interface OidcClientTokenContext extends ClientTokenContext,
+    IdTokenContext, UserInfoContext {
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b316007c/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcIdTokenProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcIdTokenProvider.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcIdTokenProvider.java
index fab9ae8..b87ea2c 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcIdTokenProvider.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcIdTokenProvider.java
@@ -23,14 +23,23 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.oauth2.client.ClientTokenContext;
 import org.apache.cxf.rs.security.oidc.common.IdToken;
 
-public class OidcIdTokenProvider implements ContextProvider<IdToken> {
+public class OidcIdTokenProvider implements ContextProvider<IdTokenContext> {
     @Override
-    public IdToken createContext(Message m) {
+    public IdTokenContext createContext(Message m) {
         
         OidcClientTokenContext ctx = (OidcClientTokenContext)m.getContent(ClientTokenContext.class);
-        if (ctx != null) {
-            return ctx.getIdToken();
+        final IdToken idToken = ctx != null ? ctx.getIdToken() : m.getContent(IdToken.class);
+        if (idToken != null) {
+            return new IdTokenContext() {
+
+                @Override
+                public IdToken getIdToken() {
+                    return idToken;
+                }
+                
+            };
+        } else {
+            return null;
         }
-        return m.getContent(IdToken.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b316007c/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcUserInfoProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcUserInfoProvider.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcUserInfoProvider.java
index 52e03fa..822d13b 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcUserInfoProvider.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcUserInfoProvider.java
@@ -23,17 +23,29 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.oauth2.client.ClientTokenContext;
 import org.apache.cxf.rs.security.oidc.common.UserInfo;
 
-public class OidcUserInfoProvider implements ContextProvider<UserInfo> {
+public class OidcUserInfoProvider implements ContextProvider<UserInfoContext> {
 
     @Override
-    public UserInfo createContext(Message m) {
+    public UserInfoContext createContext(Message m) {
         OidcClientTokenContext ctx = (OidcClientTokenContext)
             m.getContent(ClientTokenContext.class);
-        UserInfo userInfo = ctx != null ? ctx.getUserInfo() : null;
+        final UserInfo userInfo = ctx != null ? ctx.getUserInfo() : m.getContent(UserInfo.class);
         if (userInfo != null) {
-            userInfo.setIdToken(ctx.getIdToken());
+            if (ctx != null) {
+                userInfo.setIdToken(ctx.getIdToken());
+            }
+            return new UserInfoContext() {
+
+                @Override
+                public UserInfo getUserInfo() {
+                    return userInfo;
+                } 
+                
+            };
+        } else {
+            return null;
         }
-        return userInfo;
+        
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b316007c/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/UserInfoContext.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/UserInfoContext.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/UserInfoContext.java
new file mode 100644
index 0000000..0a98068
--- /dev/null
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/UserInfoContext.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rs.security.oidc.rp;
+
+import org.apache.cxf.rs.security.oidc.common.UserInfo;
+
+public interface UserInfoContext {
+    UserInfo getUserInfo();
+}


Mime
View raw message