[java-identity-provider] 05/06: JSPT-98 Integrate lifecycle checking methods in base classes

Rod Widdowson rdw at steadingsoftware.com
Mon Jul 11 16:23:16 UTC 2022


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

rdw pushed a commit to branch dev/JSPT-98
in repository java-identity-provider.

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

commit f97b7ef544da9778484c161c406d0984932e8f78
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jul 3 16:50:26 2022 +0100

    JSPT-98 Integrate lifecycle checking methods in base classes
    
    https://shibboleth.atlassian.net/browse/JSPT-98
    
    Stop using ComponentSupport and use the appropriate methods instead:
    
        idp-consent-impl
---
 .../ar/impl/AttributeReleaseFlowDescriptor.java    | 16 ++++++---------
 .../consent/flow/impl/ConsentFlowDescriptor.java   | 16 +++++----------
 .../impl/AbstractConsentIndexedStorageAction.java  | 22 +++++++++------------
 .../storage/impl/AbstractConsentStorageAction.java | 22 +++++++++------------
 .../consent/flow/storage/impl/RevokeConsent.java   |  8 +++-----
 .../idp/consent/logic/impl/AttributePredicate.java | 10 +++-------
 .../logic/impl/CounterStorageKeyFunction.java      | 23 ++++++++++------------
 .../logic/impl/MessageSourceConsentFunction.java   | 23 +++++++++-------------
 .../consent/storage/impl/ConsentSerializer.java    |  4 +---
 9 files changed, 55 insertions(+), 89 deletions(-)

diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptor.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptor.java
index 98e215ed8..909846b18 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptor.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/ar/impl/AttributeReleaseFlowDescriptor.java
@@ -25,7 +25,6 @@ import javax.annotation.Nonnull;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor;
 import net.shibboleth.idp.consent.logic.impl.AttributeValuesHashFunction;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -92,8 +91,7 @@ public class AttributeReleaseFlowDescriptor extends ConsentFlowDescriptor {
      * @param flag true if consent should not be remembered
      */
     public void setDoNotRememberConsentAllowed(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        
+        throwSetterPreconditionExceptions();
         doNotRememberConsentAllowed = flag;
     }
 
@@ -103,8 +101,7 @@ public class AttributeReleaseFlowDescriptor extends ConsentFlowDescriptor {
      * @param flag true iff consent to any attribute and to any relying party is allowed
      */
     public void setGlobalConsentAllowed(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        
+        throwSetterPreconditionExceptions();
         globalConsentAllowed = flag;
     }
 
@@ -114,8 +111,7 @@ public class AttributeReleaseFlowDescriptor extends ConsentFlowDescriptor {
      * @param flag true iff per-attribute consent is enabled
      */
     public void setPerAttributeConsentEnabled(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        
+        throwSetterPreconditionExceptions();
         perAttributeConsentEnabled = flag;
     }
 
@@ -126,9 +122,9 @@ public class AttributeReleaseFlowDescriptor extends ConsentFlowDescriptor {
      */
     public void setAttributeValuesHashFunction(
             @Nonnull final Function<Collection<IdPAttributeValue>, String> function) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
-        attributeValuesHashFunction = Constraint.isNotNull(function, "Attribute values hash function cannot be null");
+        throwSetterPreconditionExceptions();
+                attributeValuesHashFunction = Constraint.isNotNull(function, 
+                        "Attribute values hash function cannot be null");
     }
 
 }
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
index 33043da07..c5b54698a 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
@@ -22,7 +22,6 @@ import java.time.Duration;
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 
 /**
  * Descriptor for a consent flow.
@@ -103,8 +102,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
      * @param flag true if consent equality includes comparing consent values
      */
     public void setCompareValues(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         compareValues = flag;
     }
 
@@ -114,8 +112,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
      * @param consentLifetime time to expire consent storage records.  null means infinite
      */
     public void setLifetime(@Nullable final Duration consentLifetime) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         lifetime = consentLifetime;
     }
 
@@ -125,8 +122,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
      * @param maximum the maximum number of records, or <=0 for no limit
      */
     public void setMaximumNumberOfStoredRecords(final int maximum) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-    
+        throwSetterPreconditionExceptions();
         maxStoredRecords = maximum;
     }
 
@@ -136,8 +132,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
      * @param maximum the maximum number of records, or <=0 for no limit
      */
     public void setExpandedNumberOfStoredRecords(final int maximum) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-    
+        throwSetterPreconditionExceptions();
         expandedMaxStoredRecords = maximum;
     }
 
@@ -149,8 +144,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
      * @param size size threshold
      */
     public void setExpandedStorageThreshold(final long size) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-    
+        throwSetterPreconditionExceptions();
         expandedStorageThreshold = size;
     }
 }
\ No newline at end of file
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageAction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageAction.java
index 05f1fd660..c6bfbd531 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageAction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentIndexedStorageAction.java
@@ -30,6 +30,12 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.storage.StorageRecord;
+import org.opensaml.storage.StorageSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor;
 import net.shibboleth.idp.consent.storage.impl.CollectionSerializer;
 import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
@@ -38,15 +44,8 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElemen
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.collection.Pair;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.storage.StorageRecord;
-import org.opensaml.storage.StorageSerializer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Base class for consent actions which write to a {@link org.opensaml.storage.StorageService}.
  * 
@@ -95,8 +94,7 @@ public class AbstractConsentIndexedStorageAction extends AbstractConsentStorageA
      * @param strategy the storage index key lookup strategy
      */
     public void setStorageIndexKeyLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageIndexKeyLookupStrategy =
                 Constraint.isNotNull(strategy, "Storage index key lookup strategy cannot be null");
     }
@@ -107,8 +105,7 @@ public class AbstractConsentIndexedStorageAction extends AbstractConsentStorageA
      * @param serializer the storage keys serializer
      */
     public void setStorageKeysSerializer(@Nonnull final StorageSerializer<Collection<String>> serializer) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageKeysSerializer = Constraint.isNotNull(serializer, "Storage keys serializer cannot be null");
     }
 
@@ -119,8 +116,7 @@ public class AbstractConsentIndexedStorageAction extends AbstractConsentStorageA
      */
     public void setStorageKeysStrategy(
             @Nonnull final Function<Pair<ProfileRequestContext, List<String>>, List<String>> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageKeysStrategy = Constraint.isNotNull(strategy, "Storage keys strategy cannot be null");
     }
 
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageAction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageAction.java
index 8a15f0c68..cc2ff02a7 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageAction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/AbstractConsentStorageAction.java
@@ -23,6 +23,12 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.storage.StorageSerializer;
+import org.opensaml.storage.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.idp.consent.flow.impl.AbstractConsentAction;
 import net.shibboleth.idp.consent.logic.impl.FlowIdLookupFunction;
@@ -31,15 +37,8 @@ import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
 import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.storage.StorageSerializer;
-import org.opensaml.storage.StorageService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Base class for consent actions which interact with a {@link StorageService}.
  * 
@@ -121,8 +120,7 @@ public abstract class AbstractConsentStorageAction extends AbstractConsentAction
      * @param serializer storage serializer
      */
     public void setStorageSerializer(@Nonnull final StorageSerializer<Map<String,Consent>> serializer) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageSerializer = Constraint.isNotNull(serializer, "Storage serializer cannot be null");
     }
     
@@ -132,8 +130,7 @@ public abstract class AbstractConsentStorageAction extends AbstractConsentAction
      * @param strategy the storage context lookup strategy
      */
     public void setStorageContextLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageContextLookupStrategy = Constraint.isNotNull(strategy, "Storage context lookup strategy cannot be null");
     }
 
@@ -143,8 +140,7 @@ public abstract class AbstractConsentStorageAction extends AbstractConsentAction
      * @param strategy the storage key lookup strategy
      */
     public void setStorageKeyLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageKeyLookupStrategy = Constraint.isNotNull(strategy, "Storage key lookup strategy cannot be null");
     }
 
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/RevokeConsent.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/RevokeConsent.java
index 4012e3d7a..efa94c68b 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/RevokeConsent.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/RevokeConsent.java
@@ -21,15 +21,14 @@ import java.io.IOException;
 
 import javax.annotation.Nonnull;
 
-import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-
 import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
+
 /**
  * Consent action which deletes a consent record from storage.
  * 
@@ -50,8 +49,7 @@ public class RevokeConsent extends AbstractConsentIndexedStorageAction {
      * @param flag flag to set
      */
     public void setMaskStorageErrors(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         maskStorageErrors = flag;
     }
 
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributePredicate.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributePredicate.java
index d2f35819c..b230d8914 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributePredicate.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributePredicate.java
@@ -31,7 +31,6 @@ import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Predicate;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
@@ -61,8 +60,7 @@ public class AttributePredicate extends AbstractInitializableComponent implement
      * @param prompted prompted attribute IDs
      */
     public void setPromptedAttributeIds(@Nullable @NonnullElements final Collection<String> prompted) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         promptedAttributeIds = new HashSet<>(StringSupport.normalizeStringCollection(prompted));
     }
 
@@ -72,8 +70,7 @@ public class AttributePredicate extends AbstractInitializableComponent implement
      * @param ignored ignored attribute IDs
      */
     public void setIgnoredAttributeIds(@Nullable @NonnullElements final Collection<String> ignored) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         ignoredAttributeIds = new HashSet<>(StringSupport.normalizeStringCollection(ignored));
     }
 
@@ -83,8 +80,7 @@ public class AttributePredicate extends AbstractInitializableComponent implement
      * @param expression an attribute ID matching expression
      */
     public void setAttributeIdMatchExpression(@Nullable final Pattern expression) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         if (expression != null && !expression.pattern().isEmpty()) {
             matchExpression = expression;
         } else {
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunction.java
index d8bb6368f..ff7e51432 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/CounterStorageKeyFunction.java
@@ -28,15 +28,6 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import net.shibboleth.idp.consent.flow.storage.impl.UpdateCounter;
-import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
-import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
-import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-
 import org.opensaml.messaging.context.navigate.ChildContextLookup;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.storage.StorageRecord;
@@ -46,6 +37,14 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Joiner;
 
+import net.shibboleth.idp.consent.flow.storage.impl.UpdateCounter;
+import net.shibboleth.idp.profile.context.ProfileInterceptorContext;
+import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
+import net.shibboleth.utilities.java.support.collection.Pair;
+import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
+
 /**
  * Function to order storage keys by least-used and oldest first during pruning of storage records.
  * 
@@ -78,8 +77,7 @@ public class CounterStorageKeyFunction extends AbstractInitializableComponent im
      */
     public void setInterceptorContextLookupStrategy(
             @Nonnull final Function<ProfileRequestContext, ProfileInterceptorContext> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         interceptorContextlookupStrategy =
                 Constraint.isNotNull(strategy, "Profile interceptor context lookup strategy cannot be null");
     }
@@ -90,8 +88,7 @@ public class CounterStorageKeyFunction extends AbstractInitializableComponent im
      * @param strategy the storage context lookup strategy
      */
     public void setStorageContextLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         storageContextLookupStrategy = Constraint.isNotNull(strategy, "Storage context lookup strategy cannot be null");
     }
 
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunction.java
index 405cf11af..a5aaa9280 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/MessageSourceConsentFunction.java
@@ -26,6 +26,11 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.context.MessageSource;
+import org.springframework.context.MessageSourceAware;
+import org.springframework.context.NoSuchMessageException;
+
 import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor;
 import net.shibboleth.idp.profile.context.navigate.RelyingPartyIdLookupFunction;
@@ -35,15 +40,9 @@ import net.shibboleth.utilities.java.support.codec.StringDigester;
 import net.shibboleth.utilities.java.support.codec.StringDigester.OutputFormat;
 import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.springframework.context.MessageSource;
-import org.springframework.context.MessageSourceAware;
-import org.springframework.context.NoSuchMessageException;
-
 /**
  * Function that returns a consent object whose id and value are resolved from a lookup function
  * and {@link MessageSource}.
@@ -93,8 +92,7 @@ public class MessageSourceConsentFunction extends AbstractInitializableComponent
      * @param strategy lookup strategy
      */
     public void setConsentKeyLookupStrategy(@Nonnull final Function<ProfileRequestContext,String> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         consentKeyLookupStrategy = Constraint.isNotNull(strategy, "Consent key lookup strategy cannot be null");
     }
 
@@ -104,8 +102,7 @@ public class MessageSourceConsentFunction extends AbstractInitializableComponent
      * @param suffix suffix of message code for the consent value
      */
     public void setConsentValueMessageCodeSuffix(@Nonnull @NotEmpty final String suffix) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         consentValueMessageCodeSuffix =
                 Constraint.isNotNull(StringSupport.trimOrNull(suffix),
                         "Consent value message code suffix cannot be null nor empty");
@@ -118,8 +115,7 @@ public class MessageSourceConsentFunction extends AbstractInitializableComponent
      */
     public void setConsentFlowDescriptorLookupStrategy(
             @Nonnull final Function<ProfileRequestContext,ConsentFlowDescriptor> strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         consentFlowDescriptorLookupStrategy =
                 Constraint.isNotNull(strategy, "Consent flow descriptor lookup strategy cannot be null");
     }
@@ -141,8 +137,7 @@ public class MessageSourceConsentFunction extends AbstractInitializableComponent
      * @param function hash function
      */
     public void setHashFunction(@Nonnull final Function<String,String> function) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         hashFunction = Constraint.isNotNull(function, "Hash function cannot be null");
     }
 
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
index cdad484e4..726728ad1 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
@@ -53,7 +53,6 @@ import net.shibboleth.idp.consent.Consent;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -97,8 +96,7 @@ public class ConsentSerializer extends AbstractInitializableComponent implements
      * @param mappings string to symbolic mappings
      */
     public void setSymbolics(@Nonnull @NonnullElements final Map<String, Integer> mappings) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+        throwSetterPreconditionExceptions();
         symbolics = HashBiMap.create(Constraint.isNotNull(mappings, "Symbolic mappings cannot be null"));
     }
 

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


More information about the commits mailing list