[java-identity-provider] branch main updated: Refactor resolveAttributes profile config into new interface.

Scott Cantor cantor.2 at osu.edu
Thu Mar 10 15:15:43 UTC 2022


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

scantor pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=9ac4127704dae6d44ac4d5a92fa4a09d30d7f263

The following commit(s) were added to refs/heads/main by this push:
     new 9ac412770 Refactor resolveAttributes profile config into new interface.
9ac412770 is described below

commit 9ac4127704dae6d44ac4d5a92fa4a09d30d7f263
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Mar 10 10:15:39 2022 -0500

    Refactor resolveAttributes profile config into new interface.
---
 .../cas/config/AbstractProtocolConfiguration.java  | 11 ++----
 .../idp/flows/saml/saml1/sso-abstract-beans.xml    |  3 +-
 .../idp/flows/saml/saml2/sso-abstract-beans.xml    |  5 ++-
 .../AttributeResolvingProfileConfiguration.java    | 42 ++++++++++++++++++++++
 .../config/logic/ResolveAttributesPredicate.java   | 25 +++++--------
 .../ResolveAttributesProfileConfigPredicate.java   | 27 ++++++--------
 .../config/BrowserSSOProfileConfiguration.java     | 13 ++-----
 .../config/BrowserSSOProfileConfiguration.java     | 13 ++-----
 8 files changed, 73 insertions(+), 66 deletions(-)

diff --git a/idp-cas-api/src/main/java/net/shibboleth/idp/cas/config/AbstractProtocolConfiguration.java b/idp-cas-api/src/main/java/net/shibboleth/idp/cas/config/AbstractProtocolConfiguration.java
index 15b431420..a5c529411 100644
--- a/idp-cas-api/src/main/java/net/shibboleth/idp/cas/config/AbstractProtocolConfiguration.java
+++ b/idp-cas-api/src/main/java/net/shibboleth/idp/cas/config/AbstractProtocolConfiguration.java
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
 
 import net.shibboleth.idp.cas.ticket.TicketIdentifierGenerationStrategy;
 import net.shibboleth.idp.profile.config.AbstractConditionalProfileConfiguration;
+import net.shibboleth.idp.profile.config.AttributeResolvingProfileConfiguration;
 import net.shibboleth.idp.profile.config.SecurityConfiguration;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.InitializableComponent;
@@ -42,7 +43,7 @@ import com.google.common.base.Predicates;
  * @author Marvin S. Addison
  */
 public abstract class AbstractProtocolConfiguration extends AbstractConditionalProfileConfiguration implements
-        InitializableComponent {
+        AttributeResolvingProfileConfiguration, InitializableComponent {
 
     /** CAS base protocol URI. */
     @Nonnull @NotEmpty public static final String PROTOCOL_URI = "https://www.apereo.org/cas/protocol";
@@ -121,13 +122,7 @@ public abstract class AbstractProtocolConfiguration extends AbstractConditionalP
         ticketValidityPeriodLookupStrategy = Constraint.isNotNull(strategy, "Lookup strategy cannot be null");
     }
 
-    /**
-     * Get whether attributes should be resolved during the profile (defaults to true).
-     * 
-     * @param profileRequestContext current profile request context
-     * 
-     * @return true iff attributes should be resolved
-     */
+    /** {@inheritDoc} */
     public boolean isResolveAttributes(@Nullable final ProfileRequestContext profileRequestContext) {
         return resolveAttributesPredicate.test(profileRequestContext);
     }
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml1/sso-abstract-beans.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml1/sso-abstract-beans.xml
index b191f2de3..7c35ebacf 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml1/sso-abstract-beans.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml1/sso-abstract-beans.xml
@@ -31,8 +31,7 @@
         class="org.opensaml.profile.action.impl.StaticMessageChannelSecurity" scope="prototype"
         p:confidentialityActive="false" p:integrityActive="false" />
 
-    <bean id="ResolveAttributesPredicate"
-        class="net.shibboleth.idp.saml.profile.config.logic.ResolveAttributesProfileConfigPredicate" />
+    <bean id="ResolveAttributesPredicate" class="net.shibboleth.idp.profile.config.logic.ResolveAttributesPredicate" />
 
     <bean id="AddNameIdentifierToSubjects"
             class="org.opensaml.saml.saml1.profile.impl.AddNameIdentifierToSubjects" scope="prototype">
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/sso-abstract-beans.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/sso-abstract-beans.xml
index 14a8a307e..eca780ad6 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/sso-abstract-beans.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/sso-abstract-beans.xml
@@ -59,9 +59,8 @@
         </constructor-arg>
     </bean>
         
-    <bean id="ResolveAttributesPredicate"
-        class="net.shibboleth.idp.saml.profile.config.logic.ResolveAttributesProfileConfigPredicate" />
-
+    <bean id="ResolveAttributesPredicate" class="net.shibboleth.idp.profile.config.logic.ResolveAttributesPredicate" />
+    
     <bean id="AddNameIDToSubjects"
             class="org.opensaml.saml.saml2.profile.impl.AddNameIDToSubjects" scope="prototype">
         <property name="formatLookupStrategy">
diff --git a/idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/AttributeResolvingProfileConfiguration.java b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/AttributeResolvingProfileConfiguration.java
new file mode 100644
index 000000000..bb24dccf1
--- /dev/null
+++ b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/AttributeResolvingProfileConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * 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.idp.profile.config;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/**
+ * {@link ProfileConfiguration} with optional resolution of attributes.
+ *
+ * @since 4.2.0
+ */
+public interface AttributeResolvingProfileConfiguration extends ProfileConfiguration {
+
+    /**
+     * Get whether to resolve attributes.
+     * 
+     * @param profileRequestContext current profile request context
+     * 
+     * @return true iff resolution should be done
+     */
+    @Nullable @NotEmpty boolean isResolveAttributes(@Nullable final ProfileRequestContext profileRequestContext);
+    
+}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/logic/ResolveAttributesPredicate.java
similarity index 50%
copy from idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java
copy to idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/logic/ResolveAttributesPredicate.java
index 36ba503e8..edfa3e6d7 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java
+++ b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/config/logic/ResolveAttributesPredicate.java
@@ -15,36 +15,29 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.saml.profile.config.logic;
+package net.shibboleth.idp.profile.config.logic;
 
 import javax.annotation.Nullable;
 
+import net.shibboleth.idp.profile.config.AttributeResolvingProfileConfiguration;
 import net.shibboleth.idp.profile.context.RelyingPartyContext;
 import net.shibboleth.idp.profile.logic.AbstractRelyingPartyPredicate;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 
 /**
- * A predicate that evaluates a {@link ProfileRequestContext} and determines whether attribute resolution
- * and filtering should take place.
+ * Predicate to determine whether a profile request should resolve attributes.
  * 
- * <p>For SAML 1 and SAML 2 SSO profiles, the "resolveAttributes" flag is the setting governing
- * this decision. For other profiles, false is returned.</p> 
+ * @since 4.2.0
  */
-public class ResolveAttributesProfileConfigPredicate extends AbstractRelyingPartyPredicate {
+public class ResolveAttributesPredicate extends AbstractRelyingPartyPredicate {
 
     /** {@inheritDoc} */
     public boolean test(@Nullable final ProfileRequestContext input) {
-        final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
-        if (rpc != null) {
-            if (rpc.getProfileConfig()
-                    instanceof net.shibboleth.idp.saml.saml1.profile.config.BrowserSSOProfileConfiguration) {
-                return ((net.shibboleth.idp.saml.saml1.profile.config.BrowserSSOProfileConfiguration)
-                        rpc.getProfileConfig()).isResolveAttributes(input);
-            } else if (rpc.getProfileConfig()
-                    instanceof net.shibboleth.idp.saml.saml2.profile.config.BrowserSSOProfileConfiguration) {
-                return ((net.shibboleth.idp.saml.saml2.profile.config.BrowserSSOProfileConfiguration)
-                        rpc.getProfileConfig()).isResolveAttributes(input);
+        if (input != null) {
+            final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
+            if (rpc != null && rpc.getProfileConfig() instanceof AttributeResolvingProfileConfiguration) {
+                return ((AttributeResolvingProfileConfiguration) rpc.getProfileConfig()).isResolveAttributes(input);
             }
         }
         
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java
index 36ba503e8..b651b91ca 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/logic/ResolveAttributesProfileConfigPredicate.java
@@ -19,8 +19,9 @@ package net.shibboleth.idp.saml.profile.config.logic;
 
 import javax.annotation.Nullable;
 
-import net.shibboleth.idp.profile.context.RelyingPartyContext;
-import net.shibboleth.idp.profile.logic.AbstractRelyingPartyPredicate;
+import net.shibboleth.idp.profile.config.logic.ResolveAttributesPredicate;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
 
 import org.opensaml.profile.context.ProfileRequestContext;
 
@@ -29,26 +30,18 @@ import org.opensaml.profile.context.ProfileRequestContext;
  * and filtering should take place.
  * 
  * <p>For SAML 1 and SAML 2 SSO profiles, the "resolveAttributes" flag is the setting governing
- * this decision. For other profiles, false is returned.</p> 
+ * this decision. For other profiles, false is returned.</p>
+ * 
+ * @deprecated
  */
-public class ResolveAttributesProfileConfigPredicate extends AbstractRelyingPartyPredicate {
+ at Deprecated(since="4.2.0", forRemoval=true)
+public class ResolveAttributesProfileConfigPredicate extends ResolveAttributesPredicate {
 
     /** {@inheritDoc} */
     public boolean test(@Nullable final ProfileRequestContext input) {
-        final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
-        if (rpc != null) {
-            if (rpc.getProfileConfig()
-                    instanceof net.shibboleth.idp.saml.saml1.profile.config.BrowserSSOProfileConfiguration) {
-                return ((net.shibboleth.idp.saml.saml1.profile.config.BrowserSSOProfileConfiguration)
-                        rpc.getProfileConfig()).isResolveAttributes(input);
-            } else if (rpc.getProfileConfig()
-                    instanceof net.shibboleth.idp.saml.saml2.profile.config.BrowserSSOProfileConfiguration) {
-                return ((net.shibboleth.idp.saml.saml2.profile.config.BrowserSSOProfileConfiguration)
-                        rpc.getProfileConfig()).isResolveAttributes(input);
-            }
-        }
+        DeprecationSupport.warnOnce(ObjectType.CLASS, getClass().getName(), null, ResolveAttributesPredicate.class.getName());
         
-        return false;
+        return super.test(input);
     }
 
 }
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml1/profile/config/BrowserSSOProfileConfiguration.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml1/profile/config/BrowserSSOProfileConfiguration.java
index cea614f48..02b3d9a8a 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml1/profile/config/BrowserSSOProfileConfiguration.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml1/profile/config/BrowserSSOProfileConfiguration.java
@@ -33,6 +33,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
 import com.google.common.base.Predicates;
 
 import net.shibboleth.idp.authn.config.AuthenticationProfileConfiguration;
+import net.shibboleth.idp.profile.config.AttributeResolvingProfileConfiguration;
 import net.shibboleth.idp.saml.authn.principal.AuthenticationMethodPrincipal;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonNegative;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
@@ -45,7 +46,7 @@ import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 /** Configuration for SAML 1 Browser SSO profile requests. */
 public class BrowserSSOProfileConfiguration extends AbstractSAML1ArtifactAwareProfileConfiguration
-        implements AuthenticationProfileConfiguration {
+        implements AuthenticationProfileConfiguration, AttributeResolvingProfileConfiguration {
 
     /** ID for this profile configuration. */
     @Nonnull @NotEmpty public static final String PROFILE_ID = "http://shibboleth.net/ns/profiles/saml1/sso/browser";
@@ -98,15 +99,7 @@ public class BrowserSSOProfileConfiguration extends AbstractSAML1ArtifactAwarePr
         proxyCountLookupStrategy = FunctionSupport.constant(null);
     }
 
-    /**
-     * Get whether attributes should be resolved during the profile.
-     *
-     * <p>Default is true</p>
-     * 
-     * @param profileRequestContext current profile request context
-     * 
-     * @return true iff attributes should be resolved
-     */
+    /** {@inheritDoc} */
     public boolean isResolveAttributes(@Nullable final ProfileRequestContext profileRequestContext) {
         return resolveAttributesPredicate.test(profileRequestContext);
     }
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/BrowserSSOProfileConfiguration.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/BrowserSSOProfileConfiguration.java
index ce34bd135..b600634c4 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/BrowserSSOProfileConfiguration.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/saml2/profile/config/BrowserSSOProfileConfiguration.java
@@ -30,6 +30,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.authn.config.AuthenticationProfileConfiguration;
+import net.shibboleth.idp.profile.config.AttributeResolvingProfileConfiguration;
 import net.shibboleth.idp.saml.authn.principal.AuthnContextClassRefPrincipal;
 import net.shibboleth.idp.saml.profile.config.logic.ProxyAwareForceAuthnPredicate;
 import net.shibboleth.idp.saml.saml2.profile.config.navigate.ProxyAwareAuthnContextComparisonLookupFunction;
@@ -53,7 +54,7 @@ import com.google.common.base.Predicates;
 
 /** Configuration support for SAML 2 Browser SSO. */
 public class BrowserSSOProfileConfiguration extends AbstractSAML2ArtifactAwareProfileConfiguration
-        implements AuthenticationProfileConfiguration {
+        implements AuthenticationProfileConfiguration, AttributeResolvingProfileConfiguration {
     
     /** ID for this profile configuration. */
     @Nonnull @NotEmpty public static final String PROFILE_ID = "http://shibboleth.net/ns/profiles/saml2/sso/browser";
@@ -166,15 +167,7 @@ public class BrowserSSOProfileConfiguration extends AbstractSAML2ArtifactAwarePr
         nameIDFormatPrecedenceLookupStrategy = FunctionSupport.constant(null);
     }
     
-    /**
-     * Get whether attributes should be resolved during the profile.
-     *
-     * <p>Default is true</p>
-     * 
-     * @param profileRequestContext current profile request context
-     * 
-     * @return true iff attributes should be resolved
-     */
+    /** {@inheritDoc} */
     public boolean isResolveAttributes(@Nullable final ProfileRequestContext profileRequestContext) {
         return resolveAttributesPredicate.test(profileRequestContext);
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list