[java-shib-attribute] branch main updated: Extend metadata config support with native XMLObject handling.
Scott Cantor
cantor.2 at osu.edu
Thu Feb 23 15:31:45 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-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=fe07723768e9f51eb495291ec9db022a5cd9e958
The following commit(s) were added to refs/heads/main by this push:
new fe0772376 Extend metadata config support with native XMLObject handling.
fe0772376 is described below
commit fe07723768e9f51eb495291ec9db022a5cd9e958
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Feb 23 10:31:42 2023 -0500
Extend metadata config support with native XMLObject handling.
---
...tMetadataDrivenConfigurationLookupStrategy.java | 3 +--
.../config/ListConfigurationLookupStrategy.java | 26 +++++++++++++++-------
.../config/SetConfigurationLookupStrategy.java | 25 ++++++++++++++-------
3 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/AbstractMetadataDrivenConfigurationLookupStrategy.java b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
index 7d66cf4cb..e745ef34c 100644
--- a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
+++ b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/AbstractMetadataDrivenConfigurationLookupStrategy.java
@@ -428,8 +428,7 @@ public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> exten
*/
@Nullable private T translate(@Nonnull final IdPAttribute tag) {
- final List<IdPAttributeValue> values = tag.getValues();
- if (values == null || values.isEmpty()) {
+ if (tag.getValues().isEmpty()) {
log.debug("Tag '{}' contained no values, no setting returned for '{}'", tag.getId(), propertyName);
return null;
}
diff --git a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/ListConfigurationLookupStrategy.java b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/ListConfigurationLookupStrategy.java
index f963f4bbe..36b45d541 100644
--- a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/ListConfigurationLookupStrategy.java
+++ b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/ListConfigurationLookupStrategy.java
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
@@ -54,12 +55,16 @@ public class ListConfigurationLookupStrategy<T> extends AbstractCollectionConfig
final List<IdPAttributeValue> values = tag.getValues();
final List<T> result = new ArrayList<>(values.size());
for (final IdPAttributeValue value : values) {
- if (value instanceof StringAttributeValue) {
+ if (value instanceof StringAttributeValue sval) {
try {
- result.add(createInstanceFromString(((StringAttributeValue) value).getValue()));
+ result.add(createInstanceFromString(sval.getValue()));
} catch (final Exception e) {
log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
}
+ } else if (value instanceof XMLObjectAttributeValue xmlValue) {
+ if (getPropertyType().isInstance(xmlValue.getValue())) {
+ result.add(getPropertyType().cast(xmlValue.getValue()));
+ }
}
}
return result;
@@ -75,12 +80,17 @@ public class ListConfigurationLookupStrategy<T> extends AbstractCollectionConfig
final List<T> result = new ArrayList<>(values.size());
for (final XMLObject value : values) {
assert value != null;
- final String converted = xmlObjectToString(value);
- if (converted != null) {
- try {
- result.add(createInstanceFromString(converted));
- } catch (final Exception e) {
- log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+
+ if (getPropertyType().isInstance(value)) {
+ result.add(getPropertyType().cast(value));
+ } else {
+ final String converted = xmlObjectToString(value);
+ if (converted != null) {
+ try {
+ result.add(createInstanceFromString(converted));
+ } catch (final Exception e) {
+ log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+ }
}
}
}
diff --git a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/SetConfigurationLookupStrategy.java b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/SetConfigurationLookupStrategy.java
index 3f601bda6..57b47e7f8 100644
--- a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/SetConfigurationLookupStrategy.java
+++ b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/config/SetConfigurationLookupStrategy.java
@@ -31,6 +31,7 @@ import org.slf4j.Logger;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
@@ -55,12 +56,16 @@ public class SetConfigurationLookupStrategy<T> extends AbstractCollectionConfigu
final List<IdPAttributeValue> values = tag.getValues();
final Set<T> result = new HashSet<>(values.size());
for (final IdPAttributeValue value : values) {
- if (value instanceof StringAttributeValue) {
+ if (value instanceof StringAttributeValue sval) {
try {
- result.add(createInstanceFromString(((StringAttributeValue) value).getValue()));
+ result.add(createInstanceFromString(sval.getValue()));
} catch (final Exception e) {
log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
}
+ } else if (value instanceof XMLObjectAttributeValue xmlValue) {
+ if (getPropertyType().isInstance(xmlValue.getValue())) {
+ result.add(getPropertyType().cast(xmlValue.getValue()));
+ }
}
}
return result;
@@ -76,12 +81,16 @@ public class SetConfigurationLookupStrategy<T> extends AbstractCollectionConfigu
final Set<T> result = new HashSet<>(values.size());
for (final XMLObject value : values) {
assert value != null;
- final String converted = xmlObjectToString(value);
- if (converted != null) {
- try {
- result.add(createInstanceFromString(converted));
- } catch (final Exception e) {
- log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+ if (getPropertyType().isInstance(value)) {
+ result.add(getPropertyType().cast(value));
+ } else {
+ final String converted = xmlObjectToString(value);
+ if (converted != null) {
+ try {
+ result.add(createInstanceFromString(converted));
+ } catch (final Exception e) {
+ log.error("Error converting tag value into {}", getPropertyType().getSimpleName(), e);
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list