[java-oidc-common] branch main updated: JCOMOIDC-38 - Move various support classes from the OP plugin
Phil Smart
philip.smart at jisc.ac.uk
Wed Feb 2 10:28:41 UTC 2022
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=dec31c3c9651780fd99f7f197db6df34e73f10dc
The following commit(s) were added to refs/heads/main by this push:
new dec31c3 JCOMOIDC-38 - Move various support classes from the OP plugin
dec31c3 is described below
commit dec31c3c9651780fd99f7f197db6df34e73f10dc
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Feb 2 10:28:36 2022 +0000
JCOMOIDC-38 - Move various support classes from the OP plugin
Move classes from the OP to oidc-common.
https://shibboleth.atlassian.net/browse/JCOMOIDC-38
---
.../oidc/metadata/context/OIDCMetadataContext.java | 59 ++++++++++++++++
oidc-common-profile-impl/pom.xml | 4 ++
...entIDFromOIDCMetadataContextLookupFunction.java | 78 ++++++++++++++++++++++
3 files changed, 141 insertions(+)
diff --git a/oidc-common-metadata-api/src/main/java/net/shibboleth/oidc/metadata/context/OIDCMetadataContext.java b/oidc-common-metadata-api/src/main/java/net/shibboleth/oidc/metadata/context/OIDCMetadataContext.java
new file mode 100644
index 0000000..e9c615c
--- /dev/null
+++ b/oidc-common-metadata-api/src/main/java/net/shibboleth/oidc/metadata/context/OIDCMetadataContext.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.oidc.metadata.context;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.messaging.context.BaseContext;
+
+import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
+
+/**
+ * Subcontext carrying information on metadata of the relying party. This
+ * context appears as a subcontext of the
+ * {@link org.opensaml.messaging.context.MessageContext} that carries the actual
+ * OIDC request message, in such cases the metadata carried herein applies to
+ * the issuer of that message.
+ *
+ * This context is just a placeholder for the final solution. At first phase we
+ * use only redirect uris.
+ */
+public class OIDCMetadataContext extends BaseContext {
+
+ /** The client information. */
+ @Nullable private OIDCClientInformation clientInformation;
+
+ /**
+ * Set the client information.
+ *
+ * @return The client information.
+ */
+ @Nullable
+ public OIDCClientInformation getClientInformation() {
+ return clientInformation;
+ }
+
+ /**
+ * Set the client information.
+ *
+ * @param information The client information.
+ */
+ public void setClientInformation(@Nullable final OIDCClientInformation information) {
+ clientInformation = information;
+ }
+}
\ No newline at end of file
diff --git a/oidc-common-profile-impl/pom.xml b/oidc-common-profile-impl/pom.xml
index 0c34d9e..6cd95fb 100644
--- a/oidc-common-profile-impl/pom.xml
+++ b/oidc-common-profile-impl/pom.xml
@@ -22,6 +22,10 @@
<groupId>net.shibboleth.oidc</groupId>
<artifactId>oidc-common-profile-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.shibboleth.oidc</groupId>
+ <artifactId>oidc-common-metadata-api</artifactId>
+ </dependency>
<dependency>
<groupId>net.shibboleth.idp</groupId>
<artifactId>idp-core</artifactId>
diff --git a/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/logic/ClientIDFromOIDCMetadataContextLookupFunction.java b/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/logic/ClientIDFromOIDCMetadataContextLookupFunction.java
new file mode 100644
index 0000000..11c52f7
--- /dev/null
+++ b/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/logic/ClientIDFromOIDCMetadataContextLookupFunction.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.oidc.profile.logic;
+
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.profile.context.navigate.InboundMessageContextLookup;
+
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
+
+import net.shibboleth.oidc.metadata.context.OIDCMetadataContext;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+/**
+ * A function that returns client_id via client information stored in {@link OIDCMetadataContext}.
+ */
+public class ClientIDFromOIDCMetadataContextLookupFunction
+ implements BiFunction<ProfileRequestContext, JWTClaimsSet, String> {
+
+ /** Strategy that will return {@link OIDCMetadataContext}. */
+ @Nonnull private Function<ProfileRequestContext, OIDCMetadataContext> oidcMetadataContextLookupStrategy;
+
+ /**
+ * Constructor.
+ */
+ public ClientIDFromOIDCMetadataContextLookupFunction() {
+ oidcMetadataContextLookupStrategy = new ChildContextLookup<>(OIDCMetadataContext.class).compose(
+ new InboundMessageContextLookup());
+ }
+
+ /**
+ * Set the strategy used to return the {@link OIDCMetadataContext}.
+ *
+ * @param strategy The lookup strategy.
+ */
+ public void setOIDCMetadataContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext, OIDCMetadataContext> strategy) {
+ oidcMetadataContextLookupStrategy =
+ Constraint.isNotNull(strategy, "OIDCMetadataContext lookup strategy cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable
+ public String apply(@Nonnull final ProfileRequestContext prc, @Nullable final JWTClaimsSet claimsSet) {
+ final OIDCMetadataContext oidcMetadataContext = oidcMetadataContextLookupStrategy.apply(prc);
+ if (oidcMetadataContext == null) {
+ return null;
+ }
+ final OIDCClientInformation clientInformation = oidcMetadataContext.getClientInformation();
+ if (clientInformation == null || clientInformation.getID() == null) {
+ return null;
+ }
+ return clientInformation.getID().toString();
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list