[java-opensaml] 13/14: JSPT-98 Integrate lifecycle checking methods in base classes

Rod Widdowson rdw at steadingsoftware.com
Mon Jun 13 19:42:44 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-opensaml.

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

commit c8829df927bd2f1c0f02960fd557af06f14b5a7f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Jun 13 20:34:19 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: storage-impl
---
 .../java/org/opensaml/storage/impl/JPAStorageService.java |  3 +--
 .../storage/impl/client/ClientStorageService.java         | 15 +++++++--------
 .../storage/impl/client/LoadClientStorageServices.java    |  5 ++---
 .../impl/client/PopulateClientStorageLoadContext.java     |  3 +--
 .../impl/client/PopulateClientStorageSaveContext.java     |  3 +--
 .../client/SaveCookieBackedClientStorageServices.java     |  3 +--
 6 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
index 55097a08d..719571a2b 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
@@ -46,7 +46,6 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElemen
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
 import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -92,7 +91,7 @@ public class JPAStorageService extends AbstractStorageService implements Storage
      * @param retry number of transaction retries
      */
     public void setTransactionRetry(final int retry) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         transactionRetry =
                 (int) Constraint.isGreaterThanOrEqual(0, retry,
                         "Transaction retry must be greater than or equal to zero");
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java
index ce885910f..a37252ab0 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/ClientStorageService.java
@@ -51,7 +51,6 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterI
 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.ComponentInitializationException;
-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 net.shibboleth.utilities.java.support.net.CookieManager;
@@ -141,7 +140,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param map capability map
      */
     public void setCapabilityMap(@Nonnull @NonnullElements final Map<ClientStorageSource,Integer> map) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         Constraint.isNotNull(map, "Capability map cannot be null");
         
         for (final Map.Entry<ClientStorageSource,Integer> entry : map.entrySet()) {
@@ -170,7 +169,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param request servlet request in which to manage data
      */
     public void setHttpServletRequest(@Nonnull final HttpServletRequest request) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         httpServletRequest = Constraint.isNotNull(request, "HttpServletRequest cannot be null");
     }
@@ -190,7 +189,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param manager the CookieManager to use.
      */
     public void setCookieManager(@Nonnull final CookieManager manager) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         cookieManager = Constraint.isNotNull(manager, "CookieManager cannot be null");
     }
@@ -210,7 +209,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param name label to use
      */
     public void setStorageName(@Nonnull @NotEmpty final String name) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         storageName = Constraint.isNotNull(StringSupport.trimOrNull(name), "Storage name cannot be null or empty");
     }
@@ -230,7 +229,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param sealer {@link DataSealer} to use for data security
      */
     public void setDataSealer(@Nonnull final DataSealer sealer) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
     }
@@ -241,7 +240,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param strategy {@link DataSealerKeyStrategy} to use for stale key detection
      */
     public void setKeyStrategy(@Nullable final DataSealerKeyStrategy strategy) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         keyStrategy = strategy;
     }
@@ -252,7 +251,7 @@ public class ClientStorageService extends AbstractMapBackedStorageService implem
      * @param factory factory to use
      */
     public void setClientStorageServiceStoreFactory(@Nonnull final Factory factory) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         storeFactory = Constraint.isNotNull(factory, "Factory cannot be null");
     }
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/LoadClientStorageServices.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/LoadClientStorageServices.java
index e6c85f42b..fa9dd1ade 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/LoadClientStorageServices.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/LoadClientStorageServices.java
@@ -42,7 +42,6 @@ import jakarta.servlet.http.Cookie;
 import jakarta.servlet.http.HttpServletRequest;
 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.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.net.URISupport;
 
@@ -91,7 +90,7 @@ public class LoadClientStorageServices extends AbstractProfileAction {
      * @param flag flag to set
      */
     public void setUseLocalStorage(final boolean flag) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         useLocalStorage = flag;
     }
@@ -102,7 +101,7 @@ public class LoadClientStorageServices extends AbstractProfileAction {
      * @param services instances to check for loading
      */
     public void setStorageServices(@Nonnull @NonnullElements final Collection<ClientStorageService> services) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         Constraint.isNotNull(services, "StorageService collection cannot be null");
         storageServices = new HashMap<>(services.size());
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
index 24a9cc160..998be0229 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
@@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
 
 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.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -68,7 +67,7 @@ public class PopulateClientStorageLoadContext extends AbstractProfileAction {
      * @param services instances to check for loading
      */
     public void setStorageServices(@Nonnull @NonnullElements final Collection<ClientStorageService> services) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         storageServices = List.copyOf(Constraint.isNotNull(services, "StorageService collection cannot be null"));
     }
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContext.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContext.java
index eab2bbb0d..4cfcba972 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContext.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContext.java
@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
 
 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.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -67,7 +66,7 @@ public class PopulateClientStorageSaveContext extends AbstractProfileAction {
      * @param services instances to check for saving
      */
     public void setStorageServices(@Nonnull @NonnullElements final Collection<ClientStorageService> services) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         storageServices = List.copyOf(Constraint.isNotNull(services, "StorageService collection cannot be null"));
     }
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/SaveCookieBackedClientStorageServices.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/SaveCookieBackedClientStorageServices.java
index aa4692ab6..412375c1e 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/SaveCookieBackedClientStorageServices.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/SaveCookieBackedClientStorageServices.java
@@ -38,7 +38,6 @@ import com.google.common.escape.Escaper;
 import com.google.common.net.UrlEscapers;
 
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
 /**
@@ -78,7 +77,7 @@ public class SaveCookieBackedClientStorageServices
      * @param services instances to check for loading
      */
     public void setStorageServices(@Nonnull @NonnullElements final Collection<ClientStorageService> services) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        throwSetterPreconditionExceptions();
         
         Constraint.isNotNull(services, "StorageService collection cannot be null");
         storageServices = new HashMap<>(services.size());

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


More information about the commits mailing list