Repository: cxf Updated Branches: refs/heads/master 6aa73265a -> 38a1b7704
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/38a1b770 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/38a1b770 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/38a1b770 Branch: refs/heads/master Commit: 38a1b770407c6e1955e46ca700e7babd15276c08 Parents: 6aa7326 Author: Sergey Beryozkin <[email protected]> Authored: Thu Oct 22 16:32:38 2015 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Thu Oct 22 16:32:38 2015 +0100 ---------------------------------------------------------------------- .../oidc/idp/IdTokenCodeResponseFilter.java | 53 ------------------ .../oidc/idp/IdTokenResponseFilter.java | 59 ++++++++++++++++++++ 2 files changed, 59 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/38a1b770/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 01b024e..0000000 --- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenCodeResponseFilter.java +++ /dev/null @@ -1,53 +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) { - // This may also be done directly inside a data provider code creating the server token - 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/38a1b770/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..f0b1d79 --- /dev/null +++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/IdTokenResponseFilter.java @@ -0,0 +1,59 @@ +/** + * 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; + } + +}
