[java-identity-provider] branch master updated: Add mapped tag support to metadata-driven config lookup.
Scott Cantor
cantor.2 at osu.edu
Tue May 21 12:50:07 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=d35b9d67da4b14c57f56c5d4f8260d087e59ece7
The following commit(s) were added to refs/heads/master by this push:
new d35b9d6 Add mapped tag support to metadata-driven config lookup.
d35b9d6 is described below
commit d35b9d67da4b14c57f56c5d4f8260d087e59ece7
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue May 21 12:50:04 2019 -0400
Add mapped tag support to metadata-driven config lookup.
---
.../src/main/resources/conf/services.properties | 2 +
.../system/conf/relying-party-mddriven.xml | 7 +-
...tMetadataDrivenConfigurationLookupStrategy.java | 175 ++++++++++++++++++---
.../config/BeanConfigurationLookupStrategy.java | 32 +++-
.../config/BooleanConfigurationLookupStrategy.java | 27 +++-
.../config/DoubleConfigurationLookupStrategy.java | 27 +++-
.../DurationConfigurationLookupStrategy.java | 31 +++-
.../config/IntegerConfigurationLookupStrategy.java | 27 +++-
.../config/ListConfigurationLookupStrategy.java | 24 +++
.../config/LongConfigurationLookupStrategy.java | 27 +++-
.../config/SetConfigurationLookupStrategy.java | 24 +++
.../config/StringConfigurationLookupStrategy.java | 28 +++-
12 files changed, 402 insertions(+), 29 deletions(-)
diff --git a/idp-conf/src/main/resources/conf/services.properties b/idp-conf/src/main/resources/conf/services.properties
index 257dade..d691b4a 100644
--- a/idp-conf/src/main/resources/conf/services.properties
+++ b/idp-conf/src/main/resources/conf/services.properties
@@ -16,6 +16,8 @@ idp.service.logging.checkInterval = PT5M
#idp.service.relyingparty.resources = shibboleth.RelyingPartyResolverResources
#idp.service.relyingparty.failFast = false
idp.service.relyingparty.checkInterval = PT15M
+# Set true to limit metadata-driven settings lookup to decoded EntityAttributes
+idp.service.relyingparty.ignoreUnmappedEntityAttributes=true
#idp.service.metadata.resources = shibboleth.MetadataResolverResources
#idp.service.metadata.failFast = false
diff --git a/idp-conf/src/main/resources/system/conf/relying-party-mddriven.xml b/idp-conf/src/main/resources/system/conf/relying-party-mddriven.xml
index 6fd4ac4..e30f884 100644
--- a/idp-conf/src/main/resources/system/conf/relying-party-mddriven.xml
+++ b/idp-conf/src/main/resources/system/conf/relying-party-mddriven.xml
@@ -53,6 +53,10 @@
<bean id="RelyingPartyByTag.MDDriven" parent="RelyingParty.MDDriven" abstract="true"
class="net.shibboleth.idp.saml.relyingparty.impl.RelyingPartyConfigurationSupport" factory-method="byTag"
c:trim="false" c:matchAll="false" />
+
+ <bean id="RelyingPartyByMappedTag.MDDriven" parent="RelyingParty.MDDriven" abstract="true"
+ class="net.shibboleth.idp.saml.relyingparty.impl.RelyingPartyConfigurationSupport" factory-method="byMappedTag"
+ c:trim="false" c:matchAll="false" />
<bean id="shibboleth.DefaultMDProfileAliases"
class="org.springframework.beans.factory.config.ListFactoryBean">
@@ -64,7 +68,8 @@
</bean>
<bean id="shibboleth.AbstractMDDrivenProperty" abstract="true"
- p:profileAliases="#{getObject('shibboleth.MDProfileAliases') ?: getObject('shibboleth.DefaultMDProfileAliases')}" />
+ p:profileAliases="#{getObject('shibboleth.MDProfileAliases') ?: getObject('shibboleth.DefaultMDProfileAliases')}"
+ p:ignoreUnmappedEntityAttributes="%{idp.service.relyingparty.ignoreUnmappedEntityAttributes:false}" />
<bean id="shibboleth.MDDrivenStringProperty" abstract="true" parent="shibboleth.AbstractMDDrivenProperty"
class="net.shibboleth.idp.saml.profile.config.StringConfigurationLookupStrategy" />
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/AbstractMetadataDrivenConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
index 7688638..6a15fb7 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
@@ -45,10 +45,14 @@ import org.slf4j.LoggerFactory;
import com.google.common.collect.Collections2;
+import net.shibboleth.idp.attribute.AttributesMapContainer;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.utilities.java.support.annotation.constraint.Live;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap;
import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -93,6 +97,9 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
/** Cache the lookup in the context tree. */
private boolean enableCaching;
+ /** Examine only decoded/mapped tags in object metadata. */
+ private boolean ignoreUnmappedEntityAttributes;
+
/** Base name of property to produce. */
@NonnullAfterInit @NotEmpty private String propertyName;
@@ -113,20 +120,8 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
enableCaching = true;
}
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (propertyName == null) {
- throw new ComponentInitializationException("Property name cannot be null or empty");
- } else if (propertyAliases == null) {
- propertyAliases = Collections.emptyList();
- }
- }
-
/**
- * Set whether tag matching should examine and require an Attribute NameFormat of the URI type.
+ * Sets whether tag matching should examine and require an Attribute NameFormat of the URI type.
*
* <p>Default is false.</p>
*
@@ -139,7 +134,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
- * Set whether property lookup should be cached in the profile context tree.
+ * Sets whether property lookup should be cached in the profile context tree.
*
* <p>Default is true.</p>
*
@@ -150,9 +145,23 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
enableCaching = flag;
}
+
+ /**
+ * Sets whether property lookup should be based solely on mapped/decoded objects
+ * and not on underlying SAML Attributes.
+ *
+ * <p>Default is false.</p>
+ *
+ * @param flag flag to set
+ */
+ public void setIgnoreUnmappedEntityAttributes(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ ignoreUnmappedEntityAttributes = flag;
+ }
/**
- * Set the "base" name of the property/setting to derive.
+ * Sets the "base" name of the property/setting to derive.
*
* @param name base property name
*/
@@ -163,7 +172,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
- * Set profile ID aliases to include when checking for metadata tags (the property name is suffixed to the
+ * Sets profile ID aliases to include when checking for metadata tags (the property name is suffixed to the
* aliases).
*
* <p>This allows alternative tag names to be checked.</p>
@@ -179,7 +188,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
- * Set a default value to return as the function result in the absence of an explicit property.
+ * Sets a default value to return as the function result in the absence of an explicit property.
*
* @param value default value to return
*/
@@ -190,7 +199,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
- * Set lookup strategy for metadata to examine.
+ * Sets lookup strategy for metadata to examine.
*
* @param strategy lookup strategy
*/
@@ -201,7 +210,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
- * Set lookup strategy for profile ID to base property names on.
+ * Sets lookup strategy for profile ID to base property names on.
*
* @param strategy lookup strategy
*/
@@ -211,7 +220,19 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
profileIdLookupStrategy = Constraint.isNotNull(strategy, "Profile ID lookup strategy cannot be null");
}
-// Checkstyle: CyclomaticComplexity OFF
+/** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (propertyName == null) {
+ throw new ComponentInitializationException("Property name cannot be null or empty");
+ } else if (propertyAliases == null) {
+ propertyAliases = Collections.emptyList();
+ }
+ }
+
+ // Checkstyle: CyclomaticComplexity|MethodLength OFF
/** {@inheritDoc} */
@Nullable public T apply(@Nullable final BaseContext input) {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
@@ -254,6 +275,38 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
profileId = "";
}
+ // Look for "primary" tag name based on profile/property using mapped tags.
+ IdPAttribute idpAttribute = findMatchingMappedTag(entity, profileId + '/' + propertyName);
+ if (idpAttribute != null) {
+ log.debug("Found matching tag '{}' for property '{}'", idpAttribute.getId(), propertyName);
+ final T result = translate(idpAttribute);
+ if (enableCaching) {
+ cacheContext.getPropertyMap().put(propertyName, result);
+ }
+ return result;
+ }
+
+ // Check aliases.
+ for (final String alias : propertyAliases) {
+ idpAttribute = findMatchingMappedTag(entity, alias);
+ if (idpAttribute != null) {
+ log.debug("Found matching tag '{}' for property '{}'", idpAttribute.getId(), propertyName);
+ final T result = translate(idpAttribute);
+ if (enableCaching) {
+ cacheContext.getPropertyMap().put(propertyName, result);
+ }
+ return result;
+ }
+ }
+
+ if (ignoreUnmappedEntityAttributes) {
+ log.debug("No applicable mapped tag, default returned for '{}'", propertyName);
+ if (enableCaching) {
+ cacheContext.getPropertyMap().put(propertyName, defaultValue);
+ }
+ return defaultValue;
+ }
+
// Look for "primary" tag name based on profile/property.
Attribute attribute = findMatchingTag(entity, profileId + '/' + propertyName);
if (attribute != null) {
@@ -265,6 +318,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
return result;
}
+ // Check aliases.
for (final String alias : propertyAliases) {
attribute = findMatchingTag(entity, alias);
if (attribute != null) {
@@ -283,7 +337,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
return defaultValue;
}
-// Checkstyle: CyclomaticComplexity ON
+// Checkstyle: CyclomaticComplexity|MethodLength ON
/**
* Translate the value(s) into a setting of the appropriate type.
@@ -306,6 +360,24 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
/**
* Translate the value(s) into a setting of the appropriate type.
*
+ * @param tag tag to translate
+ *
+ * @return the setting derived from the tag's value(s)
+ */
+ @Nullable private T translate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values == null || values.isEmpty()) {
+ log.debug("Tag '{}' contained no values, no setting returned for '{}'", tag.getId(), propertyName);
+ return null;
+ }
+
+ return doTranslate(tag);
+ }
+
+ /**
+ * Translate the value(s) into a setting of the appropriate type.
+ *
* <p>Overrides of this function can assume a non-zero collection of values.</p>
*
* @param tag tag to translate
@@ -313,6 +385,46 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
* @return the setting derived from the tag's value(s)
*/
@Nullable protected abstract T doTranslate(@Nonnull final Attribute tag);
+
+ /**
+ * Translate the value(s) into a setting of the appropriate type.
+ *
+ * <p>Overrides of this function can assume a non-zero collection of values.</p>
+ *
+ * @param tag tag to translate
+ *
+ * @return the setting derived from the tag's value(s)
+ */
+ @Nullable protected abstract T doTranslate(@Nonnull final IdPAttribute tag);
+
+ /**
+ * Find first matching attribute in the input object's node metadata.
+ *
+ * @param entity the metadata to examine
+ * @param name the tag name to search for
+ *
+ * @return matching attribute, or null
+ */
+ @Nullable private IdPAttribute findMatchingMappedTag(@Nonnull final EntityDescriptor entity,
+ @Nonnull @NotEmpty final String name) {
+
+ // Check for a tag match in the node metadata of the entity and its parent(s).
+ IdPAttribute tag = findMatchingMappedTag(entity.getObjectMetadata(), name);
+ if (tag != null) {
+ return tag;
+ }
+
+ XMLObject parent = entity.getParent();
+ while (parent instanceof EntitiesDescriptor) {
+ tag = findMatchingMappedTag(parent.getObjectMetadata(), name);
+ if (tag != null) {
+ return tag;
+ }
+ parent = parent.getParent();
+ }
+
+ return null;
+ }
/**
* Find a matching entity attribute in the input metadata.
@@ -356,6 +468,27 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
}
/**
+ * Find first matching attribute in the input object's node metadata.
+ *
+ * @param input the metadata to examine
+ * @param name the tag name to search for
+ *
+ * @return matching attribute, or null
+ */
+ @Nullable private IdPAttribute findMatchingMappedTag(@Nonnull final LockableClassToInstanceMultiMap input,
+ @Nonnull @NotEmpty final String name) {
+
+ final List<AttributesMapContainer> containerList = input.get(AttributesMapContainer.class);
+ if (null == containerList || containerList.isEmpty() || containerList.get(0).get() == null ||
+ containerList.get(0).get().isEmpty()) {
+ return null;
+ }
+
+ final Collection<IdPAttribute> matches = containerList.get(0).get().get(name);
+ return matches.isEmpty() ? null : matches.iterator().next();
+ }
+
+ /**
* Find a matching entity attribute in the input metadata.
*
* @param entityAttributes the metadata to examine
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BeanConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BeanConfigurationLookupStrategy.java
index 65248e8..31bdbb4 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BeanConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BeanConfigurationLookupStrategy.java
@@ -32,6 +32,9 @@ import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
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;
@@ -94,11 +97,38 @@ public class BeanConfigurationLookupStrategy<T> extends AbstractMetadataDrivenCo
/** {@inheritDoc} */
@Override
+ @Nullable protected T doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Bean property of tyoe '{}'", tag.getId(), propertyType.getSimpleName());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ try {
+ return applicationContext.getBean(((StringAttributeValue) value).getValue(), propertyType);
+ } catch (final BeansException e) {
+ log.error("Error locating appropriately typed bean named {}",
+ ((StringAttributeValue) value).getValue(), e);
+ return null;
+ }
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected T doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BooleanConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BooleanConfigurationLookupStrategy.java
index cbab637..c0e3f2b 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BooleanConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/BooleanConfigurationLookupStrategy.java
@@ -32,6 +32,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Boolean-valued
* configuration settings based on EntityAttribute extension tags.
@@ -45,11 +49,32 @@ public class BooleanConfigurationLookupStrategy extends AbstractMetadataDrivenCo
/** {@inheritDoc} */
@Override
+ @Nullable protected Boolean doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Boolean property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ return XSBooleanValue.valueOf(((StringAttributeValue) value).getValue()).getValue();
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Boolean doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DoubleConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DoubleConfigurationLookupStrategy.java
index 4a3caa2..563a67f 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DoubleConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DoubleConfigurationLookupStrategy.java
@@ -32,6 +32,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Double-valued
* configuration settings based on EntityAttribute extension tags.
@@ -45,11 +49,32 @@ public class DoubleConfigurationLookupStrategy extends AbstractMetadataDrivenCon
/** {@inheritDoc} */
@Override
+ @Nullable protected Double doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Double property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ return Double.valueOf(((StringAttributeValue) value).getValue());
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Double doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DurationConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DurationConfigurationLookupStrategy.java
index 920d581..a08213a 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DurationConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/DurationConfigurationLookupStrategy.java
@@ -33,6 +33,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;
import net.shibboleth.ext.spring.config.StringToDurationConverter;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Long-valued
@@ -55,11 +58,37 @@ public class DurationConfigurationLookupStrategy extends AbstractMetadataDrivenC
/** {@inheritDoc} */
@Override
+ @Nullable protected Duration doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Duration property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ try {
+ return durationConverter.convert(((StringAttributeValue) value).getValue());
+ } catch (final IllegalArgumentException e) {
+ log.error("Error converting duration", e);
+ return null;
+ }
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Duration doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/IntegerConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/IntegerConfigurationLookupStrategy.java
index 8d60963..a10274d 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/IntegerConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/IntegerConfigurationLookupStrategy.java
@@ -32,6 +32,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Integer-valued
* configuration settings based on EntityAttribute extension tags.
@@ -45,11 +49,32 @@ public class IntegerConfigurationLookupStrategy extends AbstractMetadataDrivenCo
/** {@inheritDoc} */
@Override
+ @Nullable protected Integer doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Integer property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ return Integer.decode(((StringAttributeValue) value).getValue());
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Integer doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/ListConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/ListConfigurationLookupStrategy.java
index c54797e..37021e3 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/ListConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/ListConfigurationLookupStrategy.java
@@ -28,6 +28,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives List<String>-valued
* configuration settings based on EntityAttribute extension tags.
@@ -43,6 +47,26 @@ public class ListConfigurationLookupStrategy<T> extends AbstractCollectionConfig
/** {@inheritDoc} */
@Override
+ @Nullable protected List<T> doTranslate(@Nonnull final IdPAttribute tag) {
+
+ log.debug("Converting tag '{}' to List<{}> property", tag.getId(), getPropertyType().getSimpleName());
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ final List<T> result = new ArrayList<>(values.size());
+ for (final IdPAttributeValue value : values) {
+ if (value instanceof StringAttributeValue) {
+ try {
+ result.add(createInstanceFromString(((StringAttributeValue) value).getValue()));
+ } catch (final Exception e) {
+ log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+ }
+ }
+ }
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected List<T> doTranslate(@Nonnull final Attribute tag) {
log.debug("Converting tag '{}' to List<{}> property", tag.getName(), getPropertyType().getSimpleName());
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/LongConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/LongConfigurationLookupStrategy.java
index 59fad52..9468b7a 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/LongConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/LongConfigurationLookupStrategy.java
@@ -34,6 +34,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Long-valued
* configuration settings based on EntityAttribute extension tags.
@@ -47,11 +51,32 @@ public class LongConfigurationLookupStrategy extends AbstractMetadataDrivenConfi
/** {@inheritDoc} */
@Override
+ @Nullable protected Long doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to Long property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ return Long.decode(((StringAttributeValue) value).getValue());
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Long doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/SetConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/SetConfigurationLookupStrategy.java
index 925bcf5..37647d9 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/SetConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/SetConfigurationLookupStrategy.java
@@ -29,6 +29,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives Set<String>-valued
* configuration settings based on EntityAttribute extension tags.
@@ -44,6 +48,26 @@ public class SetConfigurationLookupStrategy<T> extends AbstractCollectionConfigu
/** {@inheritDoc} */
@Override
+ @Nullable protected Set<T> doTranslate(@Nonnull final IdPAttribute tag) {
+
+ log.debug("Converting tag '{}' to List<{}> property", tag.getId(), getPropertyType().getSimpleName());
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ final Set<T> result = new HashSet<>(values.size());
+ for (final IdPAttributeValue value : values) {
+ if (value instanceof StringAttributeValue) {
+ try {
+ result.add(createInstanceFromString(((StringAttributeValue) value).getValue()));
+ } catch (final Exception e) {
+ log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+ }
+ }
+ }
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected Set<T> doTranslate(@Nonnull final Attribute tag) {
log.debug("Converting tag '{}' to Set<String> property", tag.getName());
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/StringConfigurationLookupStrategy.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/StringConfigurationLookupStrategy.java
index 8b3bda5..6613d51 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/StringConfigurationLookupStrategy.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/profile/config/StringConfigurationLookupStrategy.java
@@ -36,6 +36,10 @@ import org.opensaml.saml.saml2.core.Attribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.StringAttributeValue;
+
/**
* A strategy function that examines SAML metadata associated with a relying party and derives String-valued
* configuration settings based on EntityAttribute extension tags.
@@ -49,11 +53,32 @@ public class StringConfigurationLookupStrategy extends AbstractMetadataDrivenCon
/** {@inheritDoc} */
@Override
+ @Nullable protected String doTranslate(@Nonnull final IdPAttribute tag) {
+
+ final List<IdPAttributeValue> values = tag.getValues();
+ if (values.size() != 1) {
+ log.error("Tag '{}' contained multiple values, returning none", tag.getId());
+ return null;
+ }
+
+ log.debug("Converting tag '{}' to String property", tag.getId());
+
+ final IdPAttributeValue value = values.get(0);
+ if (value instanceof StringAttributeValue) {
+ return ((StringAttributeValue) value).getValue();
+ } else {
+ log.error("Tag '{}' contained non-string value, returning null");
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
@Nullable protected String doTranslate(@Nonnull final Attribute tag) {
final List<XMLObject> values = tag.getAttributeValues();
if (values.size() != 1) {
- log.error("Tag '{}' contained multiple values, returning none");
+ log.error("Tag '{}' contained multiple values, returning none", tag.getName());
return null;
}
@@ -96,5 +121,6 @@ public class StringConfigurationLookupStrategy extends AbstractMetadataDrivenCon
return null;
}
// Checkstyle: CyclomaticComplexity ON
+
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list