cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: Minor update to IdToken filter
Date Thu, 22 Oct 2015 15:46:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes e5e5ebd3f -> 61d0690a8


Minor update to IdToken filter


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

Branch: refs/heads/3.0.x-fixes
Commit: 612f74a81b0bc5cc928ea56afbbb70840ca09934
Parents: e08ab43
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Oct 22 16:32:38 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Oct 22 16:46:00 2015 +0100

----------------------------------------------------------------------
 .../oidc/idp/IdTokenCodeResponseFilter.java     | 52 ------------------
 .../oidc/idp/IdTokenResponseFilter.java         | 58 ++++++++++++++++++++
 2 files changed, 58 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/612f74a8/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenCodeResponseFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenCodeResponseFilter.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenCodeResponseFilter.java
deleted file mode 100644
index 62902af..0000000
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenCodeResponseFilter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.idp;
-
-import org.apache.cxf.rs.security.jose.jwt.JwtToken;
-import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken;
-import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
-import org.apache.cxf.rs.security.oauth2.provider.AbstractOAuthServerJoseJwtProducer;
-import org.apache.cxf.rs.security.oauth2.provider.AccessTokenResponseFilter;
-import org.apache.cxf.rs.security.oidc.common.IdToken;
-import org.apache.cxf.rs.security.oidc.utils.OidcUtils;
-
-public class IdTokenCodeResponseFilter extends AbstractOAuthServerJoseJwtProducer implements
AccessTokenResponseFilter {
-    private UserInfoProvider userInfoProvider;
-    private String issuer;
-    @Override
-    public void process(ClientAccessToken ct, ServerAccessToken st) {
-        IdToken token = 
-            userInfoProvider.getIdToken(st.getClient().getClientId(), st.getSubject(), st.getScopes());
-        token.setIssuer(issuer);
-        token.setAudience(st.getClient().getClientId());
-        
-        String responseEntity = super.processJwt(new JwtToken(token), 
-                                                 st.getClient());
-        ct.getParameters().put(OidcUtils.ID_TOKEN, responseEntity);
-        
-    }
-    
-    public void setIssuer(String issuer) {
-        this.issuer = issuer;
-    }
-    public void setUserInfoProvider(UserInfoProvider userInfoProvider) {
-        this.userInfoProvider = userInfoProvider;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/612f74a8/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenResponseFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenResponseFilter.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenResponseFilter.java
new file mode 100644
index 0000000..08853fb
--- /dev/null
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenResponseFilter.java
@@ -0,0 +1,58 @@
+/**
+ * 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.idp;
+
+import org.apache.cxf.rs.security.jose.jwt.JwtToken;
+import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken;
+import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
+import org.apache.cxf.rs.security.oauth2.provider.AbstractOAuthServerJoseJwtProducer;
+import org.apache.cxf.rs.security.oauth2.provider.AccessTokenResponseFilter;
+import org.apache.cxf.rs.security.oidc.common.IdToken;
+import org.apache.cxf.rs.security.oidc.utils.OidcUtils;
+
+public class IdTokenResponseFilter extends AbstractOAuthServerJoseJwtProducer implements
AccessTokenResponseFilter {
+    private UserInfoProvider userInfoProvider;
+    private String issuer;
+    @Override
+    public void process(ClientAccessToken ct, ServerAccessToken st) {
+        // This may also be done directly inside a data provider code creating the server
token
+        if (userInfoProvider != null) {
+            IdToken token = 
+                userInfoProvider.getIdToken(st.getClient().getClientId(), st.getSubject(),
st.getScopes());
+            token.setIssuer(issuer);
+            token.setAudience(st.getClient().getClientId());
+            
+            String responseEntity = super.processJwt(new JwtToken(token), 
+                                                     st.getClient());
+            ct.getParameters().put(OidcUtils.ID_TOKEN, responseEntity);
+        } else if (st.getSubject().getProperties().containsKey("id_token")) {
+            ct.getParameters().put(OidcUtils.ID_TOKEN, 
+                                   st.getSubject().getProperties().get("id_token"));
+        }
+        
+    }
+    
+    public void setIssuer(String issuer) {
+        this.issuer = issuer;
+    }
+    public void setUserInfoProvider(UserInfoProvider userInfoProvider) {
+        this.userInfoProvider = userInfoProvider;
+    }
+    
+}


Mime
View raw message