[java-idp-oidc] 11/44: JOIDC-5 Initial version, required by the metadata-lookup flow
Henri Mikkonen
henri.mikkonen at iki.fi
Thu Oct 22 13:08:23 UTC 2020
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=3a49c65104cba059798227dab93d61663582df00
commit 3a49c65104cba059798227dab93d61663582df00
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Apr 24 14:15:49 2020 +0300
JOIDC-5 Initial version, required by the metadata-lookup flow
https://issues.shibboleth.net/jira/browse/JOIDC-5
---
.../impl/SetEntityIdToSAMLPeerEntityContext.java | 89 ++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/idp-oidc-extension-impl/src/main/java/org/geant/idpextension/oidc/profile/impl/SetEntityIdToSAMLPeerEntityContext.java b/idp-oidc-extension-impl/src/main/java/org/geant/idpextension/oidc/profile/impl/SetEntityIdToSAMLPeerEntityContext.java
new file mode 100644
index 00000000..8d78c05a
--- /dev/null
+++ b/idp-oidc-extension-impl/src/main/java/org/geant/idpextension/oidc/profile/impl/SetEntityIdToSAMLPeerEntityContext.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017 - 2020, GÉANT
+ *
+ * Licensed 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.geant.idpextension.oidc.profile.impl;
+
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+
+import org.geant.idpextension.oidc.profile.context.navigate.DefaultClientIDLookupFunction;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.saml.common.messaging.context.AbstractSAMLEntityContext;
+import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.nimbusds.oauth2.sdk.id.ClientID;
+
+import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+public class SetEntityIdToSAMLPeerEntityContext extends AbstractProfileAction {
+
+ /** Class logger. */
+ @Nonnull
+ private Logger log = LoggerFactory.getLogger(SetEntityIdToSAMLPeerEntityContext.class);
+
+ /** Strategy used to obtain the client id value for authorize/token request. */
+ @Nonnull private Function<MessageContext, ClientID> clientIDLookupStrategy;
+
+ /** The context class representing the SAML entity for whom data is to be attached.
+ * Defaults to: {@link SAMLPeerEntityContext}. */
+ @Nonnull private Class<? extends AbstractSAMLEntityContext> entityContextClass = SAMLPeerEntityContext.class;
+
+ public SetEntityIdToSAMLPeerEntityContext() {
+ clientIDLookupStrategy = new DefaultClientIDLookupFunction();
+ }
+
+ /**
+ * Set the strategy used to locate the client id of the request.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setClientIDLookupStrategy(@Nonnull final Function<MessageContext, ClientID> strategy) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ clientIDLookupStrategy =
+ Constraint.isNotNull(strategy, "ClientIDLookupStrategy lookup strategy cannot be null");
+ }
+
+ /**
+ * Set the class type holding the SAML entity data.
+ *
+ * <p>Defaults to: {@link SAMLPeerEntityContext}.</p>
+ *
+ * @param clazz the entity context class type
+ */
+ public void setEntityContextClass(@Nonnull final Class<? extends AbstractSAMLEntityContext> clazz) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ entityContextClass = Constraint.isNotNull(clazz, "SAML entity context class may not be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ final MessageContext messageContext = profileRequestContext.getInboundMessageContext();
+ final AbstractSAMLEntityContext entityCtx = messageContext.getSubcontext(entityContextClass);
+ final ClientID clientID = clientIDLookupStrategy.apply(messageContext);
+ if (clientID != null) {
+ log.debug("{} Set clientID '{}' to the peer entity context", getLogPrefix(), clientID.getValue());
+ entityCtx.setEntityId(clientID.getValue());
+ }
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list