[java-metadata-aggregator] branch master updated: MDA-246 - Integrate lifecycle checking methods in base classes
Ian Young
ian at iay.org.uk
Thu Jun 11 15:09:56 UTC 2020
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=2a7f4f980506aba3d038e096cf2a144910691d75
The following commit(s) were added to refs/heads/master by this push:
new 2a7f4f9 MDA-246 - Integrate lifecycle checking methods in base classes
2a7f4f9 is described below
commit 2a7f4f980506aba3d038e096cf2a144910691d75
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Jun 11 11:19:07 2020 +0100
MDA-246 - Integrate lifecycle checking methods in base classes
https://issues.shibboleth.net/jira/browse/MDA-246
---
.../metadata/dom/AbstractElementVisitingStage.java | 8 +-
.../metadata/dom/AbstractXSLProcessingStage.java | 31 +++-----
.../metadata/dom/DOMFilesystemSourceStage.java | 35 +++------
.../metadata/dom/DOMResourceSourceStage.java | 23 ++----
.../metadata/dom/ElementStrippingStage.java | 9 +--
.../metadata/dom/ElementsStrippingStage.java | 9 +--
.../metadata/dom/EmptyContainerStrippingStage.java | 9 +--
.../metadata/dom/NamespaceStrippingStage.java | 5 +-
.../metadata/dom/NamespacesStrippingStage.java | 9 +--
.../metadata/dom/XMLSchemaValidationStage.java | 9 +--
.../metadata/dom/XMLSignatureSigningStage.java | 72 +++++-------------
.../metadata/dom/XMLSignatureValidationStage.java | 29 ++------
.../metadata/dom/XPathFilteringStage.java | 9 +--
.../dom/saml/ContactPersonFilterStage.java | 8 +-
.../dom/saml/DiscoFeedCollectionSerializer.java | 8 +-
.../dom/saml/EntitiesDescriptorAssemblerStage.java | 13 +---
.../metadata/dom/saml/EntityFilterStage.java | 13 +---
.../metadata/dom/saml/EntityRoleFilterStage.java | 17 +----
.../dom/saml/PullUpCacheDurationStage.java | 9 +--
.../metadata/dom/saml/PullUpValidUntilStage.java | 9 +--
.../metadata/dom/saml/SetCacheDurationStage.java | 4 +-
.../metadata/dom/saml/SetValidUntilStage.java | 4 +-
.../metadata/dom/saml/ValidateValidUntilStage.java | 8 +-
.../saml/mdattr/EntityAttributeAddingStage.java | 17 +----
.../saml/mdattr/EntityAttributeFilteringStage.java | 13 +---
.../EntityRegistrationAuthorityFilterStage.java | 17 +----
.../dom/saml/mdui/IPHintValidationStage.java | 5 +-
.../AbstractItemMetadataSelectionStage.java | 9 +--
.../metadata/pipeline/AbstractStage.java | 14 ++--
.../metadata/pipeline/CompositeStage.java | 5 +-
.../FilesInDirectoryMultiOutputStrategy.java | 21 ++----
.../metadata/pipeline/ItemIdTransformStage.java | 5 +-
.../metadata/pipeline/ItemMetadataAddingStage.java | 4 +-
.../metadata/pipeline/ItemOrderingStage.java | 5 +-
.../pipeline/MultiOutputSerializationStage.java | 9 +--
.../pipeline/PipelineDemultiplexerStage.java | 16 +---
.../metadata/pipeline/PipelineMergeStage.java | 17 +----
.../metadata/pipeline/ScriptletStage.java | 11 +--
.../metadata/pipeline/SerializationStage.java | 19 ++---
.../metadata/pipeline/SimplePipeline.java | 9 +--
.../metadata/pipeline/SplitMergeStage.java | 31 +++-----
.../metadata/pipeline/StaticItemSourceStage.java | 5 +-
.../BaseIdentifiableInitializableComponent.java | 85 ++++++++++++++++++++++
.../pipeline/impl/BaseInitializableComponent.java | 79 ++++++++++++++++++++
.../metadata/validate/BaseValidator.java | 9 +--
.../metadata/validate/ValidatorSequence.java | 5 +-
.../validate/string/BaseStringRegexValidator.java | 5 +-
.../metadata/validate/x509/X509DSADetector.java | 9 +--
.../x509/X509RSAOpenSSLBlacklistValidator.java | 13 ++--
49 files changed, 330 insertions(+), 457 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
index b3b663a..20baa50 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
@@ -28,7 +28,6 @@ import org.w3c.dom.Element;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -55,7 +54,6 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
*/
@Nonnull @NonnullElements @Unmodifiable
public Collection<QName> getElementNames() {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
return elementNames;
}
@@ -65,8 +63,7 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
* @param names collection of element names to visit.
*/
public void setElementNames(@Nonnull @NonnullElements @Unmodifiable final Collection<QName> names) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(names, "elementNames may not be null");
elementNames = Set.copyOf(names);
}
@@ -79,8 +76,7 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
* @param name {@link QName} for the element to be visited.
*/
public void setElementName(@Nonnull final QName name) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(name, "elementName may not be null");
elementNames = Set.of(name);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
index 4adadcd..5f510f6 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
@@ -34,6 +34,11 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.ErrorStatus;
import net.shibboleth.metadata.InfoStatus;
import net.shibboleth.metadata.Item;
@@ -43,15 +48,9 @@ import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.Resource;
-import org.w3c.dom.Element;
-
/**
* An abstract stage which applies an XSL transformation to each element in the {@link DOMElementItem} collection.
*
@@ -107,9 +106,7 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
* @param resource resource that provides the XSL document
*/
public synchronized void setXSLResource(@Nonnull final Resource resource) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
xslResource = Constraint.isNotNull(resource, "XSL resource can not be null");
}
@@ -130,9 +127,7 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*/
public synchronized void setTransformAttributes(
@Nonnull @NonnullElements @Unmodifiable final Map<String, Object> attributes) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
transformAttributes = Map.copyOf(attributes);
}
@@ -153,9 +148,7 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*/
public synchronized void setTransformFeatures(
@Nonnull @NonnullElements @Unmodifiable final Map<String, Boolean> features) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
transformFeatures = Map.copyOf(features);
}
@@ -176,9 +169,7 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*/
public synchronized void setTransformParameters(
@Nonnull @NonnullElements @Unmodifiable final Map<String, Object> parameters) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
transformParameters = Map.copyOf(parameters);
}
@@ -197,9 +188,7 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
* @param resolver the {@link URIResolver} to use, or <code>null</code>
*/
public synchronized void setURIResolver(@Nullable final URIResolver resolver) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
uriResolver = resolver;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
index 6cb1975..f4bb1d8 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
@@ -29,21 +29,20 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.Live;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
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.xml.ParserPool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
/**
* A stage which reads XML information from the filesystem and places it in the given {@link DOMElementItem} collection.
* <p>
@@ -100,9 +99,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param pool pool of DOM parsers used to parse the XML file in to a DOM
*/
public synchronized void setParserPool(@Nonnull final ParserPool pool) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
parserPool = Constraint.isNotNull(pool, "Parser pool can not be null");
}
@@ -121,9 +118,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param source path to the DOM material provided by this source
*/
public synchronized void setSource(@Nonnull final File source) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
sourceFile = Constraint.isNotNull(source, "XML source file can not be null");
}
@@ -143,9 +138,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param filter filter used to determine if a file, in a directory, should be treated as a source file, may be null
*/
public synchronized void setSourceFileFilter(@Nonnull final FileFilter filter) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
sourceFileFilter = Constraint.isNotNull(filter, "File filter can not be null");
}
@@ -164,9 +157,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param recurse whether directories will be recursively searched for XML input files
*/
public synchronized void setRecurseDirectories(final boolean recurse) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
recurseDirectories = recurse;
}
@@ -185,9 +176,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param isError whether the lack of source files is considered an error
*/
public synchronized void setNoSourceFilesAnError(final boolean isError) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
noSourceFilesAnError = isError;
}
@@ -206,9 +195,7 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
* @param causesFailure whether an error parsing a single file causes the source to fail
*/
public synchronized void setErrorCausesSourceFailure(final boolean causesFailure) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
errorCausesSourceFailure = causesFailure;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
index c9b2506..8967d7d 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMResourceSourceStage.java
@@ -25,21 +25,20 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
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.xml.ParserPool;
import net.shibboleth.utilities.java.support.xml.XMLParserException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.Resource;
-import org.w3c.dom.Element;
-
/**
* A pipeline stage which reads an XML document from an {@link Resource}, parses the document, and places the resultant
* document (root) element in to the provided {@link DOMElementItem} collection.
@@ -83,9 +82,7 @@ public class DOMResourceSourceStage extends AbstractStage<Element> {
* @param resource resource from which the XML document will be fetched
*/
public synchronized void setDOMResource(@Nonnull final Resource resource) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
domResource = Constraint.isNotNull(resource, "DOM resource can not be null");
}
@@ -104,9 +101,7 @@ public class DOMResourceSourceStage extends AbstractStage<Element> {
* @param pool pool of DOM parsers used to parse the XML file in to a DOM
*/
public synchronized void setParserPool(@Nonnull final ParserPool pool) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
parserPool = Constraint.isNotNull(pool, "Parser pool can not be null");
}
@@ -125,9 +120,7 @@ public class DOMResourceSourceStage extends AbstractStage<Element> {
* @param causesFailure whether an error reading and parsing the XML file causes this stage to fail
*/
public synchronized void setErrorCausesSourceFailure(final boolean causesFailure) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
errorCausesSourceFailure = causesFailure;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementStrippingStage.java
index a586f43..ef721b2 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementStrippingStage.java
@@ -32,7 +32,6 @@ import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
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.primitive.StringSupport;
@@ -63,9 +62,7 @@ public class ElementStrippingStage extends AbstractIteratingStage<Element> {
* @param namespace namespace of the element to strip
*/
public void setElementNamespace(@Nonnull @NotEmpty final String namespace) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementNamespace = Constraint.isNotNull(StringSupport.trimOrNull(namespace),
"target namespace can not be null or empty");
}
@@ -85,9 +82,7 @@ public class ElementStrippingStage extends AbstractIteratingStage<Element> {
* @param name the name of the element to strip
*/
public void setElementName(@Nonnull @NotEmpty final String name) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementName = Constraint.isNotNull(StringSupport.trimOrNull(name),
"target element name can not be null or empty");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
index b9f7ebc..58e9e4e 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
@@ -33,7 +33,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.Unmodifiable;
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;
@@ -117,9 +116,7 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
* @param namespace namespace of the elements to strip
*/
public void setElementNamespace(@Nonnull @NotEmpty final String namespace) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementNamespace = Constraint.isNotNull(StringSupport.trimOrNull(namespace),
"target namespace can not be null or empty");
}
@@ -141,9 +138,7 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
*/
public void setElementNames(
@Nonnull @NonnullElements @Unmodifiable @NotEmpty final Collection<String> names) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementNames = Set.copyOf(names);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/EmptyContainerStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/EmptyContainerStrippingStage.java
index fb8e642..50d045c 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/EmptyContainerStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/EmptyContainerStrippingStage.java
@@ -29,7 +29,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
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.primitive.StringSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -61,9 +60,7 @@ public class EmptyContainerStrippingStage extends AbstractIteratingStage<Element
* @param namespace namespace of the element to strip
*/
public void setElementNamespace(@Nonnull @NotEmpty final String namespace) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementNamespace = Constraint.isNotNull(StringSupport.trimOrNull(namespace),
"target namespace can not be null or empty");
}
@@ -83,9 +80,7 @@ public class EmptyContainerStrippingStage extends AbstractIteratingStage<Element
* @param name the name of the element to strip
*/
public void setElementName(@Nonnull @NotEmpty final String name) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementName = Constraint.isNotNull(StringSupport.trimOrNull(name),
"target element name can not be null or empty");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespaceStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespaceStrippingStage.java
index 50f8249..e728cd4 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespaceStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespaceStrippingStage.java
@@ -23,7 +23,6 @@ import javax.annotation.concurrent.ThreadSafe;
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.primitive.StringSupport;
@@ -53,9 +52,7 @@ public class NamespaceStrippingStage extends AbstractNamespacesStrippingStage {
* @param ns namespace URI as a string
*/
public void setNamespace(@Nonnull @NotEmpty final String ns) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
namespace = Constraint.isNotNull(StringSupport.trimOrNull(ns),
"target namespace can not be null or empty");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
index 2db8d7b..855d277 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
@@ -25,7 +25,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A stage which removes all evidence of a given collection of XML namespaces from each metadata item.
@@ -71,9 +70,7 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
* @param nss collection of namespaces
*/
public void setNamespaces(@Nonnull @NonnullElements @Unmodifiable final Collection<String> nss) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
namespaces = Set.copyOf(nss);
}
@@ -92,9 +89,7 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
* @param wl <code>true</code> for whitelisting, <code>false</code> for blacklisting
*/
public void setWhitelisting(final boolean wl) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelisting = wl;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
index 843aede..a460ba8 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
@@ -42,7 +42,6 @@ import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.SchemaBuilder;
import net.shibboleth.utilities.java.support.xml.SerializeSupport;
@@ -92,9 +91,7 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setSchemaResources(
@Nullable @NonnullElements @Unmodifiable final List<Resource> resources) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
schemaResources = List.copyOf(resources);
}
@@ -113,9 +110,7 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
* @param isRequired whether Elements are required to be schema valid
*/
public synchronized void setElementRequiredToBeSchemaValid(final boolean isRequired) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
elementRequiredToBeSchemaValid = isRequired;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
index 5018312..f2a09cd 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
@@ -67,7 +67,6 @@ import net.shibboleth.utilities.java.support.annotation.constraint.Live;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
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 net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -214,9 +213,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param variant SHA algorithm variant used when computing the signature and digest
*/
public synchronized void setShaVariant(@Nonnull final ShaVariant variant) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
shaVariant = Constraint.isNotNull(variant, "SHA variant can not be null");
}
@@ -235,9 +232,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param key private key used to sign the content
*/
public synchronized void setPrivateKey(@Nonnull final PrivateKey key) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
privKey = Constraint.isNotNull(key, "Private key can not be null");
}
@@ -256,9 +251,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param key public key associated with private key used to sign the content
*/
public synchronized void setPublicKey(@Nullable final PublicKey key) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
publicKey = key;
}
@@ -281,9 +274,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setCertificates(
@Nonnull @NonnullElements @Unmodifiable final List<X509Certificate> certs) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
certificates = List.copyOf(certs);
}
@@ -304,9 +295,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setCrls(
@Nonnull @NonnullElements @Unmodifiable final List<X509CRL> revocationLists) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
crls = List.copyOf(revocationLists);
}
@@ -325,9 +314,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param isExclusive whether exclusive canonicalization will be used
*/
public synchronized void setC14nExclusive(final boolean isExclusive) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
c14nExclusive = isExclusive;
}
@@ -346,9 +333,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param withComments whether comments are canonicalized
*/
public synchronized void setC14nWithComments(final boolean withComments) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
c14nWithComments = withComments;
}
@@ -369,9 +354,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setInclusivePrefixList(
@Nonnull @NonnullElements @Unmodifiable final List<String> prefixList) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
inclusivePrefixList = List.copyOf(prefixList);
}
@@ -392,8 +375,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setIdAttributeNames(
@Nonnull @NonnullElements @Unmodifiable final List<QName> names) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(names, "names property may not be null");
idAttributeNames = List.copyOf(names);
@@ -416,9 +398,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setKeyNames(
@Nonnull @NonnullElements @Unmodifiable final List<String> names) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
keyNames = List.copyOf(names);
}
@@ -437,9 +417,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param include whether key names are included in the KeyInfo
*/
public synchronized void setIncludeKeyNames(final boolean include) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeKeyNames = include;
}
@@ -458,9 +436,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param included whether key values are included in the KeyInfo
*/
public synchronized void setIncludeKeyValue(final boolean included) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeKeyValue = included;
}
@@ -479,9 +455,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param include whether end-entity certifcate's subject name is included in the KeyInfo
*/
public synchronized void setIncludeX509SubjectName(final boolean include) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeX509SubjectName = include;
}
@@ -500,9 +474,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param include whether X509 certificates are included in the KeyInfo
*/
public synchronized void setIncludeX509Certificates(final boolean include) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeX509Certificates = include;
}
@@ -521,9 +493,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param include whether CRLs are included in the KeyInfo
*/
public synchronized void setIncludeX509Crls(final boolean include) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeX509Crls = include;
}
@@ -542,9 +512,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param include whether the end-entity certificate's issuer and serial number are included in the KeyInfo
*/
public synchronized void setIncludeX509IssuerSerial(final boolean include) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
includeX509IssuerSerial = include;
}
@@ -563,9 +531,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param debug whether logging of the pre-digest data stream is enabled
*/
public synchronized void setDebugPreDigest(final boolean debug) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
debugPreDigest = debug;
}
@@ -602,9 +568,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* @param newValue whether to remove CR characters from generated signatures.
*/
public void setRemovingCRsFromSignature(final boolean newValue) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
removingCRsFromSignature = newValue;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
index 225995a..02ea65c 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
@@ -40,7 +40,6 @@ import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
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.xml.SerializeSupport;
@@ -105,9 +104,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param required whether the Element is required to be signed
*/
public synchronized void setSignatureRequired(final boolean required) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
signatureRequired = required;
}
@@ -126,9 +123,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param isRequired whether the signature on a Element element is required to be valid
*/
public synchronized void setValidSignatureRequired(final boolean isRequired) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
validSignatureRequired = isRequired;
}
@@ -147,9 +142,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param key key used to verify the signature
*/
public synchronized void setVerificationKey(@Nonnull final PublicKey key) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
verificationKey = Constraint.isNotNull(key, "Public key can not be null");
}
@@ -169,9 +162,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param certificate certificate containing the key used to verify the signature
*/
public synchronized void setVerificationCertificate(@Nonnull final Certificate certificate) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
verificationCertificate = Constraint.isNotNull(certificate, "Certificate can not be null");
verificationKey = verificationCertificate.getPublicKey();
}
@@ -182,9 +173,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param identifiers collection of identifiers to be blacklisted
*/
public void setBlacklistedDigests(@Nonnull @NonnullElements @Unmodifiable final Collection<String> identifiers) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
blacklistedDigests = Set.copyOf(identifiers);
}
@@ -204,9 +193,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
*/
public void setBlacklistedSignatureMethods(
@Nonnull @NonnullElements @Unmodifiable final Collection<String> identifiers) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
blacklistedSignatureMethods = Set.copyOf(identifiers);
}
@@ -234,9 +221,7 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
* @param permit whether empty references are permitted
*/
public synchronized void setPermittingEmptyReferences(final boolean permit) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
permittingEmptyReferences = permit;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XPathFilteringStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XPathFilteringStage.java
index 053ec9f..bfcc53a 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XPathFilteringStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XPathFilteringStage.java
@@ -40,7 +40,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.primitive.StringSupport;
import net.shibboleth.utilities.java.support.xml.SimpleNamespaceContext;
@@ -84,9 +83,7 @@ public class XPathFilteringStage extends AbstractStage<Element> {
* @param expression XPath expression to execute on each {@link DOMElementItem}
*/
public synchronized void setXPathExpression(@Nonnull @NotEmpty final String expression) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
xpathExpression =
Constraint.isNotNull(StringSupport.trimOrNull(expression), "XPath expression can not be null or empty");
}
@@ -106,9 +103,7 @@ public class XPathFilteringStage extends AbstractStage<Element> {
* @param context {@link NamespaceContext} to use in interpreting the XPath expression
*/
public synchronized void setNamespaceContext(@Nullable final NamespaceContext context) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
if (context == null) {
namespaceContext = new SimpleNamespaceContext();
} else {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
index e1da730..a7612c4 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
@@ -34,7 +34,6 @@ import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-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 net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -103,8 +102,7 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
*/
public synchronized void setDesignatedTypes(
@Nonnull @NonnullElements @Unmodifiable final Collection<String> types) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
final Set<String> checkedTypes = new HashSet<>();
for (final String type : types) {
@@ -134,9 +132,7 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
* @param whitelisting true if the designated entities should be considered a whitelist, false otherwise
*/
public synchronized void setWhitelistingTypes(final boolean whitelisting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelistingTypes = whitelisting;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/DiscoFeedCollectionSerializer.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/DiscoFeedCollectionSerializer.java
index 1332275..bc4bf14 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/DiscoFeedCollectionSerializer.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/DiscoFeedCollectionSerializer.java
@@ -37,18 +37,17 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemCollectionSerializer;
import net.shibboleth.metadata.dom.saml.mdattr.MDAttrSupport;
import net.shibboleth.metadata.dom.saml.mdui.MDUISupport;
+import net.shibboleth.metadata.pipeline.impl.BaseInitializableComponent;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-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.xml.ElementSupport;
/**
* A collection serializer that generates an equivalent of the Shibboleth SP's discovery
* feed output from a collection of entity descriptors.
*/
-public class DiscoFeedCollectionSerializer extends AbstractInitializableComponent
+public class DiscoFeedCollectionSerializer extends BaseInitializableComponent
implements ItemCollectionSerializer<Element> {
/** Configured JSON generator factory. */
@@ -276,8 +275,7 @@ public class DiscoFeedCollectionSerializer extends AbstractInitializableComponen
@Override
public void serializeCollection(@Nonnull @NonnullElements final Collection<Item<Element>> items,
@Nonnull final OutputStream output) throws IOException {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+ throwComponentStateExceptions();
final JsonGenerator gen = factory.createGenerator(output);
gen.writeStartArray();
for (final Item<Element> item : items) {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
index dc65f54..3e2a6ba 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
@@ -38,7 +38,6 @@ import net.shibboleth.metadata.pipeline.ItemOrderingStrategy;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.metadata.pipeline.impl.NoOpItemOrderingStrategy;
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;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -88,9 +87,7 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
* @param isError whether attempting to turn an empty item collection should be treated as processing error
*/
public synchronized void setNoChildrenAProcessingError(final boolean isError) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
noChildrenAProcessingError = isError;
}
@@ -109,9 +106,7 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
* @param strategy strategy used to order a collection of Items
*/
public synchronized void setItemOrderingStrategy(@Nonnull final ItemOrderingStrategy<Element> strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
orderingStrategy = Constraint.isNotNull(strategy, "Item ordering strategy can not be null");
}
@@ -130,9 +125,7 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
* @param name Name used for the generated descriptor
*/
public synchronized void setDescriptorName(@Nullable final String name) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
descriptorName = StringSupport.trimOrNull(name);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
index e587a5f..2047047 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
@@ -33,7 +33,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
/** A pipeline stage that will remove SAML EntityDescriptior elements which do meet specified filtering criteria. */
@@ -69,9 +68,7 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
*/
public synchronized void setDesignatedEntities(
@Nonnull @NonnullElements @Unmodifiable final Collection<String> ids) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
designatedEntities = Set.copyOf(ids);
}
@@ -90,9 +87,7 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
* @param whitelisting true if the designated entities should be considered a whitelist, false otherwise
*/
public synchronized void setWhitelistingEntities(final boolean whitelisting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelistingEntities = whitelisting;
}
@@ -111,9 +106,7 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
* @param remove whether EntitiesDescriptor that do not contain EntityDescriptors should be removed
*/
public synchronized void setRemovingEntitylessEntitiesDescriptor(final boolean remove) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
removingEntitylessEntitiesDescriptor = remove;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
index d75d741..7a54182 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
@@ -35,7 +35,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
import net.shibboleth.utilities.java.support.xml.QNameSupport;
@@ -96,9 +95,7 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
* @param roles list of designated entity roles
*/
public synchronized void setDesignatedRoles(@Nonnull @NonnullElements @Unmodifiable final Collection<QName> roles) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
designatedRoles = Set.copyOf(roles);
}
@@ -117,9 +114,7 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
* @param whitelisting true if the designated entities should be considered a whitelist, false otherwise
*/
public synchronized void setWhitelistingRoles(final boolean whitelisting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelistingRoles = whitelisting;
}
@@ -138,9 +133,7 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
* @param remove whether EntityDescriptor elements without roles (after filtering) should be removed altogether
*/
public synchronized void setRemoveRolelessEntities(final boolean remove) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
removingRolelessEntities = remove;
}
@@ -159,9 +152,7 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
* @param remove whether EntitiesDescriptor that do not contain EntityDescriptors should be removed
*/
public synchronized void setRemovingEntitylessEntitiesDescriptor(final boolean remove) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
removingEntitylessEntitiesDescriptor = remove;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpCacheDurationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpCacheDurationStage.java
index fc35e9b..0eadedd 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpCacheDurationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpCacheDurationStage.java
@@ -30,7 +30,6 @@ import org.w3c.dom.Element;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -64,9 +63,7 @@ public class PullUpCacheDurationStage extends AbstractIteratingStage<Element> {
* @param duration the minimum cache duration
*/
public synchronized void setMinimumCacheDuration(final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
if (duration.isNegative()) {
minCacheDuration = Duration.ZERO;
} else {
@@ -89,9 +86,7 @@ public class PullUpCacheDurationStage extends AbstractIteratingStage<Element> {
* @param duration maximum cache duration, must be greater than 0
*/
public synchronized void setMaximumCacheDuration(final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
Constraint.isGreaterThan(0, duration.toMillis(), "Maximum cache duration must be greater than 0");
maxCacheDuration = duration;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpValidUntilStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpValidUntilStage.java
index f279dca..3b09dc7 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpValidUntilStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/PullUpValidUntilStage.java
@@ -31,7 +31,6 @@ import org.w3c.dom.Element;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -68,9 +67,7 @@ public class PullUpValidUntilStage extends AbstractIteratingStage<Element> {
* @param duration minimum amount of time a descriptor may be valid
*/
public synchronized void setMinimumValidityDuration(@Nonnull final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
if (duration.isNegative()) {
minValidityDuration = Duration.ZERO;
} else {
@@ -93,9 +90,7 @@ public class PullUpValidUntilStage extends AbstractIteratingStage<Element> {
* @param duration maximum amount of time a descriptor may be valid, must be greater than 0
*/
public synchronized void setMaximumValidityDuration(@Nonnull final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
Constraint.isGreaterThan(0, duration.toMillis(), "Maximum validity duration must be greater than 0");
maxValidityDuration = duration;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetCacheDurationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetCacheDurationStage.java
index f118542..9f1b859 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetCacheDurationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetCacheDurationStage.java
@@ -29,7 +29,6 @@ import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
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 net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -63,8 +62,7 @@ public class SetCacheDurationStage extends AbstractIteratingStage<Element> {
* @param duration cache duration
*/
public synchronized void setCacheDuration(@Nonnull final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(duration, "cache duration cannot be null");
Constraint.isFalse(duration.isZero(), "cache duration cannot be zero");
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetValidUntilStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetValidUntilStage.java
index 3392668..2d16739 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetValidUntilStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SetValidUntilStage.java
@@ -30,7 +30,6 @@ import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
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 net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -64,8 +63,7 @@ public class SetValidUntilStage extends AbstractIteratingStage<Element> {
* @param duration amount of time the descriptors will be valid
*/
public synchronized void setValidityDuration(@Nonnull final Duration duration) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(duration, "validity duration cannot be null");
Constraint.isFalse(duration.isZero(), "validity duration cannot be zero");
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ValidateValidUntilStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ValidateValidUntilStage.java
index 5758294..319e37e 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ValidateValidUntilStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ValidateValidUntilStage.java
@@ -29,7 +29,6 @@ import net.shibboleth.metadata.ErrorStatus;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -64,9 +63,7 @@ public class ValidateValidUntilStage extends AbstractIteratingStage<Element> {
* @param isRequired whether the item is required to have a validUntil attribute
*/
public synchronized void setRequireValidUntil(final boolean isRequired) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
requireValidUntil = isRequired;
}
@@ -87,8 +84,7 @@ public class ValidateValidUntilStage extends AbstractIteratingStage<Element> {
* than or equal to 0
*/
public synchronized void setMaxValidityInterval(@Nonnull final Duration interval) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(interval, "max validity interval can not be null");
Constraint.isFalse(interval.isNegative(), "max validity interval can not be negative");
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeAddingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeAddingStage.java
index 5e1a025..f9f20b2 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeAddingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeAddingStage.java
@@ -38,7 +38,6 @@ import net.shibboleth.metadata.dom.saml.SAMLSupport;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
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;
/**
@@ -109,9 +108,7 @@ public class EntityAttributeAddingStage extends AbstractIteratingStage<Element>
* @param name the attributeName to set
*/
public void setAttributeName(@Nonnull final String name) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
attributeName = Constraint.isNotNull(name, "attributeName must not be null");
}
@@ -131,9 +128,7 @@ public class EntityAttributeAddingStage extends AbstractIteratingStage<Element>
* @param nameFormat the attributeNameFormat to set
*/
public void setAttributeNameFormat(@Nonnull final String nameFormat) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
attributeNameFormat = Constraint.isNotNull(nameFormat, "attributeNameFormat must not be null");
}
@@ -153,9 +148,7 @@ public class EntityAttributeAddingStage extends AbstractIteratingStage<Element>
* @param value the attributeValue to set
*/
public void setAttributeValue(@Nonnull final String value) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
attributeValue = Constraint.isNotNull(value, "attributeValue must not be null");
}
@@ -176,9 +169,7 @@ public class EntityAttributeAddingStage extends AbstractIteratingStage<Element>
* @param addFirst <code>true</code> to add as the first child, <code>false</code> as the last
*/
public void setAddingFirstChild(final boolean addFirst) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
addingFirstChild = addFirst;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
index 39298c0..ec04e49 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
@@ -36,7 +36,6 @@ import net.shibboleth.metadata.dom.saml.mdrpi.RegistrationAuthority;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -213,9 +212,7 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
*/
public void setRules(
@Nonnull @NonnullElements @Unmodifiable final List<Predicate<EntityAttributeContext>> newRules) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
rules = List.copyOf(Constraint.isNotNull(newRules, "rules property may not be null"));
}
@@ -236,9 +233,7 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
* <code>false</code> to blacklist
*/
public void setWhitelisting(final boolean newValue) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelisting = newValue;
}
@@ -258,9 +253,7 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
* @param newValue whether to remove recorded entity attributes
*/
public void setRecordingRemovals(final boolean newValue) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
recordingRemovals = newValue;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
index e2fb727..f28111b 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
@@ -34,7 +34,6 @@ import net.shibboleth.metadata.dom.saml.SAMLMetadataSupport;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -73,9 +72,7 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
* @param isRequired whether a descriptor is required to have registration information
*/
public synchronized void setRequiringRegistrationInformation(final boolean isRequired) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
requiringRegistrationInformation = isRequired;
}
@@ -96,9 +93,7 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
*/
public synchronized void setDesignatedRegistrationAuthorities(
@Nonnull @NonnullElements @Unmodifiable final Collection<String> authorities) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
designatedAuthorities = Set.copyOf(authorities);
}
@@ -118,9 +113,7 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
* otherwise
*/
public synchronized void setWhitelistingRegistrationAuthorities(final boolean whitelisting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
whitelistingAuthorities = whitelisting;
}
@@ -139,9 +132,7 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
* @param remove whether EntitiesDescriptor that do not contain EntityDescriptors should be removed
*/
public synchronized void setRemovingEntitylessEntitiesDescriptor(final boolean remove) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
removingEntitylessEntitiesDescriptor = remove;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdui/IPHintValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdui/IPHintValidationStage.java
index 1be03e0..d8a7c9f 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdui/IPHintValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdui/IPHintValidationStage.java
@@ -26,7 +26,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.dom.AbstractDOMTraversalStage;
import net.shibboleth.metadata.dom.DOMTraversalContext;
import net.shibboleth.metadata.dom.SimpleDOMTraversalContext;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.net.IPRange;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -54,9 +53,7 @@ public class IPHintValidationStage extends AbstractDOMTraversalStage<DOMTraversa
* @param check whether to check for network addresses only
*/
public void setCheckingNetworks(final boolean check) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
this.checkingNetworks = check;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
index 8ed6115..9ec78e8 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
@@ -33,7 +33,6 @@ import net.shibboleth.metadata.ItemIdentificationStrategy;
import net.shibboleth.metadata.ItemMetadata;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -75,9 +74,7 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
*/
public synchronized void setSelectionRequirements(
@Nonnull @NonnullElements @Unmodifiable final Collection<Class<? extends ItemMetadata>> requirements) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
selectionRequirements = Set.copyOf(requirements);
}
@@ -96,9 +93,7 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
* @param strategy strategy used to generate {@link Item} identifiers for logging purposes, can not be null
*/
public synchronized void setIdentificationStrategy(@Nonnull final ItemIdentificationStrategy strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
identificationStrategy = Constraint.isNotNull(strategy, "Item identification strategy can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
index 11219ce..154e2f1 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
@@ -25,10 +25,9 @@ import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.pipeline.impl.BaseIdentifiableInitializableComponent;
import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -37,7 +36,7 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
* @param <T> type of item this stage operates upon
*/
@ThreadSafe
-public abstract class AbstractStage<T> extends AbstractIdentifiableInitializableComponent implements Stage<T> {
+public abstract class AbstractStage<T> extends BaseIdentifiableInitializableComponent implements Stage<T> {
/**
* The {@link Predicate} applied to the supplied item collection to determine whether the stage will be executed.
@@ -54,9 +53,7 @@ public abstract class AbstractStage<T> extends AbstractIdentifiableInitializable
* whether the stage will be executed
*/
public void setCollectionPredicate(@Nonnull final Predicate<Collection<Item<T>>> pred) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
collectionPredicate = Constraint.isNotNull(pred, "collectionPredicate may not be null");
}
@@ -71,7 +68,7 @@ public abstract class AbstractStage<T> extends AbstractIdentifiableInitializable
public Predicate<Collection<Item<T>>> getCollectionPredicate() {
return collectionPredicate;
}
-
+
/**
* Creates an {@link ComponentInfo}, delegates actual work on the collection to {@link #doExecute(Collection)}, adds
* the {@link ComponentInfo} to all the resultant Item elements and then sets its completion time.
@@ -80,8 +77,7 @@ public abstract class AbstractStage<T> extends AbstractIdentifiableInitializable
*/
@Override public void execute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws StageProcessingException {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+ throwComponentStateExceptions();
final ComponentInfo compInfo = new ComponentInfo(this);
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
index 3546715..ee4c243 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
@@ -26,7 +26,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A stage that is composed of other stages. This allows a collection of stages to be grouped together and for that
@@ -59,9 +58,7 @@ public class CompositeStage<T> extends AbstractStage<T> {
*/
public synchronized void setComposedStages(
@Nonnull @NonnullElements @Unmodifiable final List<Stage<T>> stages) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
composedStages = List.copyOf(stages);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/FilesInDirectoryMultiOutputStrategy.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/FilesInDirectoryMultiOutputStrategy.java
index e4a6bc6..e55af98 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/FilesInDirectoryMultiOutputStrategy.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/FilesInDirectoryMultiOutputStrategy.java
@@ -32,10 +32,9 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemId;
import net.shibboleth.metadata.pipeline.MultiOutputSerializationStage.Destination;
+import net.shibboleth.metadata.pipeline.impl.BaseInitializableComponent;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-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;
/**
@@ -52,7 +51,7 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
*
* @param <T> the type of {@link Item} to operate on
*/
-public class FilesInDirectoryMultiOutputStrategy<T> extends AbstractInitializableComponent
+public class FilesInDirectoryMultiOutputStrategy<T> extends BaseInitializableComponent
implements MultiOutputSerializationStage.OutputStrategy<T> {
/** Class logger. */
@@ -112,9 +111,7 @@ public class FilesInDirectoryMultiOutputStrategy<T> extends AbstractInitializabl
* @param prefix the name prefix to use
*/
public void setNamePrefix(@Nonnull final String prefix) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
namePrefix = Constraint.isNotNull(prefix, "name prefix may not be null");
}
@@ -133,9 +130,7 @@ public class FilesInDirectoryMultiOutputStrategy<T> extends AbstractInitializabl
* @param transformer the name transformer to use
*/
public void setNameTransformer(@Nonnull final Function<String, String> transformer) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
nameTransformer = Constraint.isNotNull(transformer,
"name transformer may not be null");
}
@@ -155,9 +150,7 @@ public class FilesInDirectoryMultiOutputStrategy<T> extends AbstractInitializabl
* @param suffix the name suffix to use
*/
public void setNameSuffix(@Nonnull final String suffix) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
nameSuffix = Constraint.isNotNull(suffix, "name suffix may not be null");
}
@@ -176,9 +169,7 @@ public class FilesInDirectoryMultiOutputStrategy<T> extends AbstractInitializabl
* @param dir the directory to use
*/
public void setDirectory(@Nonnull final File dir) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
directory = Constraint.isNotNull(dir, "directory may not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
index d5bfccd..decf685 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
@@ -29,7 +29,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemId;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A pipeline stage that, taking each {@link ItemId} associated with an {@link Item}, transforms its
@@ -62,9 +61,7 @@ public class ItemIdTransformStage<T> extends AbstractIteratingStage<T> {
*/
public synchronized void setIdTransformers(
@Nonnull @NonnullElements @Unmodifiable final Collection<Function<String, String>> transformers) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
idTransformers = List.copyOf(transformers);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
index e7dd741..cdf9a29 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
@@ -27,7 +27,6 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemMetadata;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -59,8 +58,7 @@ public class ItemMetadataAddingStage<T> extends AbstractIteratingStage<T> {
*/
public void setAdditionalItemMetadata(
@Nonnull @NonnullElements @Unmodifiable final Collection<ItemMetadata> metadata) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
Constraint.isNotNull(metadata, "additional metadata collection must not be null");
additionalItemMetadata = List.copyOf(metadata);
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemOrderingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemOrderingStage.java
index c0c9b72..2fa74a1 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemOrderingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemOrderingStage.java
@@ -25,7 +25,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.impl.NoOpItemOrderingStrategy;
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;
/**
@@ -56,9 +55,7 @@ public class ItemOrderingStage<T> extends AbstractStage<T> {
* @param strategy strategy used to order a collection of Items
*/
public synchronized void setItemOrderingStrategy(@Nonnull final ItemOrderingStrategy<T> strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
orderingStrategy = Constraint.isNotNull(strategy, "Item ordering strategy can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/MultiOutputSerializationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/MultiOutputSerializationStage.java
index 2abafd9..4f3f603 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/MultiOutputSerializationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/MultiOutputSerializationStage.java
@@ -28,7 +28,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemSerializer;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -111,9 +110,7 @@ public class MultiOutputSerializationStage<T> extends AbstractIteratingStage<T>
* @param strategy output strategy function determining where an item will be written
*/
public synchronized void setOutputStrategy(@Nonnull final OutputStrategy<T> strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
outputStrategy = Constraint.isNotNull(strategy, "Output strategy can not be null");
}
@@ -132,9 +129,7 @@ public class MultiOutputSerializationStage<T> extends AbstractIteratingStage<T>
* @param itemSerializer serializer used to write item to the output file
*/
public synchronized void setSerializer(@Nonnull final ItemSerializer<T> itemSerializer) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
serializer = Constraint.isNotNull(itemSerializer, "Item serializer can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
index f6939fc..d09eedd 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
@@ -35,7 +35,6 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElemen
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
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;
/**
@@ -93,9 +92,7 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
* @param service executor service used to run the selected and non-selected item pipelines
*/
public synchronized void setExecutorService(@Nonnull final ExecutorService service) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
executorService = Constraint.isNotNull(service, "ExecutorService can not be null");
}
@@ -114,9 +111,7 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
* @param isWaiting whether this child waits for all the invoked pipelines to complete before proceeding
*/
public synchronized void setWaitingForPipelines(final boolean isWaiting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
waitingForPipelines = isWaiting;
}
@@ -135,9 +130,7 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
* @param factory factory used to create the Item collection that is then given to the pipelines
*/
public synchronized void setCollectionFactory(@Nonnull final Supplier<Collection<Item<T>>> factory) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
collectionFactory = Constraint.isNotNull(factory, "Collection factory can not be null");
}
@@ -158,8 +151,7 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
*/
public synchronized void setPipelineAndSelectionStrategies(
@Nonnull @NonnullElements @Unmodifiable final List<Pair<Pipeline<T>, Predicate<Item<T>>>> passes) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ throwSetterPreconditionExceptions();
for (final Pair<Pipeline<T>, Predicate<Item<T>>> pass : passes) {
Constraint.isNotNull(pass.getFirst(), "Pipeline can not be null");
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
index 5682a17..aaac44e 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
@@ -35,7 +35,6 @@ import net.shibboleth.metadata.SimpleItemCollectionFactory;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -83,9 +82,7 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
* @param service executor service used to run the selected and non-selected item pipelines
*/
public synchronized void setExecutorService(@Nonnull final ExecutorService service) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
executorService = Constraint.isNotNull(service, "ExecutorService can not be null");
}
@@ -106,9 +103,7 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
*/
public synchronized void setMergedPipelines(
@Nonnull @NonnullElements @Unmodifiable final List<? extends Pipeline<T>> pipelines) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
mergedPipelines = List.copyOf(pipelines);
}
@@ -127,9 +122,7 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
* @param factory factory used to create the {@link Item} collection produced by this source
*/
public synchronized void setCollectionFactory(@Nonnull final Supplier<Collection<Item<T>>> factory) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
collectionFactory = Constraint.isNotNull(factory, "Collection factory may not be null");
}
@@ -149,9 +142,7 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
* null
*/
public synchronized void setCollectionMergeStrategy(@Nonnull final CollectionMergeStrategy strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
mergeStrategy = strategy;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ScriptletStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ScriptletStage.java
index 77399be..bc61d7a 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ScriptletStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ScriptletStage.java
@@ -25,16 +25,15 @@ import javax.annotation.concurrent.ThreadSafe;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
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.scripting.EvaluableScript;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* A pipeline stage that computes that transforms the collection of {@link Item} via a script.
*
@@ -78,9 +77,7 @@ public class ScriptletStage<T> extends AbstractStage<T> {
* @param stageScript the script executed by this stage
*/
public synchronized void setScript(@Nonnull final EvaluableScript stageScript) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
script = Constraint.isNotNull(stageScript, "Stage script can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SerializationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SerializationStage.java
index 8cb133b..0db44ca 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SerializationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SerializationStage.java
@@ -27,17 +27,16 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemCollectionSerializer;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* A stage which writes the given item collection out to a file using a provided
* {@link ItemCollectionSerializer}.
@@ -82,9 +81,7 @@ public class SerializationStage<T> extends AbstractStage<T> {
* @param file file to which the item will be written
*/
public synchronized void setOutputFile(@Nonnull final File file) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
outputFile = Constraint.isNotNull(file, "Output file can not be null");
}
@@ -103,9 +100,7 @@ public class SerializationStage<T> extends AbstractStage<T> {
* @param isOverwriting whether an existing output file should be overwritten
*/
public synchronized void setOverwritingExistingOutputFile(final boolean isOverwriting) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
overwritingExistingOutputFile = isOverwriting;
}
@@ -124,9 +119,7 @@ public class SerializationStage<T> extends AbstractStage<T> {
* @param itemSerializer serializer used to write item to the output file
*/
public synchronized void setSerializer(@Nonnull final ItemCollectionSerializer<T> itemSerializer) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
serializer = Constraint.isNotNull(itemSerializer, "Item collection serializer can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
index 5b3def4..5c3a008 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
@@ -25,12 +25,11 @@ import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.pipeline.impl.BaseIdentifiableInitializableComponent;
import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A very simple implementation of {@link Pipeline}.
@@ -38,7 +37,7 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
* @param <T> the type of item upon which this stage operates
*/
@ThreadSafe
-public class SimplePipeline<T> extends AbstractIdentifiableInitializableComponent
+public class SimplePipeline<T> extends BaseIdentifiableInitializableComponent
implements Pipeline<T> {
/** Stages for this pipeline. */
@@ -57,9 +56,7 @@ public class SimplePipeline<T> extends AbstractIdentifiableInitializableComponen
*/
public synchronized void setStages(
@Nonnull @NonnullElements @Unmodifiable final List<Stage<T>> stages) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
pipelineStages = List.copyOf(stages);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
index 230dac8..a5626f9 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
@@ -29,18 +29,17 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.shibboleth.metadata.CollectionMergeStrategy;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.SimpleCollectionMergeStrategy;
import net.shibboleth.metadata.SimpleItemCollectionFactory;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* A stage which splits a given collection and passes selected items to one pipeline and non-selected items to another.
* The selected and non-selected item pipelines are executed via the set {@link ExecutorService} and operate on
@@ -102,9 +101,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* @param service executor service used to run the selected and non-selected item pipelines
*/
public synchronized void setExecutorService(@Nonnull final ExecutorService service) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
executorService = Constraint.isNotNull(service, "ExecutorService can not be null");
}
@@ -123,9 +120,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* @param factory factory used to create the Item collection that is then given to the pipelines
*/
public synchronized void setCollectionFactory(@Nonnull final Supplier<Collection<Item<T>>> factory) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
collectionFactory = Constraint.isNotNull(factory, "Collection factory can not be null");
}
@@ -144,9 +139,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* @param strategy strategy used to split the given item collection, never null
*/
public synchronized void setSelectionStrategy(@Nonnull final Predicate<Item<T>> strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
selectionStrategy = Constraint.isNotNull(strategy, "Item selection strategy can not be null");
}
@@ -165,9 +158,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* @param pipeline pipeline that receives the selected items
*/
public synchronized void setSelectedItemPipeline(@Nullable final Pipeline<T> pipeline) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
selectedItemPipeline = pipeline;
}
@@ -186,9 +177,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* @param pipeline pipeline that receives the non-selected items
*/
public synchronized void setNonselectedItemPipeline(@Nullable final Pipeline<T> pipeline) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
nonselectedItemPipeline = pipeline;
}
@@ -208,9 +197,7 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
* null
*/
public synchronized void setCollectionMergeStrategy(@Nonnull final CollectionMergeStrategy strategy) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
mergeStrategy = Constraint.isNotNull(strategy, "Collection merge strategy can not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
index de2e6ab..420ae62 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
@@ -26,7 +26,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A stage which adds a static collection of Items to a {@link Item} collection.
@@ -57,9 +56,7 @@ public class StaticItemSourceStage<T> extends AbstractStage<T> {
*/
public synchronized void setSourceItems(
@Nonnull @NonnullElements @Unmodifiable final Collection<Item<T>> items) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
source = List.copyOf(items);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseIdentifiableInitializableComponent.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseIdentifiableInitializableComponent.java
new file mode 100644
index 0000000..99765f9
--- /dev/null
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseIdentifiableInitializableComponent.java
@@ -0,0 +1,85 @@
+/*
+ * 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.metadata.pipeline.impl;
+
+import javax.annotation.concurrent.ThreadSafe;
+
+import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.utilities.java.support.component.DestroyedComponentException;
+import net.shibboleth.utilities.java.support.component.UninitializedComponentException;
+import net.shibboleth.utilities.java.support.component.UnmodifiableComponentException;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Base class extending {@link AbstractIdentifiableInitializableComponent} with helper methods
+ * assisting with lifecycle management.
+ */
+ at ThreadSafe
+public class BaseIdentifiableInitializableComponent extends AbstractIdentifiableInitializableComponent {
+
+ /**
+ * Checks if the component is destroyed and, if so, throws a {@link DestroyedComponentException}.
+ */
+ protected final void ifDestroyedThrowDestroyedComponentException() {
+ if (isDestroyed()) {
+ throw new DestroyedComponentException("Component '"
+ + StringSupport.trimOrNull(getId())
+ + "' has already been destroyed and can no longer be used.");
+ }
+ }
+
+ /**
+ * Checks if a component has not been initialized and, if so, throws a {@link UninitializedComponentException}.
+ */
+ protected final void ifNotInitializedThrowUninitializedComponentException() {
+ if (!isInitialized()) {
+ throw new UninitializedComponentException("Component '"
+ + StringSupport.trimOrNull(getId())
+ + "' has not yet been initialized and cannot be used.");
+ }
+ }
+
+ /**
+ * Checks if a component has been initialized and, if so, throws a {@link UnmodifiableComponentException}.
+ */
+ protected final void ifInitializedThrowUnmodifiabledComponentException() {
+ if (isInitialized()) {
+ throw new UnmodifiableComponentException("Component '"
+ + StringSupport.trimOrNull(getId())
+ + "' has already been initialized and can no longer be modified");
+ }
+ }
+
+ /**
+ * Helper for a setter method to check the standard preconditions.
+ */
+ protected final void throwSetterPreconditionExceptions() {
+ ifDestroyedThrowDestroyedComponentException();
+ ifInitializedThrowUnmodifiabledComponentException();
+ }
+
+ /**
+ * Helper for any method to throw appropriate exceptions if we are either
+ * not initialized, or have been destroyed.
+ */
+ protected final void throwComponentStateExceptions() {
+ ifDestroyedThrowDestroyedComponentException();
+ ifNotInitializedThrowUninitializedComponentException();
+ }
+
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseInitializableComponent.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseInitializableComponent.java
new file mode 100644
index 0000000..580d4ce
--- /dev/null
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/impl/BaseInitializableComponent.java
@@ -0,0 +1,79 @@
+/*
+ * 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.metadata.pipeline.impl;
+
+import javax.annotation.concurrent.ThreadSafe;
+
+import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
+import net.shibboleth.utilities.java.support.component.DestroyedComponentException;
+import net.shibboleth.utilities.java.support.component.UninitializedComponentException;
+import net.shibboleth.utilities.java.support.component.UnmodifiableComponentException;
+
+/**
+ * Base class extending {@link AbstractInitializableComponent} with helper methods
+ * assisting with lifecycle management.
+ */
+ at ThreadSafe
+public class BaseInitializableComponent extends AbstractInitializableComponent {
+
+ /**
+ * Checks if the component is destroyed and, if so, throws a {@link DestroyedComponentException}.
+ */
+ protected final void ifDestroyedThrowDestroyedComponentException() {
+ if (isDestroyed()) {
+ throw new DestroyedComponentException("Component has already been destroyed and can no longer be used");
+ }
+ }
+
+ /**
+ * Checks if a component has not been initialized and, if so, throws a {@link UninitializedComponentException}.
+ */
+ protected final void ifNotInitializedThrowUninitializedComponentException() {
+ if (!isInitialized()) {
+ throw new UninitializedComponentException("Component has not yet been initialized and cannot be used.");
+ }
+ }
+
+ /**
+ * Checks if a component has been initialized and, if so, throws a {@link UnmodifiableComponentException}.
+ */
+ protected final void ifInitializedThrowUnmodifiabledComponentException() {
+ if (isInitialized()) {
+ throw new UnmodifiableComponentException(
+ "Component has already been initialized and can no longer be modified");
+ }
+ }
+
+ /**
+ * Helper for a setter method to check the standard preconditions.
+ */
+ protected final void throwSetterPreconditionExceptions() {
+ ifDestroyedThrowDestroyedComponentException();
+ ifInitializedThrowUnmodifiabledComponentException();
+ }
+
+ /**
+ * Helper for any method to throw appropriate exceptions if we are either
+ * not initialized, or have been destroyed.
+ */
+ protected final void throwComponentStateExceptions() {
+ ifDestroyedThrowDestroyedComponentException();
+ ifNotInitializedThrowUninitializedComponentException();
+ }
+
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
index 0d7ce22..e471dcb 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
@@ -22,8 +22,7 @@ import javax.annotation.Nonnull;
import net.shibboleth.metadata.ErrorStatus;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.WarningStatus;
-import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.metadata.pipeline.impl.BaseIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -32,7 +31,7 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
* Encapsulates the notion of an identifier for each validator class, and helper
* methods for constructing status metadata.
*/
-public abstract class BaseValidator extends AbstractIdentifiableInitializableComponent {
+public abstract class BaseValidator extends BaseIdentifiableInitializableComponent {
/**
* Message format string.
@@ -61,9 +60,7 @@ public abstract class BaseValidator extends AbstractIdentifiableInitializableCom
* @param newMessage the new message format string
*/
public void setMessage(@Nonnull final String newMessage) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
message = Constraint.isNotNull(newMessage, "message format string may not be null");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
index db91ac8..f7f6473 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
@@ -26,7 +26,6 @@ import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A {@link Validator} implementation which encapsulates the functionality of stepping
@@ -50,9 +49,7 @@ public class ValidatorSequence<V> extends BaseValidator implements Validator<V>
* @param newValidators the list of validators to set
*/
public void setValidators(@Nonnull @NonnullElements @Unmodifiable final List<Validator<V>> newValidators) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
validators = List.copyOf(newValidators);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/string/BaseStringRegexValidator.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/string/BaseStringRegexValidator.java
index 77f986d..b4fd215 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/string/BaseStringRegexValidator.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/string/BaseStringRegexValidator.java
@@ -24,7 +24,6 @@ import javax.annotation.Nonnull;
import net.shibboleth.metadata.validate.BaseValidator;
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;
/**
* A base class for <code>Validator</code>s that match {@link String} values against a regular expression.
@@ -55,9 +54,7 @@ public abstract class BaseStringRegexValidator extends BaseValidator {
* @param r the regular expression to set.
*/
public void setRegex(@Nonnull final String r) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
regex = r;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509DSADetector.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509DSADetector.java
index 1340326..3d9c12f 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509DSADetector.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509DSADetector.java
@@ -26,7 +26,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.validate.BaseValidator;
import net.shibboleth.metadata.validate.Validator;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* Validator class to check that X.509 certificates do not contain DSA public keys.
@@ -77,9 +76,7 @@ public class X509DSADetector extends BaseValidator implements Validator<X509Cert
* @param newAction the {@link net.shibboleth.metadata.validate.Validator.Action} to be returned
*/
public void setAction(@Nonnull final Action newAction) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
action = newAction;
}
@@ -89,9 +86,7 @@ public class X509DSADetector extends BaseValidator implements Validator<X509Cert
* @param newValue whether an {@link net.shibboleth.metadata.ErrorStatus} should be added on failure
*/
public void setError(final boolean newValue) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
error = newValue;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
index 82d6b83..f58d2a4 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/x509/X509RSAOpenSSLBlacklistValidator.java
@@ -35,15 +35,14 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.apache.commons.codec.binary.Hex;
+import org.springframework.core.io.Resource;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.StageProcessingException;
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.apache.commons.codec.binary.Hex;
-import org.springframework.core.io.Resource;
-
/**
* Validator class to check RSA moduli in X.509 certificates against a OpenSSL-format
* blacklist. Appropriate blacklists are available as part of the Debian 7.x
@@ -81,9 +80,7 @@ public class X509RSAOpenSSLBlacklistValidator extends AbstractX509Validator {
* @param resource resource that provides the blacklist
*/
public synchronized void setBlacklistResource(@Nonnull final Resource resource) {
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
+ throwSetterPreconditionExceptions();
blacklistResource = Constraint.isNotNull(resource, "blacklist resource can not be null");
}
@@ -159,7 +156,7 @@ public class X509RSAOpenSSLBlacklistValidator extends AbstractX509Validator {
@Override
public void doValidate(@Nonnull final X509Certificate cert, @Nonnull final Item<?> item,
@Nonnull final String stageId) throws StageProcessingException {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+ throwComponentStateExceptions();
final PublicKey key = cert.getPublicKey();
if ("RSA".equals(key.getAlgorithm())) {
final RSAPublicKey rsaKey = (RSAPublicKey) key;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list