[java-shib-profile] branch main updated: IDP-2076 - Implement new SAML profile settings

Scott Cantor cantor.2 at osu.edu
Tue Feb 28 16:36:33 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-profile.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=d2948bacd5dcb243119491735f4a5185a17e6a60

The following commit(s) were added to refs/heads/main by this push:
     new d2948ba  IDP-2076 - Implement new SAML profile settings
d2948ba is described below

commit d2948bacd5dcb243119491735f4a5185a17e6a60
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Feb 28 11:36:17 2023 -0500

    IDP-2076 - Implement new SAML profile settings
    
    https://shibboleth.atlassian.net/browse/IDP-2076
    
    Move decorator hook into more generic function usable across profiles.
---
 .../profile/config/SAMLProfileConfiguration.java   | 20 ++++++++
 .../messaging/MessageHandlerLookupFunction.java    | 54 ++++++++++++++++++++++
 .../config/navigate/messaging/package-info.java    | 21 +++++++++
 .../profile/config/SAML2ProfileConfiguration.java  | 13 ------
 4 files changed, 95 insertions(+), 13 deletions(-)

diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLProfileConfiguration.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLProfileConfiguration.java
index ca7ad64..c71b7ef 100644
--- a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLProfileConfiguration.java
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLProfileConfiguration.java
@@ -17,8 +17,12 @@
 
 package net.shibboleth.saml.profile.config;
 
+import java.util.function.Function;
+
 import javax.annotation.Nullable;
 
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.handler.MessageHandler;
 import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.profile.config.ProfileConfiguration;
@@ -44,4 +48,20 @@ public interface SAMLProfileConfiguration extends ProfileConfiguration {
      */
     boolean isSignResponses(@Nullable final ProfileRequestContext profileRequestContext);
     
+    /**
+     * Get a custom handler for a SAML message produced or consumed by this profile.
+     * 
+     * <p>This function MUST be stateless and reusable if statically configured, or may be stateful
+     * if obtained by means of a more dynamic strategy.</p>
+     * 
+     * <p>The use of the {@link Function} API rather than the OpenSAML {@link MessageHandler} API is a
+     * concession to making scripted or otherwise non-Java implementations easily usable, and avoiding
+     * the explicit need to raise exceptions to signal errors, in cases where doing do is awkward.</p>
+     * 
+     * @param messageContext message context
+     * 
+     * @return message handler
+     */
+    @Nullable Function<MessageContext,Exception> getMessageHandler(@Nullable final MessageContext messageContext);
+
 }
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/MessageHandlerLookupFunction.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/MessageHandlerLookupFunction.java
new file mode 100644
index 0000000..e356958
--- /dev/null
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/MessageHandlerLookupFunction.java
@@ -0,0 +1,54 @@
+/*
+ * 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.saml.profile.config.navigate.messaging;
+
+
+import java.util.function.Function;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.profile.context.navigate.messaging.AbstractRelyingPartyLookupFunction;
+import net.shibboleth.saml.profile.config.SAMLProfileConfiguration;
+
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * A function that returns {@link SAMLProfileConfiguration#getMessageHandler(MessageContext)}
+ * if such a profile is available from a {@link RelyingPartyContext} obtained via a lookup function,
+ * by default a child of the {@link ProfileRequestContext}.
+ * 
+ * <p>If a specific setting is unavailable, a null value is returned.</p>
+ */
+public class MessageHandlerLookupFunction
+        extends AbstractRelyingPartyLookupFunction<Function<MessageContext,Exception>> {
+
+    /** {@inheritDoc} */
+    @Nullable public Function<MessageContext,Exception> apply(@Nullable final MessageContext input) {
+        final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
+        if (rpc != null) {
+            if (rpc.getProfileConfig() instanceof SAMLProfileConfiguration downcast) {
+                return downcast.getMessageHandler(input);
+            }
+        }
+        
+        return null;
+    }
+
+}
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/package-info.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/package-info.java
new file mode 100644
index 0000000..d332c74
--- /dev/null
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/navigate/messaging/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Functions based on message contexts and SAML profile configuration.
+ */
+package net.shibboleth.saml.profile.config.navigate.messaging;
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/saml2/profile/config/SAML2ProfileConfiguration.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/saml2/profile/config/SAML2ProfileConfiguration.java
index 2a08326..d724c9a 100644
--- a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/saml2/profile/config/SAML2ProfileConfiguration.java
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/saml2/profile/config/SAML2ProfileConfiguration.java
@@ -17,13 +17,10 @@
 
 package net.shibboleth.saml.saml2.profile.config;
 
-import java.util.function.BiConsumer;
-
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.saml2.core.RequestAbstractType;
 
 import net.shibboleth.saml.profile.config.SAMLProfileConfiguration;
 
@@ -67,15 +64,5 @@ public interface SAML2ProfileConfiguration extends SAMLProfileConfiguration {
      * @return predicate used to determine if name identifiers should be encrypted
      */
     boolean isEncryptNameIDs(@Nullable final ProfileRequestContext profileRequestContext);
-        
-    /**
-     * Get a decorator for the SAML request.
-     * 
-     * @param profileRequestContext current profile request context
-     * 
-     * @return request decorator
-     */
-    @Nullable BiConsumer<ProfileRequestContext,? extends RequestAbstractType> getRequestDecorator(
-            @Nullable final ProfileRequestContext profileRequestContext);
 
 }
\ 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