[java-opensaml] 11/14: JSPT-98 Integrate lifecycle checking methods in base classes
Rod Widdowson
rdw at steadingsoftware.com
Mon Jun 13 19:42:42 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=7a447313fd0b20019ea9b8a85f9783da6ae2dd2a
commit 7a447313fd0b20019ea9b8a85f9783da6ae2dd2a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Jun 13 20:23:04 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: soap-impl
---
.../soap/soap11/profile/impl/AddSOAPFault.java | 25 +++++++++++-----------
.../messaging/impl/AddActionHandler.java | 11 ++++------
.../messaging/impl/AddMessageIDHandler.java | 8 +++----
.../messaging/impl/AddRelatesToHandler.java | 11 ++++------
.../messaging/impl/ValidateActionHandler.java | 8 +++----
.../messaging/impl/AddTimestampHandler.java | 14 ++++--------
6 files changed, 30 insertions(+), 47 deletions(-)
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/soap11/profile/impl/AddSOAPFault.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/soap11/profile/impl/AddSOAPFault.java
index 90392fbb6..ac46d205f 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/soap11/profile/impl/AddSOAPFault.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/soap11/profile/impl/AddSOAPFault.java
@@ -26,12 +26,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
-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.primitive.StringSupport;
-
import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.messaging.context.MessageContext;
@@ -48,6 +42,11 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Predicates;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Action that resolves or builds a SOAP 1.1 {@link Fault} object, and stores it in the outbound message context.
*
@@ -121,7 +120,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param strategy strategy used to resolve the fault instance
*/
public void setContextFaultStrategy(@Nullable final Function<ProfileRequestContext,Fault> strategy) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
contextFaultStrategy = strategy;
}
@@ -132,7 +131,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param condition predicate for detailed errors condition
*/
public void setDetailedErrorsCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
detailedErrorsCondition = Constraint.isNotNull(condition, "Detailed errors condition cannot be null");
}
@@ -143,7 +142,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param strategy strategy used to obtain faultcode
*/
public void setFaultCodeLookupStrategy(@Nullable final Function<ProfileRequestContext,QName> strategy) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
faultCodeLookupStrategy = strategy;
}
@@ -154,7 +153,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param strategy strategy used to obtain a fault string
*/
public void setFaultStringLookupStrategy(@Nullable final Function<ProfileRequestContext,String> strategy) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
faultStringLookupStrategy = strategy;
}
@@ -165,7 +164,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param code faultcode
*/
public void setFaultCode(@Nonnull final QName code) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
defaultFaultCode = Constraint.isNotNull(code, "Faultcode cannot be null");
}
@@ -177,7 +176,7 @@ public class AddSOAPFault extends AbstractProfileAction {
* @param message default faultstring
*/
public void setFaultString(@Nullable final String message) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
faultString = StringSupport.trimOrNull(message);
}
@@ -185,7 +184,7 @@ public class AddSOAPFault extends AbstractProfileAction {
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+ throwComponentStateExceptions();
detailedErrors = detailedErrorsCondition.test(profileRequestContext);
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddActionHandler.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddActionHandler.java
index e8ddc69b0..3f5ed26f8 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddActionHandler.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddActionHandler.java
@@ -21,9 +21,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.handler.MessageHandlerException;
@@ -36,6 +33,8 @@ import org.opensaml.soap.wsaddressing.messaging.WSAddressingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Handler implementation that adds a wsa:Action header to the outbound SOAP envelope.
*
@@ -82,8 +81,7 @@ public class AddActionHandler extends AbstractHeaderGeneratingMessageHandler {
* @param uri the new URI value
*/
public void setActionURI(@Nullable final String uri) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
actionURI = StringSupport.trimOrNull(uri);
}
@@ -102,8 +100,7 @@ public class AddActionHandler extends AbstractHeaderGeneratingMessageHandler {
* @param uri the new URI value
*/
public void setFaultActionURI(@Nullable final String uri) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
faultActionURI = StringSupport.trimOrNull(uri);
}
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddMessageIDHandler.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddMessageIDHandler.java
index bb54bb016..1216653f3 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddMessageIDHandler.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddMessageIDHandler.java
@@ -22,9 +22,6 @@ import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.security.IdentifierGenerationStrategy;
-
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.handler.MessageHandlerException;
@@ -35,6 +32,8 @@ import org.opensaml.soap.wsaddressing.messaging.WSAddressingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.utilities.java.support.security.IdentifierGenerationStrategy;
+
/**
* Handler implementation that adds a wsa:MessageID header to the outbound SOAP envelope.
*
@@ -68,8 +67,7 @@ public class AddMessageIDHandler extends AbstractHeaderGeneratingMessageHandler
* @param strategy the new strategy
*/
public void setIdentifierGenerationStrategy(@Nullable final IdentifierGenerationStrategy strategy) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
identifierGenerationStrategy = strategy;
}
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddRelatesToHandler.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddRelatesToHandler.java
index 3e3fb6a3b..c4237943b 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddRelatesToHandler.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/AddRelatesToHandler.java
@@ -19,9 +19,6 @@ package org.opensaml.soap.wsaddressing.messaging.impl;
import javax.annotation.Nonnull;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.context.navigate.ContextDataLookupFunction;
@@ -33,6 +30,8 @@ import org.opensaml.soap.wsaddressing.messaging.WSAddressingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Handler implementation that adds a wsa:RelatesTo header to the outbound SOAP envelope.
*/
@@ -65,8 +64,7 @@ public class AddRelatesToHandler extends AbstractHeaderGeneratingMessageHandler
* @param lookup the lookup function
*/
public void setRelatesToURILookup(final ContextDataLookupFunction<MessageContext, String> lookup) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
relatesToURILookup = lookup;
}
@@ -85,8 +83,7 @@ public class AddRelatesToHandler extends AbstractHeaderGeneratingMessageHandler
* @param value the relationship type
*/
public void setRelationshipType(final String value) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
relationshipType = StringSupport.trimOrNull(value);
}
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/ValidateActionHandler.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/ValidateActionHandler.java
index 22d5dce05..b4c88ca72 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/ValidateActionHandler.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wsaddressing/messaging/impl/ValidateActionHandler.java
@@ -23,9 +23,6 @@ import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
import org.opensaml.core.xml.XMLObject;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.handler.AbstractMessageHandler;
@@ -37,6 +34,8 @@ import org.opensaml.soap.wsaddressing.messaging.WSAddressingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Handler implementation that checks a wsa:Action header against an expected value.
*
@@ -69,8 +68,7 @@ public class ValidateActionHandler extends AbstractMessageHandler {
* @param uri the new URI value
*/
public void setExpectedActionURI(@Nullable final String uri) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
expectedActionURI = StringSupport.trimOrNull(uri);
}
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/messaging/impl/AddTimestampHandler.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/messaging/impl/AddTimestampHandler.java
index 68fdc3e04..8051b9fae 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/messaging/impl/AddTimestampHandler.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/wssecurity/messaging/impl/AddTimestampHandler.java
@@ -24,8 +24,6 @@ import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.handler.MessageHandlerException;
@@ -82,8 +80,7 @@ public class AddTimestampHandler extends AbstractHeaderGeneratingMessageHandler
* @param lookup the lookup function
*/
public void setCreatedLookup(@Nullable final Function<MessageContext,Instant> lookup) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
createdLookup = lookup;
}
@@ -102,8 +99,7 @@ public class AddTimestampHandler extends AbstractHeaderGeneratingMessageHandler
* @param lookup the lookup function
*/
public void setExpiresLookup(@Nullable final Function<MessageContext,Instant> lookup) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
expiresLookup = lookup;
}
@@ -124,8 +120,7 @@ public class AddTimestampHandler extends AbstractHeaderGeneratingMessageHandler
* @param flag true if should use currnet time, false if not
*/
public void setUseCurrentTimeAsDefaultCreated(final boolean flag) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
useCurrentTimeAsDefaultCreated = flag;
}
@@ -146,8 +141,7 @@ public class AddTimestampHandler extends AbstractHeaderGeneratingMessageHandler
* @param value the expires offset, or null
*/
public void setExpiresOffsetFromCreated(@Nullable final Duration value) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ throwSetterPreconditionExceptions();
expiresOffsetFromCreated = value;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list