[java-shib-metadata] branch main updated: IDP-1972 - Revisit deferred classnames for solving layering conflicts
Scott Cantor
cantor.2 at osu.edu
Tue Aug 8 20:21:27 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-metadata.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-metadata.git;a=commit;h=c0f21ea2ec772d19fe3eb3b03b27f21dab35e0e5
The following commit(s) were added to refs/heads/main by this push:
new c0f21ea2 IDP-1972 - Revisit deferred classnames for solving layering conflicts
c0f21ea2 is described below
commit c0f21ea2ec772d19fe3eb3b03b27f21dab35e0e5
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Aug 8 16:21:24 2023 -0400
IDP-1972 - Revisit deferred classnames for solving layering conflicts
https://shibboleth.atlassian.net/browse/IDP-1972
Switched parser pool bean access to property.
---
.../AbstractDynamicMetadataProviderParser.java | 29 +++++++++++-------
.../AbstractReloadingMetadataProviderParser.java | 34 +++++++++++++++-------
.../net/shibboleth/spring/parser.properties | 4 +++
3 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractDynamicMetadataProviderParser.java b/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractDynamicMetadataProviderParser.java
index 6c9884e4..685ff1ba 100644
--- a/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractDynamicMetadataProviderParser.java
+++ b/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractDynamicMetadataProviderParser.java
@@ -19,6 +19,7 @@ import javax.annotation.Nullable;
import org.opensaml.core.xml.persist.FilesystemLoadSaveManager;
import org.slf4j.Logger;
+import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
@@ -28,18 +29,26 @@ import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.spring.util.SpringSupport;
import net.shibboleth.shared.xml.AttributeSupport;
+import net.shibboleth.shared.xml.ParserPool;
/**
* Parser for {@link org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver}.
*/
public abstract class AbstractDynamicMetadataProviderParser extends AbstractMetadataProviderParser {
- /** The reference to the system parser pool that we set up. */
- @Nonnull @NotEmpty private static final String DEFAULT_PARSER_POOL_REF = "shibboleth.ParserPool";
-
/** Logger. */
@Nonnull private Logger log = LoggerFactory.getLogger(AbstractDynamicMetadataProviderParser.class);
+ /** Bean ID for defaulted {@link ParserPool} instance. */
+ @Nullable private final String parserPoolRef;
+
+ /** Constructor. */
+ public AbstractDynamicMetadataProviderParser() {
+ // Will warn later if not set.
+ parserPoolRef =
+ getCustomProperty(AbstractDynamicMetadataProviderParser.class.getName() + ".ParserPool.bean", null);
+ }
+
/**
*
* {@inheritDoc}
@@ -183,7 +192,7 @@ public abstract class AbstractDynamicMetadataProviderParser extends AbstractMeta
@Nullable protected String getTaskTimerRef(@Nonnull final Element element) {
if (element.hasAttributeNS(null, "taskTimerRef")) {
- return StringSupport.trimOrNull(StringSupport.trimOrNull(element.getAttributeNS(null, "taskTimerRef")));
+ return AttributeSupport.ensureAttributeValue(element, null, "taskTimerRef");
}
return null;
}
@@ -196,17 +205,15 @@ public abstract class AbstractDynamicMetadataProviderParser extends AbstractMeta
* @return parser pool reference
*/
@Nonnull @NotEmpty protected String getParserPoolRef(@Nonnull final Element element) {
- String parserPoolRef = null;
if (element.hasAttributeNS(null, "parserPoolRef")) {
- parserPoolRef =
- StringSupport.trimOrNull(StringSupport.trimOrNull(element.getAttributeNS(null, "parserPoolRef")));
+ return AttributeSupport.ensureAttributeValue(element, null, "parserPoolRef");
}
- if (parserPoolRef == null) {
- parserPoolRef = DEFAULT_PARSER_POOL_REF;
+ if (parserPoolRef != null) {
+ return parserPoolRef;
}
-
- return parserPoolRef;
+
+ throw new BeanCreationException("Default ParserPool bean ID not available.");
}
}
\ No newline at end of file
diff --git a/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractReloadingMetadataProviderParser.java b/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractReloadingMetadataProviderParser.java
index f1a184b8..c71bc8d5 100644
--- a/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractReloadingMetadataProviderParser.java
+++ b/shib-metadata-spring/src/main/java/net/shibboleth/spring/metadata/AbstractReloadingMetadataProviderParser.java
@@ -18,9 +18,12 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.spring.util.SpringSupport;
import net.shibboleth.shared.xml.AttributeSupport;
+import net.shibboleth.shared.xml.ParserPool;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
@@ -33,6 +36,16 @@ public abstract class AbstractReloadingMetadataProviderParser extends AbstractMe
/** The reference to the system parser pool that we set up. */
@Nonnull @NotEmpty private static final String DEFAULT_PARSER_POOL_REF = "shibboleth.ParserPool";
+ /** Bean ID for defaulted {@link ParserPool} instance. */
+ @Nullable private final String parserPoolRef;
+
+ /** Constructor. */
+ public AbstractReloadingMetadataProviderParser() {
+ // Will warn later if not set.
+ parserPoolRef =
+ getCustomProperty(AbstractReloadingMetadataProviderParser.class.getName() + ".ParserPool.bean", null);
+ }
+
/**
*
* {@inheritDoc}
@@ -51,6 +64,8 @@ public abstract class AbstractReloadingMetadataProviderParser extends AbstractMe
builder.addConstructorArgReference(timerRef);
}
+ builder.addPropertyReference("parserPool", getParserPoolRef(element));
+
if (element.hasAttributeNS(null, "indexesRef")) {
builder.addPropertyReference("indexes",
AttributeSupport.ensureAttributeValue(element, null, "indexesRef"));
@@ -80,8 +95,6 @@ public abstract class AbstractReloadingMetadataProviderParser extends AbstractMe
builder.addPropertyValue("expirationWarningThreshold",
StringSupport.trimOrNull(element.getAttributeNS(null, "expirationWarningThreshold")));
}
-
- builder.addPropertyReference("parserPool", getParserPoolRef(element));
}
@@ -92,9 +105,9 @@ public abstract class AbstractReloadingMetadataProviderParser extends AbstractMe
*
* @return task timer reference
*/
- protected String getTaskTimerRef(final Element element) {
+ @Nullable protected String getTaskTimerRef(final Element element) {
if (element.hasAttributeNS(null, "taskTimerRef")) {
- return StringSupport.trimOrNull(element.getAttributeNS(null, "taskTimerRef"));
+ return AttributeSupport.ensureAttributeValue(element, null, "taskTimerRef");
}
return null;
}
@@ -106,17 +119,16 @@ public abstract class AbstractReloadingMetadataProviderParser extends AbstractMe
*
* @return parser pool reference
*/
- @Nonnull protected String getParserPoolRef(final Element element) {
- String parserPoolRef = null;
+ @Nonnull @NotEmpty protected String getParserPoolRef(final Element element) {
if (element.hasAttributeNS(null, "parserPoolRef")) {
- parserPoolRef = StringSupport.trimOrNull(element.getAttributeNS(null, "parserPoolRef"));
+ return AttributeSupport.ensureAttributeValue(element, null, "parserPoolRef");
}
- if (parserPoolRef == null) {
- parserPoolRef = DEFAULT_PARSER_POOL_REF;
+ if (parserPoolRef != null) {
+ return parserPoolRef;
}
-
- return parserPoolRef;
+
+ throw new BeanCreationException("Default ParserPool bean ID not available.");
}
}
\ No newline at end of file
diff --git a/shib-metadata-spring/src/test/resources/META-INF/net/shibboleth/spring/parser.properties b/shib-metadata-spring/src/test/resources/META-INF/net/shibboleth/spring/parser.properties
new file mode 100644
index 00000000..f82a192b
--- /dev/null
+++ b/shib-metadata-spring/src/test/resources/META-INF/net/shibboleth/spring/parser.properties
@@ -0,0 +1,4 @@
+# These are custom parser properties to inject higher layer class names, beans, etc. into lower layer parsers.
+
+net.shibboleth.spring.metadata.AbstractReloadingMetadataProviderParser.ParserPool.bean = shibboleth.ParserPool
+net.shibboleth.spring.metadata.AbstractDynamicMetadataProviderParser.ParserPool.bean = shibboleth.ParserPool
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list