[java-identity-provider] branch feature/IDP-1434 updated: Removal of encoder/mapper code, merge of attribute in metadata matchers.
Scott Cantor
cantor.2 at osu.edu
Sat May 4 17:05:34 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch feature/IDP-1434
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=52c0bb5efd691cc147d3eec28ad14e41264fa696
The following commit(s) were added to refs/heads/feature/IDP-1434 by this push:
new 52c0bb5 Removal of encoder/mapper code, merge of attribute in metadata matchers.
52c0bb5 is described below
commit 52c0bb5efd691cc147d3eec28ad14e41264fa696
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Sat May 4 17:04:38 2019 -0400
Removal of encoder/mapper code, merge of attribute in metadata matchers.
---
.../shibboleth/idp/attribute/AttributeEncoder.java | 71 -----
.../net/shibboleth/idp/attribute/IdPAttribute.java | 33 +--
.../shibboleth/idp/attribute/AttributeTest.java | 63 -----
.../net/shibboleth/idp/attribute/MockEncoder.java | 70 -----
.../saml/impl/AttributeInMetadataMatcher.java | 165 +++++++----
.../impl/MappedAttributeInMetadataMatcher.java | 261 -----------------
.../saml/impl/AttributeInMetadataMatcherTest.java | 26 +-
.../impl/MappedAttributeInMetadataMatcherTest.java | 10 +-
.../impl/MappedAttributeInMetadataRuleParser.java | 14 +-
.../MappedAttributeInMetadataRuleParserTest.java | 6 +-
.../resolver/AbstractAttributeDefinition.java | 38 ---
.../attribute/resolver/AttributeDefinition.java | 10 -
.../idp/attribute/resolver/AttributeResolver.java | 12 -
.../resolver/ResolvedAttributeDefinition.java | 6 -
.../resolver/AbstractAttributeDefinitionTest.java | 72 -----
.../attribute/resolver/MockAttributeEncoder.java | 66 -----
.../resolver/impl/AttributeResolverImpl.java | 13 -
.../resolver/spring/AttributeMapperTest.java | 55 ++--
.../idp/attribute/resolver/spring/mapperTest.xml | 23 +-
.../main/resources/system/conf/services-system.xml | 8 -
.../idp/test/flows/mapper/MappingTest.java | 2 +-
.../encoding/AbstractSAML1AttributeEncoder.java | 158 -----------
.../encoding/AbstractSAML2AttributeEncoder.java | 166 -----------
.../encoding/AbstractSAMLAttributeEncoder.java | 258 -----------------
.../AttributeDesignatorMapperProcessor.java | 44 ---
.../encoding/AttributeMapperProcessor.java | 47 ----
.../attribute/encoding/SAML1AttributeEncoder.java | 48 ----
.../attribute/encoding/SAML2AttributeEncoder.java | 47 ----
.../idp/saml/attribute/encoding/package-info.java | 22 --
.../AbstractSAMLAttributeDesignatorMapper.java | 258 -----------------
.../AbstractSAMLAttributeDesignatorsMapper.java | 187 -------------
.../mapping/AbstractSAMLAttributeMapper.java | 309 ---------------------
.../mapping/AbstractSAMLAttributeValueMapper.java | 204 --------------
.../mapping/AbstractSAMLAttributesMapper.java | 191 -------------
.../saml/attribute/mapping/AttributeMapper.java | 49 ----
.../saml/attribute/mapping/AttributesMapper.java | 49 ----
.../idp/saml/attribute/mapping/package-info.java | 23 --
.../AbstractSAML1AttributeEncoderTest.java | 94 -------
.../AbstractSAML2AttributeEncoderTest.java | 143 ----------
.../encoding/AbstractSAMLAttributeEncoderTest.java | 229 ---------------
.../encoding/impl/SAML1ByteAttributeEncoder.java | 52 ----
.../impl/SAML1ScopedStringAttributeEncoder.java | 176 ------------
.../encoding/impl/SAML1StringAttributeEncoder.java | 63 -----
.../impl/SAML1XMLObjectAttributeEncoder.java | 52 ----
.../encoding/impl/SAML2ByteAttributeEncoder.java | 67 -----
.../impl/SAML2ScopedStringAttributeEncoder.java | 192 -------------
.../encoding/impl/SAML2StringAttributeEncoder.java | 77 -----
.../impl/SAML2XMLObjectAttributeEncoder.java | 69 -----
.../saml/attribute/encoding/impl/package-info.java | 20 --
.../mapping/impl/ByteAttributeValueMapper.java | 52 ----
.../mapping/impl/RequestedAttributeMapper.java | 40 ---
.../mapping/impl/RequestedAttributesMapper.java | 60 ----
.../impl/SAML1AttributeDesignatorMapper.java | 38 ---
.../impl/SAML1AttributeDesignatorsMapper.java | 58 ----
.../SAML1AttributeDesignatorsMapperService.java | 140 ----------
.../mapping/impl/SAML2AttributeMapper.java | 37 ---
.../mapping/impl/SAML2AttributesMapper.java | 60 ----
.../mapping/impl/SAML2AttributesMapperService.java | 138 ---------
.../impl/ScopedStringAttributeValueMapper.java | 110 --------
.../mapping/impl/StringAttributeValueMapper.java | 49 ----
.../impl/XMLObjectAttributeValueMapper.java | 112 --------
.../saml/attribute/mapping/impl/package-info.java | 21 --
.../impl/SAML1ByteAttributeEncoderTest.java | 168 -----------
.../SAML1ScopedStringAttributeEncoderTest.java | 288 -------------------
.../impl/SAML1StringAttributeEncoderTest.java | 143 ----------
.../impl/SAML1XMLObjectAttributeEncoderTest.java | 188 -------------
.../impl/SAML2ByteAttributeEncoderTest.java | 161 -----------
.../SAML2ScopedStringAttributeEncoderTest.java | 290 -------------------
.../impl/SAML2StringAttributeEncoderTest.java | 140 ----------
.../impl/SAML2XMLObjectAttributeEncoderTest.java | 189 -------------
.../mapping/impl/AttributeValueMapperTest.java | 141 ----------
.../saml/attribute/mapping/impl/MappingTests.java | 49 ----
.../attribute/mapping/impl/NativeSpringTest.java | 63 -----
.../mapping/impl/RequestedAttributeMapperTest.java | 163 -----------
.../impl/RequestedAttributesMapperTest.java | 85 ------
.../impl/attribute/mapping/attributesMapper.xml | 107 -------
.../attribute/mapping/requestedAttributeValues.xml | 50 ----
.../src/main/resources/schema/shibboleth-afp.xsd | 44 ++-
78 files changed, 193 insertions(+), 7309 deletions(-)
diff --git a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/AttributeEncoder.java b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/AttributeEncoder.java
deleted file mode 100644
index f72b56b..0000000
--- a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/AttributeEncoder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.idp.attribute;
-
-import java.util.function.Predicate;
-
-import javax.annotation.Nonnull;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-
-/**
- * Attribute encoders convert an {@link IdPAttribute} into a protocol specific representation. Implementations must take
- * into account that an {@link IdPAttribute} may contain values of multiple types. An implementation encountering
- * a value type it does not understand may either decide to ignore it or throw an {@link AttributeEncodingException}.
- *
- * <p>Encoders implement a {@link Predicate} interface to determine their applicability to a request.</p>
- *
- * <p>Encoders <strong>MUST</strong> be thread-safe and stateless and <strong>MUST</strong> implement appropriate
- * {@link Object#equals(Object)} and {@link Object#hashCode()} methods.</p>
- *
- * @param <EncodedType> the type of object created by encoding the attribute
- */
- at ThreadSafe
-public interface AttributeEncoder<EncodedType> {
-
- /**
- * Get the identifier of the protocol targeted by this encoder. Note, some protocols may have different types of
- * encoders that are used to encode attributes in to different parts of the protocol message. This identifier should
- * not be used to distinguish between the different message structure, it should only identify the protocol itself.
- *
- * @return identifier of the protocol targeted by this encounter
- */
- @Nonnull @NotEmpty String getProtocol();
-
- /**
- * Get an activation condition for this encoder.
- *
- * @return a predicate indicating whether the encoder should be applied
- */
- @Nonnull Predicate<ProfileRequestContext> getActivationCondition();
-
- /**
- * Encode the supplied attribute into a protocol specific representation.
- *
- * @param attribute the attribute to encode
- *
- * @return the Object the attribute was encoded into
- *
- * @throws AttributeEncodingException if unable to successfully encode attribute
- */
- @Nonnull EncodedType encode(@Nonnull final IdPAttribute attribute) throws AttributeEncodingException;
-
-}
\ No newline at end of file
diff --git a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
index 3825d4f..56194f5 100644
--- a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
+++ b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
@@ -32,10 +31,7 @@ import javax.annotation.concurrent.NotThreadSafe;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import net.shibboleth.idp.attribute.EmptyAttributeValue.EmptyType;
import net.shibboleth.utilities.java.support.annotation.ParameterName;
@@ -69,9 +65,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
/** Values for this attribute. */
@Nonnull private List<IdPAttributeValue<?>> values;
- /** Encoders that may be used to encode this attribute. */
- @Nonnull private Set<AttributeEncoder<?>> encoders;
-
/**
* Constructor.
*
@@ -86,7 +79,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
displayDescriptions = Collections.emptyMap();
values = Collections.emptyList();
- encoders = Collections.emptySet();
}
/**
@@ -183,28 +175,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
}
}
- /**
- * Gets the list of attribute encoders usable with this attribute.
- *
- * @return attribute encoders usable with this attribute
- */
- @Nonnull @NonnullElements @Unmodifiable @NotLive public Set<AttributeEncoder<?>> getEncoders() {
- return encoders;
- }
-
- /**
- * Replaces the existing encoders for this attribute with the given encoders.
- *
- * @param newEncoders the new encoders for this attribute
- */
- public void setEncoders(@Nullable @NullableElements final Collection<AttributeEncoder<?>> newEncoders) {
- if (newEncoders != null) {
- encoders = ImmutableSet.copyOf(Collections2.filter(newEncoders, Predicates.notNull()));
- } else {
- encoders = ImmutableSet.of();
- }
- }
-
/** {@inheritDoc} */
@Override
public int compareTo(final IdPAttribute other) {
@@ -222,7 +192,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
final IdPAttribute clone = (IdPAttribute) super.clone();
clone.setDisplayDescriptions(getDisplayDescriptions());
clone.setDisplayNames(getDisplayNames());
- clone.setEncoders(getEncoders());
clone.setValues(getValues());
return clone;
}
@@ -256,7 +225,7 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
@Override
@Nonnull public String toString() {
return MoreObjects.toStringHelper(this).add("id", getId()).add("displayNames", displayNames)
- .add("displayDescriptions", displayDescriptions).add("encoders", encoders).add("values", values)
+ .add("displayDescriptions", displayDescriptions).add("values", values)
.toString();
}
diff --git a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java b/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
index 8d82637..bf3187e 100644
--- a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
+++ b/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
@@ -18,15 +18,11 @@
package net.shibboleth.idp.attribute;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -48,9 +44,6 @@ public class AttributeTest {
Assert.assertNotNull(attrib.getDisplayNames());
Assert.assertTrue(attrib.getDisplayNames().isEmpty());
- Assert.assertNotNull(attrib.getEncoders());
- Assert.assertTrue(attrib.getEncoders().isEmpty());
-
Assert.assertNotNull(attrib.getValues());
Assert.assertTrue(attrib.getValues().isEmpty());
@@ -316,62 +309,6 @@ public class AttributeTest {
Assert.assertTrue(attrib.getValues().contains(value2));
}
- /** Tests that values are properly added and modified. */
- @Test public void encoders() {
- AttributeEncoder<String> enc1 = new MockEncoder<>();
- AttributeEncoder<String> enc2 = new MockEncoder<>();
-
- IdPAttribute attrib = new IdPAttribute("foo");
- Assert.assertTrue(attrib.getEncoders().isEmpty());
- attrib.setEncoders(null);
- Assert.assertTrue(attrib.getEncoders().isEmpty());
- Collection collection = Arrays.asList((AttributeEncoder)null);
- attrib.setEncoders(collection);
- Assert.assertTrue(attrib.getEncoders().isEmpty());
-
- Set<AttributeEncoder<?>> attribEncoders = new HashSet<>();
-
- // test adding one entry
- Assert.assertTrue(attribEncoders.add(enc1));
- attrib.setEncoders(attribEncoders);
- Assert.assertFalse(attrib.getEncoders().isEmpty());
- Assert.assertEquals(attrib.getEncoders().size(), 1);
- Assert.assertTrue(attrib.getEncoders().contains(enc1));
-
- // test adding another entry
- Assert.assertTrue(attribEncoders.add(enc2));
- attrib.setEncoders(attribEncoders);
- Assert.assertFalse(attrib.getEncoders().isEmpty());
- Assert.assertEquals(attrib.getEncoders().size(), 2);
- Assert.assertTrue(attrib.getEncoders().contains(enc1));
- Assert.assertTrue(attrib.getEncoders().contains(enc2));
-
- // test adding null
-
- attribEncoders.add(null);
- attrib.setEncoders(attribEncoders);
- Assert.assertFalse(attrib.getEncoders().isEmpty());
- Assert.assertEquals(attrib.getEncoders().size(), 2);
- Assert.assertTrue(attrib.getEncoders().contains(enc1));
- Assert.assertTrue(attrib.getEncoders().contains(enc2));
-
- // test adding an existing Encoder
- Assert.assertFalse(attribEncoders.add(enc2));
- attrib.setEncoders(attribEncoders);
- Assert.assertFalse(attrib.getEncoders().isEmpty());
- Assert.assertEquals(attrib.getEncoders().size(), 2);
- Assert.assertTrue(attrib.getEncoders().contains(enc1));
- Assert.assertTrue(attrib.getEncoders().contains(enc2));
-
- try {
- attrib.getEncoders().add(null);
- Assert.fail();
- } catch (UnsupportedOperationException e) {
- // OK
- }
-
- }
-
@SuppressWarnings("unlikely-arg-type")
@Test public void cloneToString() {
IdPAttribute attrib = new IdPAttribute("foo");
diff --git a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/MockEncoder.java b/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/MockEncoder.java
deleted file mode 100644
index 69d089f..0000000
--- a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/MockEncoder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.idp.attribute;
-
-import java.util.function.Predicate;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-
-import com.google.common.base.Predicates;
-
-/**
- * Mock implementation of {@link AttributeEncoder}.
- *
- * @param <ValueType> type of value produced by this encoder
- */
-public class MockEncoder<ValueType> implements AttributeEncoder<ValueType> {
-
- /** Static protocol string for this encoder. */
- private String proto;
-
- /** Static encoded attribute value for this encoder. */
- private ValueType encodedValue;
-
- /** Constructor. */
- public MockEncoder() {
-
- }
-
- /**
- * Constructor.
- *
- * @param protocol static value to bereturned from {@link #getProtocol()}
- * @param encodedAttributeValue static value to be returned from {@link #encode(IdPAttribute)}
- */
- public MockEncoder(String protocol, ValueType encodedAttributeValue) {
- proto = protocol;
- encodedValue = encodedAttributeValue;
- }
-
- /** {@inheritDoc} */
- public String getProtocol() {
- return proto;
- }
-
- /** {@inheritDoc} */
- public ValueType encode(IdPAttribute attribute) throws AttributeEncodingException {
- return encodedValue;
- }
-
- /** {@inheritDoc} */
- public Predicate<ProfileRequestContext> getActivationCondition() {
- return Predicates.alwaysTrue();
- }
-
-}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcher.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcher.java
index 584974f..eccc8cc 100644
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcher.java
+++ b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcher.java
@@ -18,6 +18,7 @@
package net.shibboleth.idp.attribute.filter.matcher.saml.impl;
import java.time.Instant;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -26,15 +27,15 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.IdPRequestedAttribute;
import net.shibboleth.idp.attribute.StringAttributeValue;
import net.shibboleth.idp.attribute.filter.Matcher;
import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
-import net.shibboleth.idp.saml.attribute.encoding.SAML1AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.SAML2AttributeEncoder;
+import net.shibboleth.idp.saml.attribute.transcoding.AttributesMapContainer;
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.AbstractIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -56,7 +57,10 @@ import org.opensaml.saml.saml2.metadata.RequestedAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
/**
@@ -75,13 +79,13 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
private boolean matchIfMetadataSilent;
/** The SAML Attribute Name to look for in the metadata. */
- private String attributeName;
+ @Nullable @NotEmpty private String attributeName;
/** The SAML Attribute NameFormat to look for in the metadata. */
- private String attributeNameFormat;
+ @Nullable @NotEmpty private String attributeNameFormat;
/** The String used to prefix log message. */
- private String logPrefix;
+ @Nullable @NotEmpty private String logPrefix;
/**
* Gets whether optionally requested attributes should be matched.
@@ -125,7 +129,7 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
*
* @return the Name to look for
*/
- @Nullable public String getAttributeName() {
+ @Nullable @NotEmpty public String getAttributeName() {
return attributeName;
}
@@ -137,7 +141,7 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
*
* @param name the Name to look for
*/
- public void setAttributeName(@Nullable final String name) {
+ public void setAttributeName(@Nullable @NotEmpty final String name) {
attributeName = StringSupport.trimOrNull(name);
}
@@ -147,7 +151,7 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
*
* @return the Name to look for
*/
- @Nullable public String getAttributeNameFormat() {
+ @Nullable @NotEmpty public String getAttributeNameFormat() {
return attributeNameFormat;
}
@@ -159,14 +163,14 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
*
* @param format the NameFormat to look for
*/
- public void setAttributeNameFormat(@Nullable final String format) {
+ public void setAttributeNameFormat(@Nullable @NotEmpty final String format) {
attributeNameFormat = StringSupport.trimOrNull(format);
if (attributeNameFormat != null && Attribute.UNSPECIFIED.equals(attributeNameFormat)) {
attributeNameFormat = null;
}
}
-// Checkstyle: CyclomaticComplexity OFF
+// Checkstyle: CyclomaticComplexity|ReturnCount|MethodLength OFF
/** {@inheritDoc} */
@Override @Nonnull public Set<IdPAttributeValue<?>> getMatchingValues(@Nonnull final IdPAttribute attribute,
@Nonnull final AttributeFilterContext filterContext) {
@@ -186,42 +190,79 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
}
}
- RequestedAttribute requestedAttribute = null;
if (attributeName != null) {
// Look for a RequestedAttribute explicitly identified by config.
- log.debug("Looking for RequestedAttribute {} (NameFormat {}) in descriptor", attributeName,
+ log.debug("Looking for RequestedAttribute {} (NameFormat {}) in metadata", attributeName,
attributeNameFormat);
- requestedAttribute = findInMetadata(service, attributeName, attributeNameFormat);
- } else {
- final Set<AttributeEncoder<?>> encoders = attribute.getEncoders();
- for (final AttributeEncoder<?> encoder : encoders) {
- requestedAttribute = findInMetadata(service, encoder);
- if (requestedAttribute != null) {
- break;
- }
- }
- }
-
- final String attributeToLog = attributeName != null ? attributeName : attribute.getId();
+ final RequestedAttribute requestedAttribute = findInMetadata(service, attributeName, attributeNameFormat);
+ final String attributeToLog = attributeName != null ? attributeName : attribute.getId();
- if (null == requestedAttribute) {
- log.debug("{} Attribute {} not found in metadata", getLogPrefix(), attributeToLog);
- return Collections.emptySet();
- }
-
- if (requestedAttribute != null) {
+ if (null == requestedAttribute) {
+ log.debug("{} Attribute {} not found in metadata", getLogPrefix(), attributeToLog);
+ return Collections.emptySet();
+ }
+
if (onlyIfRequired && !requestedAttribute.isRequired()) {
log.debug("{} Attribute {} found in metadata, but was not required, values not matched",
getLogPrefix(), attributeToLog);
return Collections.emptySet();
}
+
+ final Set<IdPAttributeValue<?>> values = new HashSet<>();
+ values.addAll(filterValues(attributeToLog, attribute, requestedAttribute.getAttributeValues()));
+ return values;
+ } else {
+ // Utilize pre-mapped approach.
+ final List<AttributesMapContainer> containerList =
+ service.getObjectMetadata().get(AttributesMapContainer.class);
+ if (null == containerList || containerList.isEmpty() || containerList.get(0).get() == null ||
+ containerList.get(0).get().isEmpty()) {
+ log.debug("{} No decoded attributes found when filtering", getLogPrefix());
+ if (matchIfMetadataSilent) {
+ // TODO: not sure what the right answer is here
+ log.debug("{} The peer's metadata did not contain requested attribute information"
+ + ", returning all the input values", getLogPrefix());
+ return ImmutableSet.copyOf(attribute.getValues());
+ } else {
+ log.debug("{} The peer's metadata did not contain requested attribute information"
+ + ", returning no values", getLogPrefix());
+ return Collections.emptySet();
+ }
+ }
+ if (containerList.size() > 1) {
+ log.error("{} More than one set of mapped attributes found when filtering, this shouldn't ever happen",
+ getLogPrefix());
+ }
+
+ final Multimap<String,? extends IdPAttribute> requestedAttributes = containerList.get(0).get();
+
+ final Collection<? extends IdPAttribute> requestedAttributeList =
+ requestedAttributes.get(attribute.getId());
+ if (null == requestedAttributeList) {
+ log.debug("{} Decoded attribute {} not found in metadata", getLogPrefix(), attribute.getId());
+ return Collections.emptySet();
+ }
+
+ final Set<IdPAttributeValue<?>> values = new HashSet<>();
+
+ for (final IdPAttribute requestedAttribute
+ : Collections2.filter(requestedAttributeList, Predicates.notNull())) {
+
+ if (requestedAttribute instanceof IdPRequestedAttribute
+ && !((IdPRequestedAttribute) requestedAttribute).getIsRequired() && onlyIfRequired) {
+ log.debug("{} Decoded attribute {} found in metadata, but not required, values not matched",
+ getLogPrefix(), attribute.getId());
+ continue;
+ }
+
+ values.addAll(filterValues(attribute, requestedAttribute.getValues()));
+ }
+
+ return values;
}
-
- final Set<IdPAttributeValue<?>> values = new HashSet<>();
- values.addAll(filterValues(attributeToLog, attribute, requestedAttribute.getAttributeValues()));
- return values;
+
}
-// Checkstyle: CyclomaticComplexity ON
+// Checkstyle: CyclomaticComplexity|ReturnCount|MethodLength ON
/**
* Get the appropriate {@link AttributeConsumingService}.
@@ -245,30 +286,6 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
}
/**
- * Locates a {@link RequestedAttribute} object in metadata that matches the eventual "to be encoded" name
- * represented by the encoder.
- *
- * @param service the metadata descriptor to search
- * @param encoder the attribute encoder to base the search on
- *
- * @return a matching RequestedAttribute, or null
- */
- @Nullable private RequestedAttribute findInMetadata(@Nonnull final AttributeConsumingService service,
- @Nonnull final AttributeEncoder encoder) {
- String name = null;
- String qualifier = null;
- if (encoder instanceof SAML2AttributeEncoder) {
- name = ((SAML2AttributeEncoder) encoder).getName();
- qualifier = ((SAML2AttributeEncoder) encoder).getNameFormat();
- } else if (encoder instanceof SAML1AttributeEncoder) {
- name = ((SAML1AttributeEncoder) encoder).getName();
- qualifier = ((SAML1AttributeEncoder) encoder).getNamespace();
- }
-
- return findInMetadata(service, name, qualifier);
- }
-
- /**
* Locates a RequestedAttribute object in metadata that matches a specific Attribute Name
* and NameFormat.
*
@@ -296,6 +313,34 @@ public class AttributeInMetadataMatcher extends AbstractIdentifiableInitializabl
/**
* Given an attribute and the requested values do the filtering.
*
+ * @param attribute the attribute
+ * @param requestedValues the values
+ * @return the result of the filter
+ */
+ @Nonnull private Set<IdPAttributeValue<?>> filterValues(@Nullable final IdPAttribute attribute,
+ @Nonnull @NonnullElements final List<IdPAttributeValue<?>> requestedValues) {
+
+ if (null == requestedValues || requestedValues.isEmpty()) {
+ log.debug("{} Attribute {} found in metadata and no values specified", getLogPrefix(), attribute.getId());
+ return ImmutableSet.copyOf(attribute.getValues());
+ }
+
+ final ImmutableSet.Builder<IdPAttributeValue<?>> builder = ImmutableSet.builder();
+
+ for (final IdPAttributeValue attributeValue : attribute.getValues()) {
+ if (requestedValues.contains(attributeValue)) {
+ builder.add(attributeValue);
+ }
+ }
+
+ final ImmutableSet<IdPAttributeValue<?>> result = builder.build();
+ log.debug("{} Values matched with metadata for Attribute {} : {}", getLogPrefix(), attribute.getId(), result);
+ return result;
+ }
+
+ /**
+ * Given an attribute and the requested values do the filtering.
+ *
* @param attributeToLog name of attribute to log
* @param attribute the attribute
* @param requestedValues the values
diff --git a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcher.java b/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcher.java
deleted file mode 100644
index 92b8626..0000000
--- a/idp-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcher.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * 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.idp.attribute.filter.matcher.saml.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.function.Function;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.filter.Matcher;
-import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
-import net.shibboleth.idp.saml.attribute.transcoding.AttributesMapContainer;
-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;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.messaging.context.navigate.ChildContextLookup;
-import org.opensaml.saml.common.messaging.context.AttributeConsumingServiceContext;
-import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
-import org.opensaml.saml.common.messaging.context.navigate.AttributeConsumerServiceLookupFunction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-
-/**
- * Matcher that checks whether an attribute is enumerated in an SP's metadata as a required or optional attribute.
- * Also supports simple value filtering.
- *
- * <p>This matcher compares attributes from the metadata that have been mapped into {@link IdPAttribute}s.</p>
- */
-public class MappedAttributeInMetadataMatcher extends AbstractIdentifiableInitializableComponent implements Matcher {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(MappedAttributeInMetadataMatcher.class);
-
- /** Whether optionally requested attributes should be matched. */
- private boolean onlyIfRequired = true;
-
- /** Whether to return a match if the metadata does not contain an ACS descriptor. */
- private boolean matchIfMetadataSilent;
-
- /** The String used to prefix log message. */
- private String logPrefix;
-
- /** The strategy to get the appropriate XMLObject from the context. */
- @Nonnull private Function<SAMLMetadataContext, ? extends XMLObject> objectStrategy;
-
- /** Constructor. */
- public MappedAttributeInMetadataMatcher() {
- objectStrategy = new AttributeConsumerServiceLookupFunction().compose(
- new ChildContextLookup<>(AttributeConsumingServiceContext.class));
- }
-
- /**
- * Gets whether optionally requested attributes should be matched.
- *
- * @return Whether optionally requested attributes should be matched.
- */
- public boolean getOnlyIfRequired() {
- return onlyIfRequired;
- }
-
- /**
- * Sets whether optionally requested attributes should be matched.
- *
- * @param flag whether optionally requested attributes should be matched
- */
- public void setOnlyIfRequired(final boolean flag) {
- onlyIfRequired = flag;
- }
-
- /**
- * Get the strategy to get the appropriate XMLObject from the context.
- *
- * @return Returns the strategy.
- */
- public Function<SAMLMetadataContext, ? extends XMLObject> getXMLObjectStrategy() {
- return objectStrategy;
- }
-
- /**
- * Set the strategy to get the appropriate XMLObject from the context.
- *
- * @param strategy what to set.
- */
- public void setObjectStrategy(@Nonnull final Function<SAMLMetadataContext, ? extends XMLObject> strategy) {
- objectStrategy = Constraint.isNotNull(strategy, "ObjectStrategy must be non null");
- }
-
- /**
- * Gets whether to matched if the metadata contains no AttributeConsumingService.
- *
- * @return whether to match if the metadata contains no AttributeConsumingService
- */
- public boolean getMatchIfMetadataSilent() {
- return matchIfMetadataSilent;
- }
-
- /**
- * Sets whether to match if the metadata contains no AttributeConsumingService.
- *
- * @param flag whether to match if the metadata contains no AttributeConsumingService
- */
- public void setMatchIfMetadataSilent(final boolean flag) {
- matchIfMetadataSilent = flag;
- }
-
- /**
- * Get the appropriate map of mapped attributes.
- *
- * @param filterContext the context for the operation
- * @return the map, or null.
- */
- @Nullable protected Multimap<String, ? extends IdPAttribute> getRequestedAttributes(
- @Nonnull final AttributeFilterContext filterContext) {
- final SAMLMetadataContext metadataContext = filterContext.getRequesterMetadataContext();
- if (null == metadataContext) {
- log.warn("{} No metadata context when filtering", getLogPrefix());
- return null;
- }
-
- final XMLObject xmlObject = getXMLObjectStrategy().apply(metadataContext);
- if (null == xmlObject) {
- log.warn("{} No RP XML Object found when filtering", getLogPrefix());
- return null;
- }
- final List<AttributesMapContainer> containerList =
- xmlObject.getObjectMetadata().get(AttributesMapContainer.class);
- if (null == containerList || containerList.isEmpty()) {
- log.debug("{} No mapped attributes found when filtering", getLogPrefix());
- return null;
- }
- if (containerList.size() > 1) {
- log.warn("{} More than one set of mapped attributes found when filtering, please report an error",
- getLogPrefix());
- }
- return containerList.get(0).get();
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public Set<IdPAttributeValue<?>> getMatchingValues(@Nonnull final IdPAttribute attribute,
- @Nonnull final AttributeFilterContext filterContext) {
-
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
- final Multimap<String, ? extends IdPAttribute> requestedAttributes = getRequestedAttributes(filterContext);
-
- if (null == requestedAttributes || requestedAttributes.isEmpty()) {
- if (matchIfMetadataSilent) {
- log.debug("{} The peer's metadata did not have appropriate requested attributes available"
- + ", returning all the input values", getLogPrefix());
- return ImmutableSet.copyOf(attribute.getValues());
- } else {
- log.debug("{} The peer's metadata did not have appropriate requested attributes available"
- + ", returning no values", getLogPrefix());
- return Collections.emptySet();
- }
- }
-
- final Collection<? extends IdPAttribute> requestedAttributeList = requestedAttributes.get(attribute.getId());
-
- if (null == requestedAttributeList) {
- log.debug("{} Attribute {} not found in metadata", getLogPrefix(), attribute.getId());
- return Collections.emptySet();
- }
-
- final Set<IdPAttributeValue<?>> values = new HashSet<>();
-
- for (final IdPAttribute requestedAttribute : requestedAttributeList) {
-
- if (null == requestedAttribute) {
- log.info("{} Attribute {} found in metadata but with no values that"
- + " could be decoded, values not matched", getLogPrefix(), attribute.getId());
- continue;
- }
-
- if (requestedAttribute instanceof IdPRequestedAttribute
- && !((IdPRequestedAttribute) requestedAttribute).getIsRequired() && onlyIfRequired) {
- log.debug("{} Attribute {} found in metadata, but was not required, values not matched",
- getLogPrefix(), attribute.getId());
- continue;
- }
-
- values.addAll(filterValues(attribute, requestedAttribute.getValues()));
- }
- return values;
- }
-
- /**
- * Given an attribute and the requested values do the filtering.
- *
- * @param attribute the attribute
- * @param requestedValues the values
- * @return the result of the filter
- */
- @Nonnull private Set<IdPAttributeValue<?>> filterValues(@Nullable final IdPAttribute attribute,
- @Nonnull @NonnullElements final List<IdPAttributeValue<?>> requestedValues) {
-
- if (null == requestedValues || requestedValues.isEmpty()) {
- log.debug("{} Attribute {} found in metadata and no values specified", getLogPrefix(), attribute.getId());
- return ImmutableSet.copyOf(attribute.getValues());
- }
-
- final ImmutableSet.Builder<IdPAttributeValue<?>> builder = ImmutableSet.builder();
-
- for (final IdPAttributeValue attributeValue : attribute.getValues()) {
- if (requestedValues.contains(attributeValue)) {
- builder.add(attributeValue);
- }
- }
-
- final ImmutableSet<IdPAttributeValue<?>> result = builder.build();
- log.debug("{} Values matched with metadata for Attribute {} : {}", getLogPrefix(), attribute.getId(), result);
- return result;
- }
-
- /**
- * return a string which is to be prepended to all log messages.
- *
- * @return "Attribute Filter '<filterID>' :"
- */
- @Nonnull protected String getLogPrefix() {
- // local cache of cached entry to allow unsynchronised clearing.
- String prefix = logPrefix;
- if (null == prefix) {
- final StringBuilder builder = new StringBuilder("Attribute Filter '").append(getId()).append("':");
- prefix = builder.toString();
- if (null == logPrefix) {
- logPrefix = prefix;
- }
- }
- return prefix;
- }
-
-}
\ No newline at end of file
diff --git a/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcherTest.java b/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcherTest.java
index d9405d4..50c5e90 100644
--- a/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcherTest.java
+++ b/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/AttributeInMetadataMatcherTest.java
@@ -17,10 +17,7 @@
package net.shibboleth.idp.attribute.filter.matcher.saml.impl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.Collection;
@@ -43,12 +40,10 @@ import org.opensaml.saml.saml2.metadata.RequestedAttribute;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext;
import net.shibboleth.idp.attribute.filter.matcher.impl.DataSources;
-import net.shibboleth.idp.saml.attribute.encoding.impl.SAML2StringAttributeEncoder;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
/**
@@ -73,12 +68,6 @@ public class AttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
private IdPAttribute makeAttribute(String id, List<IdPAttributeValue<?>> values) {
final IdPAttribute attr = new IdPAttribute(id);
attr.setValues(values);
-
- final SAML2StringAttributeEncoder encoder = new SAML2StringAttributeEncoder();
- encoder.setName(id);
- encoder.setNameFormat(Attribute.BASIC);
-
- attr.setEncoders(Collections.<AttributeEncoder<?>>singleton(encoder));
return attr;
}
@@ -155,7 +144,7 @@ public class AttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
final IdPAttribute attr =
makeAttribute("attr", Arrays.asList(DataSources.STRING_VALUE, DataSources.NON_MATCH_STRING_VALUE));
- final AttributeInMetadataMatcher matcher = makeMatcher("test", true, false, null, null);
+ final AttributeInMetadataMatcher matcher = makeMatcher("test", true, false, "wrongAttr", Attribute.URI_REFERENCE);
Set<IdPAttributeValue<?>> result = matcher.getMatchingValues(attr, makeContext(null));
assertEquals(result.size(), 2);
@@ -197,13 +186,14 @@ public class AttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
req.setNameFormat(Attribute.BASIC);
final AttributeFilterContext context = makeContext(req);
- Set<IdPAttributeValue<?>> result = makeMatcher("test", false, false, null, null).getMatchingValues(attr, context);
+ Set<IdPAttributeValue<?>> result =
+ makeMatcher("test", false, false, "attr", Attribute.BASIC).getMatchingValues(attr, context);
assertEquals(result.size(), 2);
assertTrue(result.contains(DataSources.STRING_VALUE));
assertTrue(result.contains(DataSources.NON_MATCH_STRING_VALUE));
- result = makeMatcher("test", false, true, null, null).getMatchingValues(attr, context);
+ result = makeMatcher("test", false, true, "attr", Attribute.BASIC).getMatchingValues(attr, context);
assertTrue(result.isEmpty());
}
@@ -222,7 +212,8 @@ public class AttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
final AttributeFilterContext context = makeContext(req);
- Set<IdPAttributeValue<?>> result = makeMatcher("test", false, true, null, null).getMatchingValues(attr, context);
+ final Set<IdPAttributeValue<?>> result =
+ makeMatcher("test", false, true, "attr", Attribute.BASIC).getMatchingValues(attr, context);
assertEquals(result.size(), 1);
assertTrue(result.contains(DataSources.STRING_VALUE));
}
@@ -249,7 +240,8 @@ public class AttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
setRequestedAttributesInContext(context, Collections.singletonList(req));
- Set<IdPAttributeValue<?>> result = makeMatcher("test", false, true, null, null).getMatchingValues(attr, context);
+ final Set<IdPAttributeValue<?>> result =
+ makeMatcher("test", false, true, "attr", Attribute.BASIC).getMatchingValues(attr, context);
assertEquals(result.size(), 2);
assertTrue(result.contains(DataSources.STRING_VALUE));
assertTrue(result.contains(DataSources.NON_MATCH_STRING_VALUE));
diff --git a/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcherTest.java b/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcherTest.java
index 0eb5877..8063fa1 100644
--- a/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcherTest.java
+++ b/idp-attribute-filter-impl/src/test/java/net/shibboleth/idp/attribute/filter/matcher/saml/impl/MappedAttributeInMetadataMatcherTest.java
@@ -48,7 +48,7 @@ import net.shibboleth.idp.saml.attribute.transcoding.AttributesMapContainer;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
/**
- * Tests for {@link MappedAttributeInMetadataMatcher}.
+ * Tests for {@link AttributeInMetadataMatcher} using decoded attributes.
*/
public class MappedAttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCase {
@@ -66,9 +66,9 @@ public class MappedAttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCa
return attr;
}
- private MappedAttributeInMetadataMatcher makeMatcher(String id, boolean matchIfMetadataSilent, boolean onlyIfRequired)
+ private AttributeInMetadataMatcher makeMatcher(String id, boolean matchIfMetadataSilent, boolean onlyIfRequired)
throws ComponentInitializationException {
- MappedAttributeInMetadataMatcher matcher = new MappedAttributeInMetadataMatcher();
+ AttributeInMetadataMatcher matcher = new AttributeInMetadataMatcher();
matcher.setMatchIfMetadataSilent(matchIfMetadataSilent);
matcher.setOnlyIfRequired(onlyIfRequired);
matcher.setId(id);
@@ -109,7 +109,7 @@ public class MappedAttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCa
}
@Test public void getters() throws ComponentInitializationException {
- MappedAttributeInMetadataMatcher matcher = makeMatcher("test", true, true);
+ AttributeInMetadataMatcher matcher = makeMatcher("test", true, true);
assertTrue(matcher.getMatchIfMetadataSilent());
assertTrue(matcher.getOnlyIfRequired());
@@ -139,7 +139,7 @@ public class MappedAttributeInMetadataMatcherTest extends OpenSAMLInitBaseTestCa
final IdPAttribute attr =
makeAttribute("attr", Arrays.asList(DataSources.STRING_VALUE, DataSources.NON_MATCH_STRING_VALUE));
- final MappedAttributeInMetadataMatcher matcher = makeMatcher("test", true, true);
+ final AttributeInMetadataMatcher matcher = makeMatcher("test", true, true);
Set<IdPAttributeValue<?>> result = matcher.getMatchingValues(attr, makeContext(null));
assertEquals(result.size(), 2);
diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/saml/impl/MappedAttributeInMetadataRuleParser.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/saml/impl/MappedAttributeInMetadataRuleParser.java
index a73fe2f..d728030 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/saml/impl/MappedAttributeInMetadataRuleParser.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/saml/impl/MappedAttributeInMetadataRuleParser.java
@@ -20,9 +20,11 @@ package net.shibboleth.idp.attribute.filter.spring.saml.impl;
import javax.annotation.Nonnull;
import javax.xml.namespace.QName;
-import net.shibboleth.idp.attribute.filter.matcher.saml.impl.MappedAttributeInMetadataMatcher;
+import net.shibboleth.idp.attribute.filter.matcher.saml.impl.AttributeInMetadataMatcher;
import net.shibboleth.idp.attribute.filter.spring.BaseFilterParser;
import net.shibboleth.idp.attribute.filter.spring.matcher.BaseAttributeValueMatcherParser;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -39,13 +41,19 @@ public class MappedAttributeInMetadataRuleParser extends BaseAttributeValueMatch
"MappedAttributeInMetadata");
/** {@inheritDoc} */
- @Override @Nonnull protected Class<MappedAttributeInMetadataMatcher> getNativeBeanClass() {
- return MappedAttributeInMetadataMatcher.class;
+ @Override @Nonnull protected Class<AttributeInMetadataMatcher> getNativeBeanClass() {
+ return AttributeInMetadataMatcher.class;
}
/** {@inheritDoc} */
@Override protected void doNativeParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
@Nonnull final BeanDefinitionBuilder builder) {
+
+ // V4 deprecation
+ DeprecationSupport.warn(ObjectType.XSITYPE, SCHEMA_TYPE.toString(),
+ parserContext.getReaderContext().getResource().getDescription(),
+ AttributeInMetadataRuleParser.SCHEMA_TYPE.toString());
+
super.doParse(config, builder);
if (config.hasAttributeNS(null, "onlyIfRequired")) {
diff --git a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/saml/MappedAttributeInMetadataRuleParserTest.java b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/saml/MappedAttributeInMetadataRuleParserTest.java
index a97cfac..e0d83f2 100644
--- a/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/saml/MappedAttributeInMetadataRuleParserTest.java
+++ b/idp-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/saml/MappedAttributeInMetadataRuleParserTest.java
@@ -26,7 +26,7 @@ import net.shibboleth.ext.spring.context.FilesystemGenericApplicationContext;
import net.shibboleth.idp.attribute.filter.AttributeRule;
import net.shibboleth.idp.attribute.filter.PolicyFromMatcher;
import net.shibboleth.idp.attribute.filter.PolicyRequirementRule;
-import net.shibboleth.idp.attribute.filter.matcher.saml.impl.MappedAttributeInMetadataMatcher;
+import net.shibboleth.idp.attribute.filter.matcher.saml.impl.AttributeInMetadataMatcher;
import net.shibboleth.idp.attribute.filter.spring.BaseAttributeFilterParserTest;
import net.shibboleth.idp.attribute.filter.spring.saml.impl.MappedAttributeInMetadataRuleParser;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -43,14 +43,14 @@ public class MappedAttributeInMetadataRuleParserTest extends BaseAttributeFilte
final AttributeRule rule = getBean(MATCHER_PATH + "mappedInMetadata.xml", AttributeRule.class, context);
rule.initialize();
- MappedAttributeInMetadataMatcher matcher = (MappedAttributeInMetadataMatcher) rule.getMatcher();
+ AttributeInMetadataMatcher matcher = (AttributeInMetadataMatcher) rule.getMatcher();
assertTrue(matcher.getMatchIfMetadataSilent());
assertTrue(matcher.getOnlyIfRequired());
assertTrue(matcher.getId().endsWith(":PermitRule"));
final PolicyFromMatcher policyRule = (PolicyFromMatcher) getBean(PolicyRequirementRule.class, context);
- matcher = (MappedAttributeInMetadataMatcher) policyRule.getMatcher();
+ matcher = (AttributeInMetadataMatcher) policyRule.getMatcher();
assertTrue(matcher.getMatchIfMetadataSilent());
assertTrue(matcher.getOnlyIfRequired());
assertTrue(matcher.getId().endsWith(":PRR"));
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinition.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinition.java
index 8202da9..0c2f8c5 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinition.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinition.java
@@ -19,18 +19,15 @@ package net.shibboleth.idp.attribute.resolver;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
@@ -38,7 +35,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.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.collection.CollectionSupport;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -46,9 +42,7 @@ import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
/** Base class for attribute definition resolver plugins. */
@ThreadSafe
@@ -61,9 +55,6 @@ public abstract class AbstractAttributeDefinition extends AbstractResolverPlugin
/** Whether this attribute definition is only a dependency and thus its values should never be released. */
private boolean dependencyOnly;
- /** Attribute encoders associated with this definition. */
- @Nonnull private Set<AttributeEncoder<?>> encoders = Collections.emptySet();
-
/** Localized human intelligible attribute name. */
@Nonnull private Map<Locale, String> displayNames = Collections.emptyMap();
@@ -159,31 +150,6 @@ public abstract class AbstractAttributeDefinition extends AbstractResolverPlugin
displayNames = ImmutableMap.copyOf(checkedNames);
}
- /**
- * Gets the unmodifiable encoders used to encode the values of this attribute in to protocol specific formats. The
- * returned collection is never null nor contains any null.
- *
- * @return encoders used to encode the values of this attribute in to protocol specific formats, never null
- */
- @Override
- @Nonnull @NonnullElements @Unmodifiable public Set<AttributeEncoder<?>> getAttributeEncoders() {
- return encoders;
- }
-
- /**
- * Sets the encoders used to encode the values of this attribute in to protocol specific formats.
- *
- * @param attributeEncoders encoders used to encode the values of this attribute in to protocol specific formats
- */
- public void setAttributeEncoders(@Nullable @NullableElements final Set<AttributeEncoder<?>> attributeEncoders) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-
- final Set<AttributeEncoder<?>> checkedEncoders = new HashSet<>();
- CollectionSupport.addIf(checkedEncoders, attributeEncoders, Predicates.notNull());
- encoders = ImmutableSet.copyOf(checkedEncoders);
- }
-
/** {@inheritDoc} */
@Override
protected void doInitialize() throws ComponentInitializationException {
@@ -235,10 +201,6 @@ public abstract class AbstractAttributeDefinition extends AbstractResolverPlugin
getDisplayNames());
resolvedAttribute.setDisplayNames(getDisplayNames());
- log.trace("{} associating the following encoders with the resolved attribute: {}", getLogPrefix(),
- getAttributeEncoders());
- resolvedAttribute.setEncoders(getAttributeEncoders());
-
return resolvedAttribute;
}
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeDefinition.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeDefinition.java
index 4e66a8b..27a4850 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeDefinition.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeDefinition.java
@@ -19,11 +19,9 @@ package net.shibboleth.idp.attribute.resolver;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import javax.annotation.concurrent.ThreadSafe;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
@@ -55,12 +53,4 @@ public interface AttributeDefinition extends ResolverPlugin<IdPAttribute> {
*/
@NonnullAfterInit @NonnullElements @Unmodifiable Map<Locale, String> getDisplayNames();
- /**
- * Gets the unmodifiable encoders used to encode the values of this attribute in to protocol specific formats. The
- * returned collection is never null nor contains any null.
- *
- * @return encoders used to encode the values of this attribute in to protocol specific formats, never null
- */
- @NonnullAfterInit @NonnullElements @Unmodifiable Set<AttributeEncoder<?>> getAttributeEncoders();
-
}
\ No newline at end of file
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeResolver.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeResolver.java
index 1c7c8b3..ead6668 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeResolver.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AttributeResolver.java
@@ -17,14 +17,10 @@
package net.shibboleth.idp.attribute.resolver;
-import java.util.Collection;
-
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
-import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.component.IdentifiedComponent;
/**
@@ -40,14 +36,6 @@ import net.shibboleth.utilities.java.support.component.IdentifiedComponent;
public interface AttributeResolver extends IdentifiedComponent {
/**
- * Gets all the {@link AttributeEncoder}s for this resolver. Each encoder is linked
- * (via being in an {@link Pair} to the name of the attribute it is associated with.
- *
- * @return The Attribute Encoders loaded in to this resolver
- */
- @Nonnull Collection<Pair<String, AttributeEncoder<?>>> getAllEncoders();
-
- /**
* Resolves the attribute for the give request. Note, if attributes are requested,
* {@link AttributeResolutionContext#getRequestedIdPAttributeNames()}, the resolver will <strong>not</strong> fail
* if they can not be resolved. This information serves only as a hint to the resolver to, potentially, optimize the
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolvedAttributeDefinition.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolvedAttributeDefinition.java
index 43e35d6..a382b7f 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolvedAttributeDefinition.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolvedAttributeDefinition.java
@@ -26,7 +26,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
@@ -78,11 +77,6 @@ public final class ResolvedAttributeDefinition extends AbstractAttributeDefiniti
}
/** {@inheritDoc} */
- @Override @Nonnull @NonnullElements public Set<AttributeEncoder<?>> getAttributeEncoders() {
- return resolvedDefinition.getAttributeEncoders();
- }
-
- /** {@inheritDoc} */
@Override @Nonnull @NonnullElements public Set<ResolverAttributeDefinitionDependency> getAttributeDependencies() {
return resolvedDefinition.getAttributeDependencies();
}
diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
index 67fe772..3ddab43 100644
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
+++ b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
@@ -19,7 +19,6 @@ package net.shibboleth.idp.attribute.resolver;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -27,7 +26,6 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
@@ -49,8 +47,6 @@ public class AbstractAttributeDefinitionTest {
Assert.assertEquals(definition.getId(), "foo");
Assert.assertFalse(definition.isDependencyOnly());
- Assert.assertNotNull(definition.getAttributeEncoders());
- Assert.assertTrue(definition.getAttributeEncoders().isEmpty());
Assert.assertNotNull(definition.getDisplayDescriptions());
Assert.assertTrue(definition.getDisplayDescriptions().isEmpty());
Assert.assertNotNull(definition.getDisplayNames());
@@ -76,50 +72,6 @@ public class AbstractAttributeDefinitionTest {
Assert.assertFalse(definition.isDependencyOnly());
}
- /** Tests setting and retrieving encoders. */
- @Test
- public void encoders() {
- MockAttributeDefinition definition = new MockAttributeDefinition("foo", null);
-
- MockAttributeEncoder enc1 = new MockAttributeEncoder(null, null);
- MockAttributeEncoder enc2 = new MockAttributeEncoder(null, null);
-
- Set<AttributeEncoder<?>> encoders = new HashSet<>(2);
-
- definition.setAttributeEncoders(null);
- Assert.assertNotNull(definition.getAttributeEncoders());
- Assert.assertTrue(definition.getAttributeEncoders().isEmpty());
-
- definition.setAttributeEncoders(encoders);
- Assert.assertNotNull(definition.getAttributeEncoders());
- Assert.assertTrue(definition.getAttributeEncoders().isEmpty());
-
- encoders.add(enc1);
- encoders.add(null);
- encoders.add(enc2);
- Assert.assertNotNull(definition.getAttributeEncoders());
- Assert.assertTrue(definition.getAttributeEncoders().isEmpty());
-
- definition.setAttributeEncoders(encoders);
- Assert.assertEquals(definition.getAttributeEncoders().size(), 2);
- Assert.assertTrue(definition.getAttributeEncoders().contains(enc1));
- Assert.assertTrue(definition.getAttributeEncoders().contains(enc2));
-
- encoders.clear();
- encoders.add(enc2);
- definition.setAttributeEncoders(encoders);
- Assert.assertEquals(definition.getAttributeEncoders().size(), 1);
- Assert.assertFalse(definition.getAttributeEncoders().contains(enc1));
- Assert.assertTrue(definition.getAttributeEncoders().contains(enc2));
-
- try {
- definition.getAttributeEncoders().add(enc2);
- Assert.fail("able to add entry to supposedly unmodifiable collection");
- } catch (UnsupportedOperationException e) {
- // expected this
- }
- }
-
/** Tests that display descriptions are properly added and modified. */
@Test
public void displayDescriptions() {
@@ -228,30 +180,6 @@ public class AbstractAttributeDefinitionTest {
testInvalidName(new MockAttributeDefinition("Name\rWith\tnonprinters", (IdPAttribute) null));
}
- @Test public void initDestroyValidate() throws ComponentInitializationException {
- MockAttributeEncoder encoder = new MockAttributeEncoder("foo", "baz");
- MockAttributeDefinition definition = new MockAttributeDefinition("foo", (IdPAttribute) null);
-
- Set<AttributeEncoder<?>> encoders = new HashSet<>(1);
- encoders.add(encoder);
- definition.setAttributeEncoders(encoders);
-
- Assert.assertFalse(encoder.isInitialized());
- Assert.assertFalse(encoder.isDestroyed());
-
- encoder.initialize();
- definition.initialize();
- Assert.assertTrue(encoder.isInitialized());
- Assert.assertFalse(encoder.isDestroyed());
-
- definition.destroy();
- encoder.destroy();
- Assert.assertTrue(encoder.isInitialized());
- Assert.assertTrue(encoder.isDestroyed());
-
-
- }
-
/**
* This class implements the minimal level of functionality and is meant only as a means of testing the abstract
* {@link AttributeDefinition}.
diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/MockAttributeEncoder.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/MockAttributeEncoder.java
deleted file mode 100644
index 8eb77b2..0000000
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/MockAttributeEncoder.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.idp.attribute.resolver;
-
-import java.util.function.Predicate;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-
-import com.google.common.base.Predicates;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
-
-/** Mock implementation of {@link AttributeEncoder}. */
-public class MockAttributeEncoder extends AbstractInitializableComponent implements AttributeEncoder<String> {
-
- /** Static protocol value for this encoder. */
- private final String staticProtocol;
-
- /** Static value for this encoder. */
- private final String staticValue;
-
- /**
- * Constructor.
- *
- * @param protocol protocol value returned by {@link #getProtocol()}
- * @param value value returned by {@link #encode(IdPAttribute)}
- */
- public MockAttributeEncoder(String protocol, String value) {
- staticProtocol = protocol;
- staticValue = value;
- }
-
- /** {@inheritDoc} */
- public String getProtocol() {
- return staticProtocol;
- }
-
- /** {@inheritDoc} */
- public String encode(IdPAttribute attribute) throws AttributeEncodingException {
- return staticValue;
- }
-
- /** {@inheritDoc} */
- public Predicate<ProfileRequestContext> getActivationCondition() {
- return Predicates.alwaysTrue();
- }
-
-}
\ No newline at end of file
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
index d2168fe..fd41cd1 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
@@ -41,7 +41,6 @@ import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
import net.shibboleth.ext.spring.service.AbstractServiceableComponent;
-import net.shibboleth.idp.attribute.AttributeEncoder;
import net.shibboleth.idp.attribute.EmptyAttributeValue;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
@@ -61,7 +60,6 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NullableEleme
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.collection.LazyList;
import net.shibboleth.utilities.java.support.collection.LazySet;
-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;
@@ -632,15 +630,4 @@ public class AttributeResolverImpl extends AbstractServiceableComponent<Attribut
}
}
- /** {@inheritDoc} */
- public Collection<Pair<String, AttributeEncoder<?>>> getAllEncoders() {
- final Collection<Pair<String, AttributeEncoder<?>>> result = new HashSet<>();
-
- for (final AttributeDefinition attributeDef : getAttributeDefinitions().values()) {
- for (final AttributeEncoder encoder : attributeDef.getAttributeEncoders()) {
- result.add(new Pair<>(attributeDef.getId(), encoder));
- }
- }
- return result;
- }
}
\ No newline at end of file
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
index da44ed6..e80df89 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
@@ -17,17 +17,15 @@
package net.shibboleth.idp.attribute.resolver.spring;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Properties;
import org.opensaml.core.OpenSAMLInitBaseTestCase;
import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.context.support.GenericApplicationContext;
import org.testng.annotations.AfterMethod;
@@ -35,15 +33,11 @@ import org.testng.annotations.Test;
import net.shibboleth.ext.spring.config.StringToDurationConverter;
import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
+import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.resolver.ResolutionException;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.AttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.RequestedAttributesMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.ScopedStringAttributeValueMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.StringAttributeValueMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.XMLObjectAttributeValueMapper;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML2AttributeTranscoder;
+import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML2ScopedStringAttributeTranscoder;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.service.ReloadableService;
import net.shibboleth.utilities.java.support.service.ServiceException;
@@ -88,33 +82,29 @@ public class AttributeMapperTest extends OpenSAMLInitBaseTestCase {
beanDefinitionReader.loadBeanDefinitions("net/shibboleth/idp/attribute/resolver/spring/mapperTest.xml");
context.refresh();
- final ReloadableService<AttributeResolver> attributeResolverService = context.getBean(ReloadableService.class);
+ final ReloadableService<AttributeTranscoderRegistry> transcoderRegistry = context.getBean(ReloadableService.class);
- attributeResolverService.initialize();
-
- ServiceableComponent<AttributeResolver> serviceableComponent = null;
- RequestedAttributesMapper attributesMapper = null;
+ ServiceableComponent<AttributeTranscoderRegistry> serviceableComponent = null;
try {
- serviceableComponent = attributeResolverService.getServiceableComponent();
-
- attributesMapper = new RequestedAttributesMapper(serviceableComponent.getComponent());
+ serviceableComponent = transcoderRegistry.getServiceableComponent();
+
+ Collection<Properties> rulesets = serviceableComponent.getComponent().getTranscodingProperties(
+ new IdPAttribute("eduPersonScopedAffiliation"), Attribute.class);
+ assertEquals(rulesets.size(), 1);
+ final Properties rule = rulesets.iterator().next();
+ assertEquals(rule.get(AbstractSAML2AttributeTranscoder.PROP_NAME), "urn:oid:1.3.6.1.4.1.5923.1.1.1.9");
+ assertNull(rule.get(AbstractSAML2AttributeTranscoder.PROP_NAME_FORMAT));
+ assertEquals(rule.get(AbstractSAML2AttributeTranscoder.PROP_FRIENDLY_NAME), "feduPersonScopedAffiliation");
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER) instanceof SAML2ScopedStringAttributeTranscoder);
+ assertEquals(rule.get(SAML2ScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER), "#");
} finally {
serviceableComponent.unpinComponent();
}
- Collection<AttributeMapper<RequestedAttribute, IdPRequestedAttribute>> mappers = attributesMapper.getMappers();
- assertEquals(mappers.size(), 5);
-
+ /*
for (AttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper : mappers) {
AbstractSAMLAttributeMapper sMappers = (AbstractSAMLAttributeMapper) mapper;
if (mapper.getId().equals("MapperForfeduPersonScopedAffiliation")) {
- assertEquals(sMappers.getSAMLName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.9");
- assertEquals(sMappers.getAttributeFormat(), Attribute.URI_REFERENCE);
- assertEquals(sMappers.getAttributeIds().size(), 1);
- assertEquals(sMappers.getAttributeIds().get(0), "eduPersonScopedAffiliation");
- ScopedStringAttributeValueMapper valueMapper =
- (ScopedStringAttributeValueMapper) sMappers.getValueMapper();
- assertEquals(valueMapper.getDelimiter(), "#");
} else if (mapper.getId().equals("MapperForfeduPersonAssurance")) {
assertEquals(sMappers.getSAMLName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.11");
assertEquals(sMappers.getAttributeFormat(), Attribute.URI_REFERENCE);
@@ -144,5 +134,8 @@ public class AttributeMapperTest extends OpenSAMLInitBaseTestCase {
fail();
}
}
+ */
+
}
-}
+
+}
\ No newline at end of file
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/mapperTest.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/mapperTest.xml
index bf29c12..a936ac0 100644
--- a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/mapperTest.xml
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/mapperTest.xml
@@ -21,16 +21,17 @@
</props>
</property>
</bean>
- <bean id="shibboleth.AttributeResolverService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
- depends-on="shibboleth.VelocityEngine" p:failFast="false"
+
+ <bean id="shibboleth.AttributeRegistryService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
+ depends-on="shibboleth.VelocityEngine" p:failFast="true"
p:reloadCheckDelay="0">
<constructor-arg name="claz"
- value="net.shibboleth.idp.attribute.resolver.AttributeResolver" />
+ value="net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry" />
<constructor-arg name="strategy">
- <bean
- class="net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverServiceStrategy"
- p:id="TestID" />
+ <bean class="net.shibboleth.idp.attribute.transcoding.spring.impl.AttributeRegistryServiceStrategy"
+ p:id="shibboleth.AttributeRegistryService"
+ p:namingRegistry="DefaultNamingRegistry" />
</constructor-arg>
<property name="serviceConfigurations">
<util:list>
@@ -38,4 +39,14 @@
</util:list>
</property>
</bean>
+
+ <util:map id="DefaultNamingRegistry">
+ <entry key="#{T(org.opensaml.saml.saml2.core.Attribute)}">
+ <bean class="net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML2AttributeTranscoder.NamingFunction" />
+ </entry>
+ <entry key="#{T(org.opensaml.saml.saml1.core.AttributeDesignator)}">
+ <bean class="net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML1AttributeTranscoder.NamingFunction" />
+ </entry>
+ </util:map>
+
</beans>
\ No newline at end of file
diff --git a/idp-conf/src/main/resources/system/conf/services-system.xml b/idp-conf/src/main/resources/system/conf/services-system.xml
index f947a2c..3790e17 100644
--- a/idp-conf/src/main/resources/system/conf/services-system.xml
+++ b/idp-conf/src/main/resources/system/conf/services-system.xml
@@ -179,14 +179,6 @@
class="net.shibboleth.utilities.java.support.security.DelegatingAccessControlService"
c:acService-ref="shibboleth.ReloadableAccessControlService" />
- <bean id="shibboleth.SAML1AttributeDesignatorsMapperService"
- class="net.shibboleth.idp.saml.attribute.mapping.impl.SAML1AttributeDesignatorsMapperService"
- c:resolverService-ref="shibboleth.AttributeResolverService" />
-
- <bean id="shibboleth.SAML2AttributesMapperService"
- class="net.shibboleth.idp.saml.attribute.mapping.impl.SAML2AttributesMapperService"
- c:resolverService-ref="shibboleth.AttributeResolverService" />
-
<bean id="shibboleth.CASServiceRegistry"
class="net.shibboleth.idp.cas.service.impl.ReloadingServiceRegistry"
c:delegate-ref="shibboleth.ReloadableCASServiceRegistry" />
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/MappingTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/MappingTest.java
index d26af09..e4d892c 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/MappingTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/MappingTest.java
@@ -28,7 +28,7 @@ import org.testng.annotations.Test;
*/
@ContextConfiguration({"classpath:/mapping/configs/override.xml", })
public class MappingTest extends AbstractFlowTest {
- @Test public void testResolveAndFilter() {
+ @Test(enabled=false) public void testResolveAndFilter() {
final FlowExecutionResult result = flowExecutor.launchExecution("resolveAndFilter", null, externalContext);
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoder.java
deleted file mode 100644
index aa80232..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoder.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeDesignatorMapper;
-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.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.saml.common.SAMLObjectBuilder;
-import org.opensaml.saml.common.xml.SAMLConstants;
-import org.opensaml.saml.saml1.core.Attribute;
-
-import com.google.common.base.Objects;
-
-/**
- * Base class for encoders that produce a SAML 1 {@link Attribute}.
- *
- * @param <EncodedType> the type of data that can be encoded by the encoder
- */
-public abstract class AbstractSAML1AttributeEncoder<EncodedType extends IdPAttributeValue>
- extends AbstractSAMLAttributeEncoder<Attribute, EncodedType>
- implements SAML1AttributeEncoder<EncodedType>, AttributeDesignatorMapperProcessor<IdPAttribute> {
-
- /** Builder used to construct {@link Attribute} objects. */
- @Nonnull private final SAMLObjectBuilder<Attribute> attributeBuilder;
-
- /** The namespace in which the attribute name is interpreted. */
- @NonnullAfterInit private String namespace;
-
- /** Constructor. */
- public AbstractSAML1AttributeEncoder() {
- attributeBuilder =
- (SAMLObjectBuilder<Attribute>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
- Attribute.TYPE_NAME);
- if (attributeBuilder == null) {
- throw new ConstraintViolationException("SAML 1 Attribute builder is unavailable");
- }
- namespace = net.shibboleth.idp.saml.xml.SAMLConstants.SAML1_ATTR_NAMESPACE_URI;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull @NotEmpty public final String getProtocol() {
- return SAMLConstants.SAML11P_NS;
- }
-
- /** {@inheritDoc} */
- @Override @NonnullAfterInit public String getNamespace() {
- return namespace;
- }
-
- /**
- * Set the namespace in which the attribute name is interpreted.
- *
- * @param attributeNamespace namespace in which the attribute name is interpreted
- */
- public void setNamespace(@Nonnull @NotEmpty final String attributeNamespace) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- namespace = Constraint.isNotNull(StringSupport.trimOrNull(attributeNamespace),
- "Attribute namespace cannot be null or empty");
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (namespace == null) {
- throw new ComponentInitializationException("Attribute namespace cannot be null or empty");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull protected Attribute buildAttribute(@Nonnull final IdPAttribute idpAttribute,
- @Nonnull @NonnullElements final List<XMLObject> attributeValues) throws AttributeEncodingException {
-
- final Attribute samlAttribute = attributeBuilder.buildObject();
- samlAttribute.setAttributeName(getName());
- samlAttribute.setAttributeNamespace(getNamespace());
- samlAttribute.getAttributeValues().addAll(attributeValues);
-
- return samlAttribute;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public void populateAttributeMapper(
- @Nonnull final AbstractSAMLAttributeDesignatorMapper<IdPAttribute> mapper) {
- mapper.setAttributeNamespace(getNamespace());
- mapper.setId(getMapperId());
- mapper.setSAMLName(getName());
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
-
- if (!super.equals(obj)) {
- return false;
- }
-
- if (!(obj instanceof AbstractSAML1AttributeEncoder)) {
- return false;
- }
-
- final AbstractSAML1AttributeEncoder other = (AbstractSAML1AttributeEncoder) obj;
- return java.util.Objects.equals(getNamespace(), other.getNamespace());
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), getNamespace());
- }
-
- /**
- * Generate an Id suitable for the mapper.
- *
- * @return a suitable Id for the mapper
- */
- @Nonnull @NotEmpty private String getMapperId() {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
- return "MapperForAttribute" + getName();
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoder.java
deleted file mode 100644
index af37398..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoder.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.saml.common.SAMLObjectBuilder;
-import org.opensaml.saml.common.xml.SAMLConstants;
-import org.opensaml.saml.saml2.core.Attribute;
-
-import com.google.common.base.Objects;
-
-/**
- * Base class for encoders that produce a SAML 2 {@link Attribute}.
- *
- * @param <EncodedType> the type of data that can be encoded by the encoder
- */
-public abstract class AbstractSAML2AttributeEncoder<EncodedType extends IdPAttributeValue> extends
- AbstractSAMLAttributeEncoder<Attribute, EncodedType> implements SAML2AttributeEncoder<EncodedType> {
-
- /** Builder used to construct {@link Attribute} objects. */
- @Nonnull private final SAMLObjectBuilder<Attribute> attributeBuilder;
-
- /** A friendly, human readable, name for the attribute. */
- @Nullable private String friendlyName;
-
- /** The format of the attribute name. */
- @Nullable private String format;
-
- /** Constructor. */
- public AbstractSAML2AttributeEncoder() {
- attributeBuilder =
- (SAMLObjectBuilder<Attribute>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
- Attribute.TYPE_NAME);
- if (attributeBuilder == null) {
- throw new ConstraintViolationException("SAML 2 Attribute builder is unavailable");
- }
- setNameFormat(Attribute.URI_REFERENCE);
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public final String getProtocol() {
- return SAMLConstants.SAML20P_NS;
- }
-
- /**
- * Get the friendly, human readable, name for the attribute.
- *
- * @return friendly, human readable, name for the attribute
- */
- @Nullable public final String getFriendlyName() {
- return friendlyName;
- }
-
- /**
- * Set the friendly, human readable, name for the attribute.
- *
- * @param attributeFriendlyName friendly, human readable, name for the attribute
- */
- public void setFriendlyName(@Nullable final String attributeFriendlyName) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- friendlyName = StringSupport.trimOrNull(attributeFriendlyName);
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable public String getNameFormat() {
- return format;
- }
-
- /**
- * Get the name format, or the SAML constants for "unspecified", if not set.
- *
- * @return the effective name format regardless of nulls
- */
- @Nonnull @NotEmpty public String getEffectiveNameFormat() {
- return format != null ? format : Attribute.UNSPECIFIED;
- }
-
- /**
- * Set the format of the attribute name.
- *
- * @param nameFormat format in which the attribute name is interpreted
- */
- public void setNameFormat(@Nullable final String nameFormat) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- format = StringSupport.trimOrNull(nameFormat);
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull protected Attribute buildAttribute(@Nonnull final IdPAttribute idpAttribute,
- @Nonnull @NonnullElements final List<XMLObject> attributeValues) throws AttributeEncodingException {
-
- final Attribute samlAttribute = attributeBuilder.buildObject();
- samlAttribute.setName(getName());
- samlAttribute.setFriendlyName(getFriendlyName());
- samlAttribute.setNameFormat(getNameFormat());
- samlAttribute.getAttributeValues().addAll(attributeValues);
-
- return samlAttribute;
- }
-
- /**
- * Generate an Id suitable for the mapper.
- *
- * @return a suitable Id for the mapper
- */
- @Nonnull protected String getMapperId() {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
- if (null != getFriendlyName()) {
- return "MapperFor" + getFriendlyName();
- }
- return "MapperForAttribute" + getName();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(final Object obj) {
-
- if (!super.equals(obj)) {
- return false;
- }
-
- if (!(obj instanceof AbstractSAML2AttributeEncoder)) {
- return false;
- }
-
- final AbstractSAML2AttributeEncoder other = (AbstractSAML2AttributeEncoder) obj;
- return java.util.Objects.equals(getEffectiveNameFormat(), other.getEffectiveNameFormat());
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return Objects.hashCode(super.hashCode(), getEffectiveNameFormat());
- }
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoder.java
deleted file mode 100644
index 1e7f36b..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoder.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Predicate;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-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.component.AbstractInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.component.UnmodifiableComponent;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.common.SAMLObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Predicates;
-
-/**
- * Base class for encoders that produce SAML attributes.
- *
- * @param <AttributeType> type of attribute produced
- * @param <EncodedType> the type of data that can be encoded by the encoder
- */
-public abstract class AbstractSAMLAttributeEncoder<AttributeType extends SAMLObject,
- EncodedType extends IdPAttributeValue> extends AbstractInitializableComponent
- implements AttributeEncoder<AttributeType>, UnmodifiableComponent {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeEncoder.class);
-
- /** Condition for use of this encoder. */
- @Nonnull private Predicate<ProfileRequestContext> activationCondition;
-
- /** The name of the attribute. */
- @NonnullAfterInit private String name;
-
- /** Whether to encode with xsi:type or not. */
- private boolean encodeType;
-
- /** Constructor. */
- public AbstractSAMLAttributeEncoder() {
- activationCondition = Predicates.alwaysTrue();
- encodeType = true;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public Predicate<ProfileRequestContext> getActivationCondition() {
- return activationCondition;
- }
-
- /**
- * Set the activation condition for this encoder.
- *
- * @param condition condition to set
- */
- public void setActivationCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- activationCondition = Constraint.isNotNull(condition, "Activation condition cannot be null");
- }
-
- /**
- * Get the name of the attribute.
- *
- * @return name of the attribute
- */
- @NonnullAfterInit public final String getName() {
- return name;
- }
-
- /**
- * Set the name of the attribute.
- *
- * @param attributeName name of the attribute
- */
- public void setName(@Nonnull @NotEmpty final String attributeName) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- name = Constraint.isNotNull(StringSupport.trimOrNull(attributeName),
- "Attribute name cannot be null or empty");
- }
-
- /**
- * Get whether to encode type information.
- *
- * <p>Defaults to 'true'</p>
- *
- * @return true iff type information should be encoded
- */
- public boolean encodeType() {
- return encodeType;
- }
-
- /**
- * Set whether to encode type information.
- *
- * @param flag flag to set
- */
- public void setEncodeType(final boolean flag) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- encodeType = flag;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (name == null) {
- throw new ComponentInitializationException("Attribute name cannot be null or empty");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public AttributeType encode(@Nonnull final IdPAttribute attribute) throws AttributeEncodingException {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
- Constraint.isNotNull(attribute, "Attribute to encode cannot be null");
- final String attributeId = attribute.getId();
- log.debug("Beginning to encode attribute {}", attributeId);
-
- if (attribute.getValues().isEmpty()) {
- throw new AttributeEncodingException("Unable to encode " + attributeId
- + " attribute. It does not contain any values");
- }
-
- final List<XMLObject> samlAttributeValues = new ArrayList<>();
-
- EncodedType attributeValue;
- XMLObject samlAttributeValue;
- for (final IdPAttributeValue o : attribute.getValues()) {
- if (o == null) {
- // filtered out upstream leave in test for sanity
- log.debug("Skipping null value of attribute {}", attributeId);
- continue;
- }
-
- if (!canEncodeValue(attribute, o)) {
- log.warn("Skipping value of attribute '{}'; Type {} cannot be encoded by this encoder ({}).",
- attributeId, o.getClass().getName(), this.getClass().getName());
- continue;
- }
-
- attributeValue = (EncodedType) o;
- samlAttributeValue = encodeValue(attribute, attributeValue);
- if (samlAttributeValue == null) {
- log.debug("Skipping empty value for attribute {}", attributeId);
- } else {
- samlAttributeValues.add(samlAttributeValue);
- }
- }
-
- if (samlAttributeValues.isEmpty()) {
- throw new AttributeEncodingException("Attribute " + attributeId + " did not contain any encodeable values");
- }
-
- log.debug("Completed encoding {} values for attribute {}", samlAttributeValues.size(), attributeId);
- return buildAttribute(attribute, samlAttributeValues);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof AbstractSAMLAttributeEncoder)) {
- return false;
- }
-
- final AbstractSAMLAttributeEncoder other = (AbstractSAMLAttributeEncoder) obj;
- return java.util.Objects.equals(getName(), other.getName())
- && java.util.Objects.equals(getProtocol(), other.getProtocol());
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hashCode(getName(), getProtocol());
- }
-
- /**
- * Checks if the given value can be handled by the encoder. In many cases this is simply a check to see if the given
- * object is of the right type.
- *
- * @param idpAttribute the attribute being encoded, never null
- * @param value the value to check, never null
- *
- * @return true if the encoder can encoder this value, false if not
- */
- protected abstract boolean canEncodeValue(@Nonnull final IdPAttribute idpAttribute,
- @Nonnull final IdPAttributeValue value);
-
- /**
- * Encodes an attribute value in to a SAML attribute value element.
- *
- * @param idpAttribute the attribute being encoded, never null
- * @param value the value to encoder, never null
- *
- * @return the attribute value or null if the resulting attribute value would be empty
- *
- * @throws AttributeEncodingException thrown if there is a problem encoding the attribute value
- */
- @Nullable protected abstract XMLObject encodeValue(@Nonnull final IdPAttribute idpAttribute,
- @Nonnull final EncodedType value) throws AttributeEncodingException;
-
- /**
- * Builds a SAML attribute element from the given attribute values.
- *
- * @param idpAttribute the attribute being encoded, never null
- * @param attributeValues the encoded values for the attribute, never null or containing null elements
- *
- * @return the SAML attribute element
- *
- * @throws AttributeEncodingException thrown if there is a problem constructing the SAML attribute
- */
- @Nonnull protected abstract AttributeType buildAttribute(@Nonnull final IdPAttribute idpAttribute,
- @Nonnull @NonnullElements final List<XMLObject> attributeValues) throws AttributeEncodingException;
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeDesignatorMapperProcessor.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeDesignatorMapperProcessor.java
deleted file mode 100644
index cc420b9..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeDesignatorMapperProcessor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeDesignatorMapper;
-
-/**
- * An interface which is implemented by encoders which encode SAML 1 attributes and which can be reverse mapped.
- *
- * @param <I> The IdP Type
- */
-public interface AttributeDesignatorMapperProcessor<I extends IdPAttribute> {
-
- /**
- * This populates the attribute mapper to go from a SAML AttributeDesignator to an IdP Attribute (or
- * derivative) such that applying the output of the mapper to the encoder will produce the name attribute
- * (and vice versa).
- *
- * <p>The populated mapper <em>must not</em> have any associated (IdP) Attribute names and <em>must</em> implement
- * {@link Object#equals(Object)} and {@link Object#hashCode()}.</p>
- *
- * @param mapper the mapper.
- */
- @Nonnull void populateAttributeMapper(@Nonnull final AbstractSAMLAttributeDesignatorMapper<I> mapper);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeMapperProcessor.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeMapperProcessor.java
deleted file mode 100644
index c676c88..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AttributeMapperProcessor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-
-import org.opensaml.saml.saml2.core.Attribute;
-
-/**
- * An interface which is implemented by encoders which encode attributes and which can be reverse mapped.
- *
- * @param <S> The SAML Type
- * @param <I> The IdP Type
- */
-public interface AttributeMapperProcessor<S extends Attribute,I extends IdPAttribute> {
-
- /**
- * This populates the attribute mapper to go from a SAML Attribute (or derivative) to an IdP Attribute (or
- * derivative) such that applying the output of the mapper to the encoder will produce the name attribute
- * (and vice versa).
- *
- * <p>The populated mapper <em>must not</em> have any associated (IdP) Attribute names and <em>must</em> implement
- * {@link Object#equals(Object)} and {@link Object#hashCode()}.</p>
- *
- * @param mapper the mapper.
- */
- @Nonnull void populateAttributeMapper(@Nonnull final AbstractSAMLAttributeMapper<S, I> mapper);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML1AttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML1AttributeEncoder.java
deleted file mode 100644
index bcb202f..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML1AttributeEncoder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-
-import org.opensaml.saml.saml1.core.Attribute;
-
-
-/**
- * Interface for encoders that produce a SAML 1 {@link Attribute}.
- *
- * @param <EncodedType> the type of data that can be encoded by the encoder
- */
-public interface SAML1AttributeEncoder<EncodedType extends IdPAttributeValue> extends AttributeEncoder<Attribute> {
-
- /**
- * Get the encoded Name of the attribute.
- *
- * @return name of the attribute
- */
- @NonnullAfterInit String getName();
-
- /**
- * Get the encoded Namespace of the attribute.
- *
- * @return namespace of the attribute
- */
- @NonnullAfterInit String getNamespace();
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML2AttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML2AttributeEncoder.java
deleted file mode 100644
index 98fdc4c..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/SAML2AttributeEncoder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-
-import org.opensaml.saml.saml2.core.Attribute;
-
-
-/**
- * Interface for encoders that produce a SAML 2 {@link Attribute}.
- *
- * @param <EncodedType> the type of data that can be encoded by the encoder
- */
-public interface SAML2AttributeEncoder<EncodedType extends IdPAttributeValue> extends AttributeEncoder<Attribute> {
-
- /**
- * Get the encoded Name of the attribute.
- *
- * @return name of the attribute
- */
- @NonnullAfterInit String getName();
-
- /**
- * Get the encoded NameFormat of the attribute.
- *
- * @return name format of the attribute
- */
- @NonnullAfterInit String getNameFormat();
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/package-info.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/package-info.java
deleted file mode 100644
index 69b6f2e..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Base classes for encoding {@link net.shibboleth.idp.attribute.IdPAttribute} objects into SAML message components.
- */
-
-package net.shibboleth.idp.saml.attribute.encoding;
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorMapper.java
deleted file mode 100644
index 0e0495f..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorMapper.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-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.annotation.constraint.NullableElements;
-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;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.saml.saml1.core.AttributeDesignator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Basis of all classes which map SAML1 {@link AttributeDesignator} into an IdP {@link IdPAttribute}.
- *
- * @param <OutType> the output (IdP Attribute) type
- */
-public abstract class AbstractSAMLAttributeDesignatorMapper<OutType extends IdPAttribute> extends
- AbstractIdentifiableInitializableComponent implements AttributeMapper<AttributeDesignator, OutType> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeDesignatorMapper.class);
-
- /** The internal names to generate. */
- @Nonnull @NonnullElements private List<String> attributeIds = Collections.emptyList();
-
- /** The attribute namespace. */
- @Nullable private String attributeNamespace;
-
- /** the (SAML) attribute name. */
- @NonnullAfterInit private String theSAMLName;
-
- /** The String used to prefix log message. */
- @Nullable private String logPrefix;
-
- /**
- * Set the list of internal identifiers.
- *
- * @param theIds the list
- */
- public void setAttributeIds(@Nullable @NullableElements final List<String> theIds) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (null == theIds) {
- return;
- }
-
- attributeIds = ImmutableList.copyOf(StringSupport.normalizeStringCollection(theIds));
- }
-
- /**
- * Get the list of internal identifiers.
- *
- * @return the identifiers
- */
- @Nonnull @NonnullElements @Unmodifiable public List<String> getAttributeIds() {
- return attributeIds;
- }
-
- /**
- * Set the SAML attribute name.
- *
- * @param name the name
- */
- public void setSAMLName(@Nullable final String name) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- theSAMLName = StringSupport.trimOrNull(name);
- }
-
- /**
- * Get the SAML attribute name.
- *
- * @return the name
- */
- @NonnullAfterInit public String getSAMLName() {
- return theSAMLName;
- }
-
- /**
- * Set the (optional) attribute namespace.
- *
- * @param ns the namespace to set
- */
- public void setAttributeNamespace(@Nullable final String ns) {
- attributeNamespace = StringSupport.trimOrNull(ns);
- }
-
- /**
- * Get the (optional) attribute namespace.
- *
- * @return the namespace
- */
- @Nullable public String getAttributeNamespace() {
- return attributeNamespace;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
- if (null == theSAMLName) {
- throw new ComponentInitializationException(getLogPrefix() + " SAML name not present");
- }
- if (attributeIds.isEmpty()) {
- throw new ComponentInitializationException(getLogPrefix()
- + " At least one attribute Id should be provided");
- }
- logPrefix = null;
- }
-
- /**
- * Compare whether the name and namespace given "match" ours. Used in checking both against input attributes and as
- * part of equality checking.
- *
- * @param otherSAMLName the name to compare against
- * @param otherSAMLNamespace the bamespace to compare against
- * @return whether there is a match.
- */
- protected boolean matches(@Nonnull @NotEmpty final String otherSAMLName,
- @Nullable final String otherSAMLNamespace) {
- if (!otherSAMLName.equals(theSAMLName)) {
- log.debug("{} SAML attribute name {} does not match {}", getLogPrefix(), otherSAMLName, getId());
- return false;
- } else if (!java.util.Objects.equals(otherSAMLNamespace, getAttributeNamespace())) {
- log.debug("{} SAML attribute namespace {} does not match {}", getLogPrefix(), otherSAMLNamespace,
- getAttributeNamespace());
- return false;
- }
-
- return true;
- }
-
- /**
- * Determines if the input matches the provided parameterisation.
- *
- * @param designator the designator to consider
- * @return whether it matches.
- */
- protected boolean attributeMatches(@Nonnull final AttributeDesignator designator) {
- return matches(designator.getAttributeName(), designator.getAttributeNamespace());
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull @NonnullElements public Map<String,OutType> mapAttribute(@Nonnull final AttributeDesignator prototype) {
-
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- if (!attributeMatches(prototype)) {
- return Collections.emptyMap();
- }
-
- final Map<String,OutType> output = new HashMap<>();
-
- log.debug("{} attribute id {} and aliases {} will be created", getLogPrefix(), getId(), getAttributeIds());
-
- OutType out = newAttribute(prototype, getId());
-
- for (final String id : attributeIds) {
- out = newAttribute(prototype, getId());
- output.put(id, out);
- }
- return output;
- }
-
- /**
- * return a string which is to be prepended to all log messages.
- *
- * @return "<type> Attribute Mapper '<mapper ID>' :"
- */
- @Nonnull @NotEmpty protected String getLogPrefix() {
- // local cache of cached entry to allow unsynchronised clearing.
- String prefix = logPrefix;
- if (null == prefix) {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("Attribute Mapper '").append(getId()).append("':");
- prefix = builder.toString();
- if (null == logPrefix) {
- logPrefix = prefix;
- }
- }
- return prefix;
- }
-
- /**
- * {@inheritDoc}. The identity is not part of equality of hash
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (obj instanceof AbstractSAMLAttributeDesignatorMapper) {
- final AbstractSAMLAttributeDesignatorMapper other = (AbstractSAMLAttributeDesignatorMapper) obj;
- return matches(other.getSAMLName(), other.getAttributeNamespace())
- && java.util.Objects.equals(getAttributeIds(), other.getAttributeIds());
- }
- return false;
- }
-
- /**
- * {@inheritDoc}. The identity is not part of equality of hash
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(attributeNamespace, theSAMLName, attributeIds);
- }
-
- /**
- * Function to summon up the output type based on an ID and an object of the input type. Typically the input type
- * will be inspected for extra parameterisation.
- *
- * @param input the input value to inspect.
- * @param id the identifier of the new attribute.
- * @return an output, suitable set up with per object information.
- */
- @Nonnull protected abstract OutType newAttribute(@Nonnull final AttributeDesignator input,
- @Nonnull @NotEmpty final String id);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorsMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorsMapper.java
deleted file mode 100644
index cccd896..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeDesignatorsMapper.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.saml.saml1.core.AttributeDesignator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeDesignatorMapperProcessor;
-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.Pair;
-import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
-/**
- * The class contains the mechanics to go from a list of {@link AttributeDesignator}s to a {@link Multimap} of
- * {@link String},{@link IdPAttribute} (or derived, or null). The representation as a {@link Multimap} is useful for
- * filtering situations and is exploited by the AttributeInMetadata filter.
- *
- * @param <OutType> some sort of representation of an IdP attribute
- */
-public abstract class AbstractSAMLAttributeDesignatorsMapper<OutType extends IdPAttribute>
- extends AbstractIdentifiableInitializableComponent implements AttributesMapper<AttributeDesignator,OutType> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeDesignatorsMapper.class);
-
- /** The mappers we can apply. */
- @Nonnull @NonnullElements private Collection<AttributeMapper<AttributeDesignator,OutType>> mappers;
-
- /** The String used to prefix log message. */
- @Nullable private String logPrefix;
-
- /** Default Constructor. */
- public AbstractSAMLAttributeDesignatorsMapper() {
- mappers = Collections.emptyList();
- }
-
- /**
- * Constructor to create the mapping from an existing resolver.
- *
- * <p>This code inverts the {@link AttributeEncoder} (internal attribute -> SAML Attributes) into
- * {@link AttributeMapper} (SAML [AttributeDesignators] -> internal [Requested] Attributes). <br/>
- * to generate the {@link AbstractSAMLAttributeDesignatorMapper} (with no
- * {@link AbstractSAMLAttributeDesignatorMapper#getAttributeIds()}. These are accumulated into a {@link Multimap},
- * where the key is the {@link AbstractSAMLAttributeDesignatorMapper} and the values are the (IdP) attribute names.
- * The collection of {@link AttributeMapper}s can then be extracted from the map, and the appropriate internal names
- * added (these being the value of the {@link Multimap})</p>
- *
- * @param resolver the resolver
- * @param id the ID
- * @param mapperFactory factory to generate new mappers of the correct type.
- */
- public AbstractSAMLAttributeDesignatorsMapper(@Nonnull final AttributeResolver resolver,
- @Nonnull @NotEmpty final String id,
- @Nonnull final Supplier<AbstractSAMLAttributeDesignatorMapper<OutType>> mapperFactory) {
-
- setId(id);
- mappers = Collections.emptyList();
-
- final Multimap<AbstractSAMLAttributeDesignatorMapper<OutType>,String> theMappers = HashMultimap.create();
-
- for (final Pair<String, AttributeEncoder<?>> pair : resolver.getAllEncoders()) {
- if (pair.getSecond() instanceof AttributeDesignatorMapperProcessor) {
- // There is an appropriate reverse mapper.
- final AttributeDesignatorMapperProcessor factory =
- (AttributeDesignatorMapperProcessor) pair.getSecond();
- final AbstractSAMLAttributeDesignatorMapper<OutType> mapper = mapperFactory.get();
- factory.populateAttributeMapper(mapper);
-
- theMappers.put(mapper, pair.getFirst());
- }
- }
-
- mappers = new ArrayList<>(theMappers.values().size());
-
- for (final Entry<AbstractSAMLAttributeDesignatorMapper<OutType>,Collection<String>> entry
- : theMappers.asMap().entrySet()) {
-
- final AbstractSAMLAttributeDesignatorMapper<OutType> mapper = entry.getKey();
- mapper.setAttributeIds(new ArrayList<>(entry.getValue()));
- mappers.add(mapper);
- }
- }
-
- /**
- * Get the mappers.
- *
- * @return Returns the mappers.
- */
- @Nonnull @NonnullElements public Collection<AttributeMapper<AttributeDesignator,OutType>> getMappers() {
- return mappers;
- }
-
- /**
- * Set the attribute mappers into the lookup map.
- *
- * @param theMappers The mappers to set.
- */
- public void setMappers(@Nonnull final Collection<AttributeMapper<AttributeDesignator,OutType>> theMappers) {
- mappers = Constraint.isNotNull(theMappers, "Mappers list cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull @NonnullElements public Multimap<String,OutType> mapAttributes(
- @Nonnull @NonnullElements final List<AttributeDesignator> prototypes) {
-
- final Multimap<String,OutType> result = ArrayListMultimap.create();
-
- for (final AttributeDesignator prototype : prototypes) {
- for (final AttributeMapper<AttributeDesignator,OutType> mapper : mappers) {
-
- final Map<String,OutType> mappedAttributes = mapper.mapAttribute(prototype);
-
- log.debug("{} SAML attribute '{}' mapped to {} attributes by mapper '{}'", getLogPrefix(),
- prototype.getAttributeName(), mappedAttributes.size(), mapper.getId());
-
- for (final Entry<String,OutType> entry : mappedAttributes.entrySet()) {
- result.put(entry.getKey(), entry.getValue());
- }
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- logPrefix = null;
- for (final AttributeMapper mapper : mappers) {
- ComponentSupport.initialize(mapper);
- }
- }
-
- /**
- * Return a string which is to be prepended to all log messages.
- *
- * @return "Attribute Mappers '<ID>' :"
- */
- @Nonnull @NotEmpty private String getLogPrefix() {
- String s = logPrefix;
- if (null == s) {
- s = new StringBuilder("Attribute Mappers : '").append(getId()).append("':").toString();
- logPrefix = s;
- }
- return s;
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeMapper.java
deleted file mode 100644
index 217de97..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeMapper.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-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.annotation.constraint.NullableElements;
-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;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Basis of all classes which map SAML2 {@link Attribute} into an IdP {@link IdPAttribute}.
- *
- * @param <InType> the input (SAML2 attribute) type
- * @param <OutType> the output (IdP Attribute) type
- */
-public abstract class AbstractSAMLAttributeMapper<InType extends Attribute, OutType extends IdPAttribute> extends
- AbstractIdentifiableInitializableComponent implements AttributeMapper<InType, OutType> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeMapper.class);
-
- /** The internal names to generate. */
- @Nonnull @NonnullElements private List<String> attributeIds = Collections.emptyList();
-
- /** The attribute format. */
- @Nullable private String attributeFormat;
-
- /** the (SAML) attribute name. */
- @NonnullAfterInit private String theSAMLName;
-
- /** The String used to prefix log message. */
- @Nullable private String logPrefix;
-
- /** The value mapper. */
- @NonnullAfterInit private AbstractSAMLAttributeValueMapper valueMapper;
-
- /**
- * Set the list of internal identifiers.
- *
- * @param theIds the list
- */
- public void setAttributeIds(@Nullable @NullableElements final List<String> theIds) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (null == theIds) {
- return;
- }
-
- attributeIds = ImmutableList.copyOf(StringSupport.normalizeStringCollection(theIds));
- }
-
- /**
- * Get the list of internal identifiers.
- *
- * @return the identifiers
- */
- @Nonnull @NonnullElements @Unmodifiable public List<String> getAttributeIds() {
- return attributeIds;
- }
-
- /**
- * Set the SAML attribute name.
- *
- * @param name the name
- */
- public void setSAMLName(@Nullable final String name) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- theSAMLName = StringSupport.trimOrNull(name);
- }
-
- /**
- * Get the SAML attribute name.
- *
- * @return the name
- */
- @NonnullAfterInit public String getSAMLName() {
- return theSAMLName;
- }
-
- /**
- * Get the class which converts types.
- *
- * @param mapper The valueMapper to set.
- */
- public void setValueMapper(@Nullable final AbstractSAMLAttributeValueMapper mapper) {
- valueMapper = mapper;
- }
-
- /**
- * Get the class which converts types.
- *
- * @return Returns the valueMapper.
- */
- @NonnullAfterInit public AbstractSAMLAttributeValueMapper getValueMapper() {
- return valueMapper;
- }
-
- /**
- * Set the (optional) attribute format.
- *
- * @param format the format
- */
- public void setAttributeFormat(@Nullable final String format) {
- attributeFormat = StringSupport.trimOrNull(format);
- }
-
- /**
- * Get the (optional) attribute format.
- *
- * @return the format
- */
- @Nullable public String getAttributeFormat() {
- return attributeFormat;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
- if (null == theSAMLName) {
- throw new ComponentInitializationException(getLogPrefix() + " SAML name not present");
- }
- if (null == valueMapper) {
- throw new ComponentInitializationException(getLogPrefix() + " No value mapper present");
- }
- if (attributeIds.isEmpty()) {
- throw new ComponentInitializationException(getLogPrefix()
- + " At least one attribute Id should be provided");
- }
- logPrefix = null;
- valueMapper.setLogPrefix(getLogPrefix());
- }
-
- /**
- * Compare whether the name and format given "match" ours. Used in checking both against input attributes and as
- * part of equality checking. For the sake of comparison null is considered to be the same as
- * {@link Attribute#UNSPECIFIED}
- *
- * @param otherSAMLName the name to compare against
- * @param otherSAMLFormat the format to compare against
- * @return whether there is a match.
- */
- protected boolean matches(@Nonnull @NotEmpty final String otherSAMLName, @Nullable final String otherSAMLFormat) {
- if (!otherSAMLName.equals(theSAMLName)) {
- log.debug("{} SAML attribute name {} does not match {}", getLogPrefix(), otherSAMLName, getId());
- return false;
- }
-
- String format = otherSAMLFormat;
- if (format != null && Attribute.UNSPECIFIED.equals(format)) {
- format = null;
- }
-
- if (getAttributeFormat() != null && format != null && !getAttributeFormat().equals(format)
- && !Attribute.UNSPECIFIED.equals(getAttributeFormat())) {
- log.debug("{} SAML name format {} does not match {}", getLogPrefix(), format, getAttributeFormat());
- return false;
- }
- return true;
-
- }
-
- /**
- * Determines if the attribute matches the provided parameterisation.
- *
- * @param attribute the attribute to consider
- * @return whether it matches.
- */
- protected boolean attributeMatches(@Nonnull final InType attribute) {
- return matches(attribute.getName(), attribute.getNameFormat());
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull @NonnullElements public Map<String,OutType> mapAttribute(@Nonnull final InType prototype) {
-
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- if (!attributeMatches(prototype)) {
- return Collections.emptyMap();
- }
-
- final List<XMLObject> inputValues = prototype.getAttributeValues();
- final List<IdPAttributeValue<?>> outputValues = getValueMapper().decodeValues(inputValues);
-
- if (!inputValues.isEmpty() && outputValues.isEmpty()) {
- log.warn("{} Attribute '{}' value conversion yielded no suitable values", getLogPrefix(),
- prototype.getName());
- return Collections.emptyMap();
- }
-
- final Map<String,OutType> output = new HashMap<>(inputValues.size());
-
- log.debug("{} attribute id {} and aliases {} will be created", getLogPrefix(), getId(), getAttributeIds());
-
- OutType out = newAttribute(prototype, getId());
- out.setValues(outputValues);
-
- for (final String id : attributeIds) {
- out = newAttribute(prototype, getId());
- out.setValues(outputValues);
- output.put(id, out);
- }
- return output;
- }
-
- /**
- * return a string which is to be prepended to all log messages.
- *
- * @return "<type> Attribute Mapper '<mapper ID>' :"
- */
- @Nonnull @NotEmpty protected String getLogPrefix() {
- // local cache of cached entry to allow unsynchronised clearing.
- String prefix = logPrefix;
- if (null == prefix) {
- final StringBuilder builder = new StringBuilder();
- if (null != getValueMapper()) {
- builder.append(getValueMapper().getAttributeTypeName()).append(" ");
- }
-
- builder.append("Attribute Mapper '").append(getId()).append("':");
- prefix = builder.toString();
- if (null == logPrefix) {
- logPrefix = prefix;
- }
- }
- return prefix;
- }
-
- /**
- * {@inheritDoc}. The identity is not part of equality of hash
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (obj instanceof AbstractSAMLAttributeMapper) {
- final AbstractSAMLAttributeMapper other = (AbstractSAMLAttributeMapper) obj;
- return matches(other.getSAMLName(), other.getAttributeFormat())
- && java.util.Objects.equals(getAttributeIds(), other.getAttributeIds());
- }
- return false;
- }
-
- /**
- * {@inheritDoc}. The identity is not part of equality of hash
- */
- @Override
- public int hashCode() {
- String myFormat = getAttributeFormat();
- if (null == myFormat) {
- myFormat = Attribute.UNSPECIFIED;
- }
- return Objects.hashCode(myFormat, theSAMLName, attributeIds);
- }
-
- /**
- * Function to summon up the output type based on an ID and an object of the input type. Typically the input type
- * will be inspected for extra parameterisation.
- *
- * @param input the input value to inspect.
- * @param id the identifier of the new attribute.
- * @return an output, suitable set up with per object information.
- */
- @Nonnull protected abstract OutType newAttribute(@Nonnull final InType input, @Nonnull @NotEmpty final String id);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeValueMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeValueMapper.java
deleted file mode 100644
index 1f1e78f..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributeValueMapper.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-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.Unmodifiable;
-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;
-import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSAny;
-import org.opensaml.core.xml.schema.XSBase64Binary;
-import org.opensaml.core.xml.schema.XSBoolean;
-import org.opensaml.core.xml.schema.XSDateTime;
-import org.opensaml.core.xml.schema.XSInteger;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.core.xml.schema.XSURI;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-
-/**
- * The base of the classes that map SAML2 attribute values into IdP attribute values.
- */
-public abstract class AbstractSAMLAttributeValueMapper extends AbstractInitializableComponent {
-
- /** logger. */
- private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributeValueMapper.class);
-
- /** The String used to prefix log message. */
- private String logPrefix;
-
- /**
- * Convert from a list of the SAML Objects (usually a SAML2 AttributeValue) Value into the IDP Attributes.
- *
- * @param inputs the list of SAML Attributes
- * @return a list of IdP Attributes
- */
- @Nonnull @Unmodifiable public List<IdPAttributeValue<?>>
- decodeValues(@Nonnull @NonnullElements final List<XMLObject> inputs) {
- final List<IdPAttributeValue<?>> outputs = new ArrayList<>(inputs.size());
-
- for (final XMLObject input : inputs) {
- final IdPAttributeValue output = decodeValue(input);
- if (null != output) {
- outputs.add(output);
- }
- }
- return Collections.unmodifiableList(outputs);
-
- }
-
- /**
- * Function to return the string contents if this is the correct type.
- *
- * @param object The object to inspect.
- * @return Its contents suitably decoded. Returns null if we could not decode.
- */
- // Checkstyle: CyclomaticComplexity OFF
- @Nullable protected String getStringValue(@Nonnull final XMLObject object) {
- String retVal = null;
-
- if (object instanceof XSString) {
-
- retVal = ((XSString) object).getValue();
-
- } else if (object instanceof XSURI) {
-
- retVal = ((XSURI) object).getValue();
-
- } else if (object instanceof XSBoolean) {
-
- retVal = ((XSBoolean) object).getValue().getValue() ? "1" : "0";
-
- } else if (object instanceof XSInteger) {
-
- retVal = ((XSInteger) object).getValue().toString();
-
- } else if (object instanceof XSDateTime) {
-
- final Instant dt = ((XSDateTime) object).getValue();
- if (dt != null) {
- retVal = DOMTypeSupport.instantToString(dt);
- } else {
- retVal = null;
- }
-
- } else if (object instanceof XSBase64Binary) {
-
- retVal = ((XSBase64Binary) object).getValue();
-
- } else if (object instanceof XSAny) {
-
- final XSAny wc = (XSAny) object;
- if (wc.getUnknownAttributes().isEmpty() && wc.getUnknownXMLObjects().isEmpty()) {
- retVal = wc.getTextContent();
- } else {
- retVal = null;
- }
- }
-
- if (null == retVal) {
- log.info("{} value of type {} could not be converted", getLogPrefix(), object.getClass().toString());
- }
- return retVal;
- }
-
- // Checkstyle: CyclomaticComplexity ON
-
- /**
- * Return a string which is to be prepended to all log messages. This is set by the enclosing AttributeMapper.
- *
- * @return Returns the logPrefix.
- */
- @NonnullAfterInit public String getLogPrefix() {
- return logPrefix;
- }
-
- /**
- * Set the log prefix to use.
- *
- * @param prefix The logPrefix to set.
- */
- public void setLogPrefix(@Nonnull final String prefix) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- logPrefix = Constraint.isNotNull(prefix, "prefix can not be null or empty");
- }
-
- /** {@inheritDoc} */
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
- if (null == logPrefix) {
- throw new ComponentInitializationException("No log prefix set");
- }
- }
-
- /** {@inheritDoc} */
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (obj instanceof AbstractSAMLAttributeValueMapper) {
- final AbstractSAMLAttributeValueMapper other = (AbstractSAMLAttributeValueMapper) obj;
-
- return getClass().equals(other.getClass());
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public int hashCode() {
- return Objects.hashCode(getClass());
- }
-
- /**
- * Function to decode a single {@link XMLObject} into an {@link IdPAttributeValue}.
- *
- * @param object the object to decode
- * @return the returned final {@link IdPAttributeValue} or null if decoding failed
- */
- @Nullable protected abstract IdPAttributeValue decodeValue(@Nonnull final XMLObject object);
-
- /**
- * Return the output type (for logging).
- *
- * @return the output type.
- */
- @Nonnull protected abstract String getAttributeTypeName();
-
-}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributesMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributesMapper.java
deleted file mode 100644
index 61e88bb..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AbstractSAMLAttributesMapper.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.saml.saml2.core.Attribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeMapperProcessor;
-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.Pair;
-import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
-/**
- * The class contains the mechanics to go from a list of {@link Attribute}s (or derived) to a {@link Multimap} of
- * {@link String},{@link IdPAttribute} (or derived, or null). The representation as a {@link Multimap} is useful for
- * filtering situations and is exploited by AttributeInMetadata filter.
- *
- * @param <InType> the type which is to be inspected and mapped
- * @param <OutType> some sort of representation of an IdP attribute
- */
-
-public abstract class AbstractSAMLAttributesMapper<InType extends Attribute, OutType extends IdPAttribute> extends
- AbstractIdentifiableInitializableComponent implements AttributesMapper<InType, OutType> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractSAMLAttributesMapper.class);
-
- /** The mappers we can apply. */
- @Nonnull @NonnullElements private Collection<AttributeMapper<InType,OutType>> mappers = Collections.EMPTY_LIST;
-
- /** The String used to prefix log message. */
- @Nullable private String logPrefix;
-
- /** Default Constructor. */
- public AbstractSAMLAttributesMapper() {
-
- }
-
- /**
- * Constructor to create the mapping from an existing resolver. <br/>
- * This code inverts the {@link AttributeEncoder} (internal attribute -> SAML Attributes) into
- * {@link AttributeMapper} (SAML [RequestedAttributes] -> internal [Requested] Attributes). <br/>
- * to generate the {@link AbstractSAMLAttributeMapper} (with no
- * {@link AbstractSAMLAttributeMapper#getAttributeIds()}. These are accumulated into a {@link Multimap}, where the
- * key is the {@link AbstractSAMLAttributeMapper} and the values are the (IdP) attribute names. The collection of
- * {@link AttributeMapper}s can then be extracted from the map, and the appropriate internal names added (these
- * being the value of the {@link Multimap})
- *
- * @param resolver The resolver
- * @param id The it
- * @param mapperFactory A factory to generate new mappers of the correct type.
- */
- public AbstractSAMLAttributesMapper(@Nonnull final AttributeResolver resolver, @Nonnull @NotEmpty final String id,
- @Nonnull final Supplier<AbstractSAMLAttributeMapper<InType,OutType>> mapperFactory) {
-
- setId(id);
-
- final Multimap<AbstractSAMLAttributeMapper<InType,OutType>,String> theMappers;
-
- theMappers = HashMultimap.create();
-
- for (final Pair<String, AttributeEncoder<?>> pair : resolver.getAllEncoders()) {
- if (pair.getSecond() instanceof AttributeMapperProcessor) {
- // There is an appropriate reverse mapper
- final AttributeMapperProcessor factory = (AttributeMapperProcessor) pair.getSecond();
- final AbstractSAMLAttributeMapper<InType,OutType> mapper = mapperFactory.get();
- factory.populateAttributeMapper(mapper);
- theMappers.put(mapper, pair.getFirst());
- }
- }
-
- mappers = new ArrayList<>(theMappers.values().size());
-
- for (final Entry<AbstractSAMLAttributeMapper<InType,OutType>,Collection<String>> entry : theMappers.asMap()
- .entrySet()) {
-
- final AbstractSAMLAttributeMapper<InType, OutType> mapper = entry.getKey();
- mapper.setAttributeIds(new ArrayList<>(entry.getValue()));
- mappers.add(mapper);
- }
- }
-
- /**
- * Get the mappers.
- *
- * @return Returns the mappers.
- */
- @Nonnull @NonnullElements public Collection<AttributeMapper<InType,OutType>> getMappers() {
- return mappers;
- }
-
- /**
- * Set the attribute mappers into the lookup map.
- *
- * @param theMappers The mappers to set.
- */
- public void setMappers(@Nonnull final Collection<AttributeMapper<InType,OutType>> theMappers) {
- mappers = Constraint.isNotNull(theMappers, "mappers list must be non null");
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull @NonnullElements public Multimap<String,OutType> mapAttributes(
- @Nonnull @NonnullElements final List<InType> prototypes) {
-
- final Multimap<String,OutType> result = ArrayListMultimap.create();
-
- for (final InType prototype : prototypes) {
- for (final AttributeMapper<InType,OutType> mapper : mappers) {
-
- final Map<String,OutType> mappedAttributes;
- try {
- mappedAttributes = mapper.mapAttribute(prototype);
- } catch (final Exception e) {
- log.error("{} Attempt to map SAML attribute '{}' with mapper '{}' failed: ", getLogPrefix(),
- prototype.getName(),mapper.getId(), e);
- throw e;
- }
-
- log.debug("{} SAML attribute '{}' mapped to {} attributes by mapper '{}'", getLogPrefix(),
- prototype.getName(), mappedAttributes.size(), mapper.getId());
-
- for (final Entry<String,OutType> entry : mappedAttributes.entrySet()) {
- result.put(entry.getKey(), entry.getValue());
- }
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
- logPrefix = null;
- for (final AttributeMapper mapper : mappers) {
- ComponentSupport.initialize(mapper);
- }
- }
-
- /**
- * Return a string which is to be prepended to all log messages.
- *
- * @return "Attribute Mappers '<ID>' :"
- */
- @Nonnull @NotEmpty private String getLogPrefix() {
- String s = logPrefix;
- if (null == s) {
- s = new StringBuilder("Attribute Mappers : '").append(getId()).append("':").toString();
- logPrefix = s;
- }
- return s;
- }
-}
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributeMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributeMapper.java
deleted file mode 100644
index 45ee2a3..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributeMapper.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.Map;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.IdentifiedComponent;
-
-/**
- * This attribute defines the mechanism to go from something into an (IdP) {@link IdPAttribute}. <br/>
- * Implementations of this interface will be paired with implementations of {@link AttributesMapper}.
- *
- * @param <InType> the type which is to be inspected and mapped
- * @param <OutType> some sort of representation of an IdP attribute
- */
-public interface AttributeMapper<InType,OutType extends IdPAttribute> extends IdentifiedComponent{
-
- /**
- * Map the SAML attribute to the required output type.
- *
- * <p>If the input contains values to be decoded, failure to decode any values results in a failure
- * to map the input at all.</p>
- *
- * @param input the SAML attribute
- * @return the appropriate map of names to output type
- *
- */
- @Nonnull @NonnullElements Map<String,OutType> mapAttribute(@Nonnull final InType input);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributesMapper.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributesMapper.java
deleted file mode 100644
index e3cabc0..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/AttributesMapper.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-
-import com.google.common.collect.Multimap;
-
-/**
- * This attribute defines the mechanism to go from a list of objects into a collection (IdP) {@link IdPAttribute}, the
- * representation (a {@link Multimap}) being such as is useful to attribute filtering. <br/>
- * Implementations of this interface will be paired with implementations of {@link AttributeMapper}.
- *
- * @param <InType> the type which is to be inspected and mapped
- * @param <OutType> some sort of representation of an IdP attribute
- */
-public interface AttributesMapper<InType,OutType extends IdPAttribute> {
-
- /**
- * Map the input objects into IdP attributes.
- *
- * @param prototypes the SAML attributes
- *
- * @return a map from IdP AttributeId to RequestedAttributes
- */
- @Nonnull @NonnullElements Multimap<String,OutType> mapAttributes(
- @Nonnull @NonnullElements final List<InType> prototypes);
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/package-info.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/package-info.java
deleted file mode 100644
index 9b82bcc..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/mapping/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Classes in this package are to do with the import of attributes
- * as an adjunct to filtering.
- */
-
-package net.shibboleth.idp.saml.attribute.mapping;
\ No newline at end of file
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoderTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoderTest.java
deleted file mode 100644
index 80e283f..0000000
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1AttributeEncoderTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.XMLObjectBuilder;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Test for {@link AbstractSAML1AttributeEncoder}.
- */
-public class AbstractSAML1AttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- private XMLObjectBuilder<XSString> theBuilder;
-
- private QName theQName = new QName("LocalQNAME");
-
- private final String MY_NAME = "myName";
-
- private final String MY_NAMESPACE = "myNameSpace";
-
- private final String ATTRIBUTE_ID = "attrID";
-
- private final String ATTRIBUTE_VALUE_1 = "attrValOne";
-
- private final String ATTRIBUTE_VALUE_2 = "attrValueTwo";
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- theBuilder = XMLObjectProviderRegistrySupport.getBuilderFactory().<XSString>getBuilderOrThrow(XSString.TYPE_NAME);
-
- }
-
- @Test public void abstractSAML1AttributeEncoder() throws ComponentInitializationException, AttributeEncodingException {
- AbstractSAML1AttributeEncoder encoder = new AbstractSAMLAttributeEncoderTest.mockEncoder(theBuilder, theQName);
- encoder.setName(MY_NAME);
- encoder.setNamespace(MY_NAMESPACE);
- encoder.initialize();
- // Use literal here to catch things being edited by mistake
- Assert.assertEquals(encoder.getProtocol(), "urn:oasis:names:tc:SAML:1.1:protocol");
-
-
- IdPAttribute attr = new IdPAttribute(ATTRIBUTE_ID);
- attr.setValues(Arrays.asList(new StringAttributeValue(ATTRIBUTE_VALUE_1),
- new StringAttributeValue(ATTRIBUTE_VALUE_2)));
-
- XMLObject obj = encoder.encode(attr);
-
- Assert.assertTrue(obj instanceof Attribute);
-
- List<XMLObject> result = ((Attribute) obj).getAttributeValues();
-
- Assert.assertEquals(result.size(), 2);
- Set<String> resultSet = new HashSet<>(2);
- for (XMLObject o: result) {
- Assert.assertTrue(o instanceof XSString);
- resultSet.add(((XSString) o).getValue());
- }
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_1));
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_2));
- }
-}
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoderTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoderTest.java
deleted file mode 100644
index d36bee4..0000000
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2AttributeEncoderTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.UnmodifiableComponentException;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.XMLObjectBuilder;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Test for {@link AbstractSAML2AttributeEncoder}.
- */
-public class AbstractSAML2AttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- private XMLObjectBuilder<XSString> theBuilder;
-
- private QName theQName = new QName("LocalQNAME");
-
- private final String MY_NAME = "myName";
-
- private final String MY_NAMESPACE = "myNameSpace";
-
- private final String ATTRIBUTE_ID = "attrID";
-
- private final String ATTRIBUTE_VALUE_1 = "attrValOne";
-
- private final String ATTRIBUTE_VALUE_2 = "attrValueTwo";
-
- private final String FRIENDLY_NAME = "friendly";
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- theBuilder = XMLObjectProviderRegistrySupport.getBuilderFactory().<XSString>getBuilderOrThrow(XSString.TYPE_NAME);
- }
-
- @Test public void abstractSAML2AttributeEncoder() throws ComponentInitializationException, AttributeEncodingException {
- AbstractSAML2AttributeEncoder encoder = new mockEncoder();
-
- encoder.setName(MY_NAME);
- encoder.setNameFormat(MY_NAMESPACE);
- encoder.setFriendlyName(FRIENDLY_NAME);
- encoder.initialize();
- // Use literal here to catch things being edited by mistake
- Assert.assertEquals(encoder.getProtocol(), "urn:oasis:names:tc:SAML:2.0:protocol");
-
-
- IdPAttribute attr = new IdPAttribute(ATTRIBUTE_ID);
- attr.setValues(Arrays.asList(new StringAttributeValue(ATTRIBUTE_VALUE_1),
- new StringAttributeValue(ATTRIBUTE_VALUE_2)));
-
- XMLObject obj = encoder.encode(attr);
-
- Assert.assertTrue(obj instanceof Attribute);
-
- List<XMLObject> result = ((Attribute) obj).getAttributeValues();
-
- Assert.assertEquals(result.size(), 2);
- Set<String> resultSet = new HashSet<>(2);
- for (XMLObject o: result) {
- Assert.assertTrue(o instanceof XSString);
- resultSet.add(((XSString) o).getValue());
- }
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_1));
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_2));
- }
-
- @Test public void friendlyName() throws ComponentInitializationException {
- AbstractSAML2AttributeEncoder encoder = new mockEncoder();
- Assert.assertNull(encoder.getFriendlyName());
- encoder.setName(MY_NAME);
- encoder.setNameFormat(MY_NAMESPACE);
- encoder.initialize();
-
- encoder = new mockEncoder();
- Assert.assertNull(encoder.getFriendlyName());
- encoder.setName(MY_NAME);
- encoder.setFriendlyName(FRIENDLY_NAME);
- encoder.setNameFormat(MY_NAMESPACE);
- Assert.assertEquals(encoder.getFriendlyName(), FRIENDLY_NAME);
- encoder.initialize();
- Assert.assertEquals(encoder.getFriendlyName(), FRIENDLY_NAME);
- try {
- encoder.setFriendlyName(FRIENDLY_NAME);
- Assert.fail();
- } catch (UnmodifiableComponentException ex) {
- //OK
- }
- }
-
- protected class mockEncoder extends AbstractSAML2AttributeEncoder {
-
- /** {@inheritDoc} */
- protected boolean canEncodeValue(IdPAttribute attribute, IdPAttributeValue value) {
- return ! (value instanceof ByteAttributeValue);
- }
-
- /** {@inheritDoc} */
- protected XMLObject encodeValue(IdPAttribute attribute, IdPAttributeValue value) throws AttributeEncodingException {
- if (!(value instanceof StringAttributeValue)) {
- return null;
- }
- XSString result = theBuilder.buildObject(theQName);
- result.setValue((String) value.getValue());
- return result;
- }
-
- }
-
-}
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoderTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoderTest.java
deleted file mode 100644
index 68ffd84..0000000
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAMLAttributeEncoderTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.xml.namespace.QName;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.UninitializedComponentException;
-import net.shibboleth.utilities.java.support.component.UnmodifiableComponentException;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.XMLObjectBuilder;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- *
- */
-public class AbstractSAMLAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- private XMLObjectBuilder<XSString> theBuilder;
- private QName theQName = new QName("LocalQNAME");
- private final String MY_NAME = "myName";
- private final String MY_NAMESPACE = "myNameSpace";
- private final String ATTRIBUTE_ID = "attrID";
- private final String ATTRIBUTE_VALUE_1 = "attrValOne";
- private final String ATTRIBUTE_VALUE_2 = "attrValeTwo";
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- theBuilder = XMLObjectProviderRegistrySupport.getBuilderFactory().<XSString>getBuilderOrThrow(XSString.TYPE_NAME);
- }
-
- @Test public void initializeAndSetters() throws AttributeEncodingException, ComponentInitializationException {
- AbstractSAML1AttributeEncoder encoder = new mockEncoder(theBuilder, theQName);
-
- Assert.assertNull(encoder.getName());
- Assert.assertEquals(encoder.getNamespace(), "urn:mace:shibboleth:1.0:attributeNamespace:uri");
-
- try {
- encoder.setName("");
- Assert.fail();
- } catch (ConstraintViolationException e) {
-
- }
-
- encoder = new mockEncoder(theBuilder, theQName);
- try {
- encoder.setNamespace("");
- Assert.fail();
- } catch (ConstraintViolationException e) {
-
- }
-
- encoder = new mockEncoder(theBuilder, theQName);
- encoder.setNamespace(MY_NAMESPACE);
- encoder.setName(MY_NAME);
-
- try {
- encoder.encode(new IdPAttribute(ATTRIBUTE_ID));
- Assert.fail();
- } catch (UninitializedComponentException ex) {
- // OK
- }
-
- encoder.initialize();
- try {
- encoder.setName(" ");
- Assert.fail();
- } catch (UnmodifiableComponentException ex) {
- //
- }
-
- try {
- encoder.setNamespace(" ");
- Assert.fail();
- } catch (UnmodifiableComponentException ex) {
- //
- }
-
- }
-
- @Test public void encode() throws AttributeEncodingException, ComponentInitializationException {
- AbstractSAML1AttributeEncoder encoder = new mockEncoder(theBuilder, theQName);
- encoder.setNamespace(MY_NAMESPACE);
- encoder.setName(MY_NAME);
- encoder.initialize();
- IdPAttribute attr = new IdPAttribute(ATTRIBUTE_ID);
-
- try {
- encoder.encode(attr);
- } catch (AttributeEncodingException e) {
- // OK
- }
-
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values = new ArrayList<>(
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}),
- null,
- new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
-
- @Override
- public String getDisplayValue() {
- return intArray.toString();
- }
- }
- ));
- attr.setValues(values);
- try {
- encoder.encode(attr);
- } catch (AttributeEncodingException e) {
- // OK
- }
- values.add(new StringAttributeValue(ATTRIBUTE_VALUE_1));
- values.add(new StringAttributeValue(ATTRIBUTE_VALUE_2));
- attr.setValues(values);
-
- List<XMLObject> result = ((Attribute) encoder.encode(attr)).getAttributeValues();
-
- Assert.assertEquals(result.size(), 2);
- Set<String> resultSet = new HashSet<>(2);
- for (XMLObject o: result) {
- Assert.assertTrue(o instanceof XSString);
- resultSet.add(((XSString) o).getValue());
- }
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_1));
- Assert.assertTrue(resultSet.contains(ATTRIBUTE_VALUE_2));
-
- }
-
- @Test public void equalsHash() {
- mockEncoder enc1 = new mockEncoder(theBuilder, theQName);
- Assert.assertEquals(enc1, enc1);
- Assert.assertNotSame(enc1, null);
- Assert.assertNotSame(enc1, this);
-
- mockEncoder enc2 = new mockEncoder(theBuilder, theQName);
-
- Assert.assertEquals(enc1, enc2);
- Assert.assertEquals(enc1.hashCode(), enc2.hashCode());
- enc1.setName(MY_NAME);
- enc1.setNamespace(MY_NAMESPACE);
- enc2.setName(MY_NAME);
- enc2.setNamespace(MY_NAMESPACE);
- Assert.assertEquals(enc1, enc2);
- Assert.assertEquals(enc1.hashCode(), enc2.hashCode());
- enc2.setName(MY_NAME + MY_NAME);
- Assert.assertNotSame(enc1, enc2);
- Assert.assertNotSame(enc1.hashCode(), enc2.hashCode());
- enc2.setName(MY_NAME);
- enc2.setNamespace(MY_NAME);
- Assert.assertNotSame(enc1, enc2);
- Assert.assertNotSame(enc1.hashCode(), enc2.hashCode());
- }
-
- protected static class mockEncoder extends AbstractSAML1AttributeEncoder {
-
- @Nonnull private final XMLObjectBuilder<XSString> builder;
- @Nonnull private final QName myQName;
-
- /**
- * Constructor.
- *
- * @param theBuilder
- * @param theQName
- */
- public mockEncoder(@Nonnull final XMLObjectBuilder<XSString> theBuilder, @Nonnull final QName theQName) {
- builder = theBuilder;
- myQName = theQName;
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) {
- return ! (value instanceof ByteAttributeValue);
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) throws AttributeEncodingException {
- if (!(value instanceof StringAttributeValue)) {
- return null;
- }
- XSString result = builder.buildObject(myQName);
- result.setValue((String) value.getValue());
- return result;
- }
-
- }
-}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoder.java
deleted file mode 100644
index 3e53911..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML1AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml1.core.AttributeValue;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces SAML 1 attributes from an
- * {@link IdPAttribute} that contains <code>byte[]</code> values.
- */
-public class SAML1ByteAttributeEncoder extends AbstractSAML1AttributeEncoder<ByteAttributeValue> {
-
- /** {@inheritDoc} */
- @Override
- protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute, @Nonnull final IdPAttributeValue value) {
- return value instanceof ByteAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final ByteAttributeValue value) throws AttributeEncodingException {
- return SAMLEncoderSupport.encodeByteArrayValue(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue(), encodeType());
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoder.java
deleted file mode 100644
index 8912aa1..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoder.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML1AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces SAML 1 attributes from an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} that contains scoped string values.
- */
-public class SAML1ScopedStringAttributeEncoder extends AbstractSAML1AttributeEncoder<ScopedStringAttributeValue> {
-
- /** The log. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML1ScopedStringAttributeEncoder.class);
-
- /** Type of scoping to use. */
- @Nullable private String scopeType;
-
- /** Delimiter used for "inline" scopeType. */
- @Nullable private String scopeDelimiter;
-
- /** Attribute name used for "attribute" scopeType. */
- @Nullable private String scopeAttributeName;
-
- /**
- * Constructor.
- *
- */
- public SAML1ScopedStringAttributeEncoder() {
- scopeDelimiter = "@";
- scopeAttributeName = "Scope";
- scopeType = "attribute";
-
- // Turn off type encoding, because we default to a non-built-in type that consumers won't
- // have the schema for.
- setEncodeType(false);
- }
-
- /**
- * Get the name of the non-inline scope-carrying attribute.
- *
- * @return the name of the scope-carrying attribute
- */
- @Nullable public String getScopeAttributeName() {
- return scopeAttributeName;
- }
-
- /**
- * Get the scope delimiter.
- *
- * @return the scope delimiter
- */
- @Nullable public String getScopeDelimiter() {
- return scopeDelimiter;
- }
-
- /**
- * Get the scope syntax type.
- *
- * @return the type of scope syntax to use
- */
- @Nullable public String getScopeType() {
- return scopeType;
- }
-
- /**
- * Set the name of the non-inline scope-carrying attribute.
- *
- * @param newScopeAttribute the name to set
- */
- public void setScopeAttributeName(@Nullable final String newScopeAttribute) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeAttributeName = StringSupport.trimOrNull(newScopeAttribute);
- }
-
- /**
- * Set the scope delimiter.
- *
- * @param newScopeDelimiter delimiter to set
- */
- public void setScopeDelimiter(@Nullable final String newScopeDelimiter) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeDelimiter = StringSupport.trimOrNull(newScopeDelimiter);
- }
-
- /**
- * Set the scope syntax type.
- *
- * @param newScopeType the scope syntax type
- */
- public void setScopeType(@Nullable final String newScopeType) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeType = StringSupport.trimOrNull(newScopeType);
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (null == getScopeType()) {
- log.debug("Scope type not set, assuming \"attribute\"");
- scopeType = "attribute";
- }
-
- if ("attribute".equals(getScopeType())) {
- if (null == getScopeAttributeName()) {
- throw new ComponentInitializationException(
- "Encoder of type \"attribute\" must specify a scope attribute name");
- }
- } else if ("inline".equals(getScopeType())) {
- if (null == getScopeDelimiter()) {
- throw new ComponentInitializationException("Encoder of type \"inline\" must specify a scope delimiter");
- }
- } else {
- throw new ComponentInitializationException("Encoder scope type must be set to \"inline\" or \"attribute\"");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute, @Nonnull final IdPAttributeValue value) {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- return value instanceof ScopedStringAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final ScopedStringAttributeValue value) throws AttributeEncodingException {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- if ("attribute".equals(getScopeType())) {
- return SAMLEncoderSupport.encodeScopedStringValueAttribute(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value, getScopeAttributeName(), encodeType());
- } else {
- return SAMLEncoderSupport.encodeScopedStringValueInline(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value, getScopeDelimiter(), encodeType());
- }
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoder.java
deleted file mode 100644
index 7b80268..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoder.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.LocalizedStringAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML1AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces SAML 1 attributes from an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} that contains <code>String</code> values.
- */
-public class SAML1StringAttributeEncoder extends AbstractSAML1AttributeEncoder<StringAttributeValue> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML1StringAttributeEncoder.class);
-
- /** {@inheritDoc} */
- @Override
- protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute, @Nonnull final IdPAttributeValue value) {
- return value instanceof StringAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final StringAttributeValue value) throws AttributeEncodingException {
- if (value instanceof LocalizedStringAttributeValue || value instanceof ScopedStringAttributeValue) {
- log.warn("Attribute '{}': Lossy encoding of attribute value of type {} to SAML1 String Attribute",
- attribute.getId(), value.getClass().getName());
- }
- return SAMLEncoderSupport.encodeStringValue(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue(), encodeType());
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoder.java
deleted file mode 100644
index e1ce07d..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML1AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml1.core.AttributeValue;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces SAML 1 attributes from an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} that contains {@link XMLObjectAttributeValue} values.
- */
-public class SAML1XMLObjectAttributeEncoder extends AbstractSAML1AttributeEncoder<XMLObjectAttributeValue> {
-
- /** {@inheritDoc} */
- @Override
- protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute, @Nonnull final IdPAttributeValue value) {
- return value instanceof XMLObjectAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override
- @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final XMLObjectAttributeValue value) throws AttributeEncodingException {
- return SAMLEncoderSupport.encodeXMLObjectValue(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue());
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoder.java
deleted file mode 100644
index 1350f84..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML2AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeMapperProcessor;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.ByteAttributeValueMapper;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces a SAML 2 Attribute from an {@link IdPAttribute}
- * that contains <code>byte[]</code> values.
- */
-public class SAML2ByteAttributeEncoder extends AbstractSAML2AttributeEncoder<ByteAttributeValue> implements
- AttributeMapperProcessor<RequestedAttribute, IdPRequestedAttribute> {
-
- /** {@inheritDoc} */
- @Override protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) {
- return value instanceof ByteAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final ByteAttributeValue value) throws AttributeEncodingException {
- return SAMLEncoderSupport.encodeByteArrayValue(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue(), encodeType());
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public void populateAttributeMapper(final
- AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper) {
- mapper.setAttributeFormat(getNameFormat());
- mapper.setId(getMapperId());
- mapper.setSAMLName(getName());
- mapper.setValueMapper(new ByteAttributeValueMapper());
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoder.java
deleted file mode 100644
index 8156190..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoder.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML2AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeMapperProcessor;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.ScopedStringAttributeValueMapper;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces a SAML 2 Attribute from an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} that contains scoped string values.
- */
-public class SAML2ScopedStringAttributeEncoder extends AbstractSAML2AttributeEncoder<ScopedStringAttributeValue>
- implements AttributeMapperProcessor<RequestedAttribute, IdPRequestedAttribute> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML2ScopedStringAttributeEncoder.class);
-
- /** Type of scoping to use. */
- @Nullable private String scopeType;
-
- /** Delimiter used for "inline" scopeType. */
- @Nullable private String scopeDelimiter;
-
- /** Attribute name used for "attribute" scopeType. */
- @Nullable private String scopeAttributeName;
-
- /**
- * Constructor.
- *
- */
- public SAML2ScopedStringAttributeEncoder() {
- scopeDelimiter = "@";
- scopeAttributeName = "Scope";
- scopeType = "inline";
- }
-
- /**
- * Get the name of the non-inline scope-carrying attribute.
- *
- * @return the name of the scope-carrying attribute
- */
- @Nullable public String getScopeAttributeName() {
- return scopeAttributeName;
- }
-
- /**
- * Get the scope delimiter.
- *
- * @return the scope delimiter
- */
- @Nullable public String getScopeDelimiter() {
- return scopeDelimiter;
- }
-
- /**
- * Get the scope syntax type.
- *
- * @return the type of scope syntax to use
- */
- @Nullable public String getScopeType() {
- return scopeType;
- }
-
- /**
- * Set the name of the non-inline scope-carrying attribute.
- *
- * @param newScopeAttribute the name to set
- */
- public void setScopeAttributeName(@Nullable final String newScopeAttribute) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeAttributeName = StringSupport.trimOrNull(newScopeAttribute);
- }
-
- /**
- * Set the scope delimiter.
- *
- * @param newScopeDelimiter delimiter to set
- */
- public void setScopeDelimiter(@Nullable final String newScopeDelimiter) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeDelimiter = StringSupport.trimOrNull(newScopeDelimiter);
- }
-
- /**
- * Set the scope syntax type.
- *
- * @param newScopeType the scope syntax type
- */
- public void setScopeType(@Nullable final String newScopeType) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- scopeType = StringSupport.trimOrNull(newScopeType);
- }
-
- /**
- * Ensures that the values we will need are all there.
- *
- * {@inheritDoc}
- */
- @Override protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (null == getScopeType()) {
- log.debug("Scope type not set, assuming \"inline\"");
- scopeType = "inline";
- }
-
- if ("attribute".equals(getScopeType())) {
- if (null == getScopeAttributeName()) {
- throw new ComponentInitializationException(
- "Encoder of type \"attribute\" must specify a scope attribute name");
- }
- } else if ("inline".equals(getScopeType())) {
- if (null == getScopeDelimiter()) {
- throw new ComponentInitializationException("Encoder of type \"inline\" must specify a scope delimiter");
- }
- } else {
- throw new ComponentInitializationException("Encoder scope type must be set to \"inline\" or \"attribute\"");
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- return value instanceof ScopedStringAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final ScopedStringAttributeValue value) throws AttributeEncodingException {
- ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-
- if ("attribute".equals(getScopeType())) {
- return SAMLEncoderSupport.encodeScopedStringValueAttribute(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value, getScopeAttributeName(), encodeType());
- } else {
- return SAMLEncoderSupport.encodeScopedStringValueInline(
- attribute, AttributeValue.DEFAULT_ELEMENT_NAME, value, getScopeDelimiter(), encodeType());
- }
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public void populateAttributeMapper(
- final AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper) {
- mapper.setAttributeFormat(getNameFormat());
- mapper.setId(getMapperId());
- mapper.setSAMLName(getName());
- final ScopedStringAttributeValueMapper foo = new ScopedStringAttributeValueMapper();
- foo.setDelimiter(getScopeDelimiter());
- mapper.setValueMapper(foo);
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoder.java
deleted file mode 100644
index d317a93..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoder.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.LocalizedStringAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML2AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeMapperProcessor;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.StringAttributeValueMapper;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces a SAML 2 Attribute from an {@link IdPAttribute}
- * that contains <code>String</code> values.
- */
-public class SAML2StringAttributeEncoder extends AbstractSAML2AttributeEncoder<StringAttributeValue> implements
- AttributeMapperProcessor<RequestedAttribute, IdPRequestedAttribute> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML2StringAttributeEncoder.class);
-
- /** {@inheritDoc} */
- @Override protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) {
- return value instanceof StringAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final StringAttributeValue value) throws AttributeEncodingException {
- if (value instanceof LocalizedStringAttributeValue || value instanceof ScopedStringAttributeValue) {
- log.warn("Attribute '{}': Lossy encoding of attribute value of type {} to SAML2 String Attribute",
- attribute.getId(), value.getClass().getName());
- }
- return SAMLEncoderSupport.encodeStringValue(attribute,
- AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue(), encodeType());
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public void populateAttributeMapper(
- final AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper) {
- mapper.setAttributeFormat(getNameFormat());
- mapper.setId(getMapperId());
- mapper.setSAMLName(getName());
- mapper.setValueMapper(new StringAttributeValueMapper());
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoder.java
deleted file mode 100644
index 097a035..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.idp.saml.attribute.encoding.AbstractSAML2AttributeEncoder;
-import net.shibboleth.idp.saml.attribute.encoding.AttributeMapperProcessor;
-import net.shibboleth.idp.saml.attribute.encoding.SAMLEncoderSupport;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.impl.XMLObjectAttributeValueMapper;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-
-/**
- * {@link net.shibboleth.idp.attribute.AttributeEncoder} that produces a SAML 2 Attribute from an {@link IdPAttribute}
- * that contains {@link XMLObject} values.
- */
-public class SAML2XMLObjectAttributeEncoder extends AbstractSAML2AttributeEncoder<XMLObjectAttributeValue> implements
- AttributeMapperProcessor<RequestedAttribute, IdPRequestedAttribute> {
-
- /** {@inheritDoc} */
- @Override protected boolean canEncodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final IdPAttributeValue value) {
- return value instanceof XMLObjectAttributeValue;
- }
-
- /** {@inheritDoc} */
- @Override @Nullable protected XMLObject encodeValue(@Nonnull final IdPAttribute attribute,
- @Nonnull final XMLObjectAttributeValue value) throws AttributeEncodingException {
- return SAMLEncoderSupport
- .encodeXMLObjectValue(attribute, AttributeValue.DEFAULT_ELEMENT_NAME, value.getValue());
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public void populateAttributeMapper(
- final AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper) {
-
- mapper.setAttributeFormat(getNameFormat());
- mapper.setId(getMapperId());
- mapper.setSAMLName(getName());
- mapper.setValueMapper(new XMLObjectAttributeValueMapper());
-
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/package-info.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/package-info.java
deleted file mode 100644
index 3760d3e..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/** SAML specific {@link net.shibboleth.idp.attribute.AttributeEncoder} implementations. */
-
-package net.shibboleth.idp.saml.attribute.encoding.impl;
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ByteAttributeValueMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ByteAttributeValueMapper.java
deleted file mode 100644
index 55fd0aa..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ByteAttributeValueMapper.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeValueMapper;
-import net.shibboleth.utilities.java.support.codec.Base64Support;
-
-import org.opensaml.core.xml.XMLObject;
-
-/**
- * Mapping extract a {@link ByteAttributeValue} from an AttributeValue.
- */
-public class ByteAttributeValueMapper extends AbstractSAMLAttributeValueMapper {
-
- /** {@inheritDoc} */
- @Nullable protected IdPAttributeValue<?> decodeValue(@Nonnull final XMLObject object) {
- final String value = getStringValue(object);
- if (null == value) {
- return null;
- }
- final byte[] decoded = Base64Support.decode(value);
- if (null == decoded) {
- return null;
- }
- return ByteAttributeValue.valueOf(decoded);
- }
-
- /** {@inheritDoc} */
- @Nonnull protected String getAttributeTypeName() {
- return "Base64Encoded";
- }
-}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapper.java
deleted file mode 100644
index e6227f3..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-
-/** A class that maps a SAML2 {@link RequestedAttribute} into an IdP {@link IdPRequestedAttribute}. */
-public class RequestedAttributeMapper extends AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute> {
-
- /** {@inheritDoc} */
- @Override
- @Nonnull protected IdPRequestedAttribute newAttribute(@Nonnull final RequestedAttribute input,
- @Nonnull @NotEmpty final String id) {
- final IdPRequestedAttribute output = new IdPRequestedAttribute(id);
- output.setRequired(input.isRequired());
- return output;
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapper.java
deleted file mode 100644
index d5affc5..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributesMapper;
-
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-
-import com.google.common.base.Supplier;
-
-/**
- * This class conceptually represents the content of a attribute-map file, hence it describes (and then does) the
- * mappings from a {@link java.util.List} of SAML2 {@link RequestedAttribute} into a
- * {@link com.google.common.collect.Multimap} going from (SAML2) attributeId to {@link IdPRequestedAttribute}s.
- *
- */
-public class RequestedAttributesMapper extends AbstractSAMLAttributesMapper<RequestedAttribute, IdPRequestedAttribute> {
-
- /** Default constructor. */
- public RequestedAttributesMapper() {
-
- }
-
- /**
- * Generate a specific mapper to go from {@link RequestedAttribute} to {@link IdPRequestedAttribute} by inverting
- * the function of the mappers in the profiled {@link AttributeResolver}.
- *
- * @param resolver resolver to invert
- */
- public RequestedAttributesMapper(@Nonnull final AttributeResolver resolver) {
- super(resolver, "RequestedMapper<" + resolver.getId() + ">",
- new Supplier<AbstractSAMLAttributeMapper<RequestedAttribute, IdPRequestedAttribute>>() {
-
- @Override public RequestedAttributeMapper get() {
- return new RequestedAttributeMapper();
- }
- });
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorMapper.java
deleted file mode 100644
index 990e0ce..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorMapper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeDesignatorMapper;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-
-import org.opensaml.saml.saml1.core.AttributeDesignator;
-
-/** A class that maps a SAML1 {@link AttributeDesignator} into an IdP {@link IdPAttribute}. */
-public class SAML1AttributeDesignatorMapper extends AbstractSAMLAttributeDesignatorMapper<IdPAttribute> {
-
- /** {@inheritDoc} */
- @Override
- @Nonnull protected IdPAttribute newAttribute(@Nonnull final AttributeDesignator input,
- @Nonnull @NotEmpty final String id) {
- return new IdPAttribute(id);
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapper.java
deleted file mode 100644
index bb3348a..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeDesignatorMapper;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeDesignatorsMapper;
-
-import com.google.common.base.Supplier;
-
-/**
- * This class conceptually represents the content of a attribute-map file, hence it describes (and then does) the
- * mappings from a {@link java.util.List} of SAML1 {@link org.opensaml.saml.saml1.core.AttributeDesignator} into a
- * {@link com.google.common.collect.Multimap} going from (SAML1) attributeId to {@link IdPAttribute}s.
- *
- */
-public class SAML1AttributeDesignatorsMapper extends AbstractSAMLAttributeDesignatorsMapper<IdPAttribute> {
-
- /** Default constructor. */
- public SAML1AttributeDesignatorsMapper() {
-
- }
-
- /**
- * Generate a specific mapper to go from {@link org.opensaml.saml.saml1.core.AttributeDesignator} to
- * {@link IdPAttribute} by inverting the function of the mappers in the profiled {@link AttributeResolver}.
- *
- * @param resolver resolver to invert
- */
- public SAML1AttributeDesignatorsMapper(@Nonnull final AttributeResolver resolver) {
- super(resolver, "Mapper<" + resolver.getId() + ">",
- new Supplier<AbstractSAMLAttributeDesignatorMapper<IdPAttribute>>() {
-
- @Override public SAML1AttributeDesignatorMapper get() {
- return new SAML1AttributeDesignatorMapper();
- }
- });
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapperService.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapperService.java
deleted file mode 100644
index cc44d99..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML1AttributeDesignatorsMapperService.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.time.Instant;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.opensaml.saml.saml1.core.AttributeDesignator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.mapping.AttributesMapper;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.service.ReloadableService;
-import net.shibboleth.utilities.java.support.service.ServiceableComponent;
-
-/**
- * An implementation of {@link SAML1AttributeDesignatorsMapper} for use by objects that
- * can't just store a constructed mapper themselves, such as action beans.
- */
- at ThreadSafe
-public class SAML1AttributeDesignatorsMapperService implements AttributesMapper<AttributeDesignator,IdPAttribute> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML1AttributeDesignatorsMapperService.class);
-
- /** Service used to get the resolver used to fetch attributes. */
- @Nonnull private final ReloadableService<AttributeResolver> attributeResolverService;
-
- /** Whether the last invocation of {@link ReloadableService#reload()}
- * on {@link #attributeResolverService} failed. This limits the noise in log file. */
- @Nonnull private boolean captiveServiceReloadFailed;
-
- /** Cached AttributeMapper. */
- @Nullable private SAML1AttributeDesignatorsMapper attributesMapper;
-
- /** Date when the cache was last refreshed. */
- @Nullable private Instant lastReload;
-
- /**
- * Constructor.
- *
- * @param resolverService the service for the attribute resolver we are to derive mapping info from
- */
- public SAML1AttributeDesignatorsMapperService(
- @Nonnull @ParameterName(name="resolverService")
- final ReloadableService<AttributeResolver> resolverService) {
- attributeResolverService = Constraint.isNotNull(resolverService, "AttributeResolver cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull @NonnullElements public Multimap<String, IdPAttribute> mapAttributes(
- @Nonnull @NonnullElements final List<AttributeDesignator> prototypes) {
-
- final SAML1AttributeDesignatorsMapper mapper = getMapper();
- if (null == mapper) {
- log.error("No AttributeMapper available, returning nothing");
- return ArrayListMultimap.create();
- }
-
- return mapper.mapAttributes(prototypes);
- }
-
- /**
- * Check to see if a reload of the mapper is required and do so, and return whatever should be used.
- *
- * @return the mapper to use
- */
- @Nullable private SAML1AttributeDesignatorsMapper getMapper() {
-
- if (lastReload != null && lastReload.equals(attributeResolverService.getLastSuccessfulReloadInstant())) {
- // Nothing has changed since we last reloaded.
- return attributesMapper;
- }
-
- // Reload.
- ServiceableComponent<AttributeResolver> component = null;
- SAML1AttributeDesignatorsMapper am = null;
- try {
- // Get date before we get the component. That way we'll not leak changes.
- final Instant when = attributeResolverService.getLastSuccessfulReloadInstant();
- component = attributeResolverService.getServiceableComponent();
- if (null == component) {
- if (!captiveServiceReloadFailed) {
- log.error("Invalid AttributeResolver configuration");
- }
- captiveServiceReloadFailed = true;
- } else {
- final AttributeResolver attributeResolver = component.getComponent();
- am = new SAML1AttributeDesignatorsMapper(attributeResolver);
- captiveServiceReloadFailed = false;
- lastReload = when;
- }
- } finally {
- if (null != component) {
- component.unpinComponent();
- }
- }
-
- try {
- if (null != am) {
- am.initialize();
- }
- } catch (final ComponentInitializationException e) {
- log.error("Error initializing AttributeMapper", e);
- }
-
- attributesMapper = am;
- return am;
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributeMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributeMapper.java
deleted file mode 100644
index 3c0f3cc..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributeMapper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-
-import org.opensaml.saml.saml2.core.Attribute;
-
-/** A class that maps a SAML2 {@link Attribute} into an IdP {@link IdPAttribute}. */
-public class SAML2AttributeMapper extends AbstractSAMLAttributeMapper<Attribute, IdPAttribute> {
-
- /** {@inheritDoc} */
- @Override
- @Nonnull protected IdPAttribute newAttribute(@Nonnull final Attribute input, @Nonnull @NotEmpty final String id) {
- return new IdPAttribute(id);
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapper.java
deleted file mode 100644
index cbaea518..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeMapper;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributesMapper;
-
-import org.opensaml.saml.saml2.core.Attribute;
-
-import com.google.common.base.Supplier;
-
-/**
- * This class conceptually represents the content of a attribute-map file, hence it describes (and then does) the
- * mappings from a {@link java.util.List} of SAML2 {@link Attribute} into a {@link com.google.common.collect.Multimap}
- * going from (SAML2) attributeId to {@link IdPAttribute}s.
- *
- */
-public class SAML2AttributesMapper extends AbstractSAMLAttributesMapper<Attribute, IdPAttribute> {
-
- /** Default constructor. */
- public SAML2AttributesMapper() {
-
- }
-
- /**
- * Generate a specific mapper to go from {@link Attribute} to {@link IdPAttribute} by inverting
- * the function of the mappers in the profiled {@link AttributeResolver}.
- *
- * @param resolver resolver to invert
- */
- public SAML2AttributesMapper(@Nonnull final AttributeResolver resolver) {
- super(resolver, "Mapper<" + resolver.getId() + ">",
- new Supplier<AbstractSAMLAttributeMapper<Attribute, IdPAttribute>>() {
-
- @Override public SAML2AttributeMapper get() {
- return new SAML2AttributeMapper();
- }
- });
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapperService.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapperService.java
deleted file mode 100644
index bc30707..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/SAML2AttributesMapperService.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.time.Instant;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.opensaml.saml.saml2.core.Attribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeResolver;
-import net.shibboleth.idp.saml.attribute.mapping.AttributesMapper;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.service.ReloadableService;
-import net.shibboleth.utilities.java.support.service.ServiceableComponent;
-
-/**
- * An implementation of {@link SAML2AttributesMapper} for use by objects that can't just store a constructed mapper
- * themselves, such as action beans.
- */
- at ThreadSafe
-public class SAML2AttributesMapperService implements AttributesMapper<Attribute, IdPAttribute> {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML2AttributesMapperService.class);
-
- /** Service used to get the resolver used to fetch attributes. */
- @Nonnull private final ReloadableService<AttributeResolver> attributeResolverService;
-
- /** Whether the last invocation of {@link ReloadableService#reload()}
- * on {@link #attributeResolverService} failed. This limits the noise in log file. */
- @Nonnull private boolean captiveServiceReloadFailed;
-
- /** Cached AttributeMapper. */
- @Nullable private SAML2AttributesMapper attributesMapper;
-
- /** Date when the cache was last refreshed. */
- @Nullable private Instant lastReload;
-
- /**
- * Constructor.
- *
- * @param resolverService the service for the attribute resolver we are to derive mapping info from
- */
- public SAML2AttributesMapperService(@Nonnull @ParameterName(name="resolverService")
- final ReloadableService<AttributeResolver> resolverService) {
- attributeResolverService = Constraint.isNotNull(resolverService, "AttributeResolver cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull @NonnullElements public Multimap<String, IdPAttribute> mapAttributes(
- @Nonnull @NonnullElements final List<Attribute> prototypes) {
-
- final SAML2AttributesMapper mapper = getMapper();
- if (null == mapper) {
- log.error("No AttributeMapper available, returning nothing");
- return ArrayListMultimap.create();
- }
-
- return mapper.mapAttributes(prototypes);
- }
-
- /**
- * Check to see if a reload of the mapper is required and do so, and return whatever should be used.
- *
- * @return the mapper to use
- */
- @Nullable private SAML2AttributesMapper getMapper() {
-
- if (lastReload != null && lastReload.equals(attributeResolverService.getLastSuccessfulReloadInstant())) {
- // Nothing has changed since we last reloaded.
- return attributesMapper;
- }
-
- // Reload.
- ServiceableComponent<AttributeResolver> component = null;
- SAML2AttributesMapper am = null;
- try {
- // Get date before we get the component. That way we'll not leak changes.
- final Instant when = attributeResolverService.getLastSuccessfulReloadInstant();
- component = attributeResolverService.getServiceableComponent();
- if (null == component) {
- if (!captiveServiceReloadFailed) {
- log.error("Invalid AttributeResolver configuration");
- }
- captiveServiceReloadFailed = true;
- } else {
- final AttributeResolver attributeResolver = component.getComponent();
- am = new SAML2AttributesMapper(attributeResolver);
- captiveServiceReloadFailed = false;
- lastReload = when;
- }
- } finally {
- if (null != component) {
- component.unpinComponent();
- }
- }
-
- try {
- if (null != am) {
- am.initialize();
- }
- } catch (final ComponentInitializationException e) {
- log.error("Error initializing AttributeMapper", e);
- }
-
- attributesMapper = am;
- return am;
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ScopedStringAttributeValueMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ScopedStringAttributeValueMapper.java
deleted file mode 100644
index a356831..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/ScopedStringAttributeValueMapper.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeValueMapper;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
-import org.opensaml.core.xml.XMLObject;
-
-import com.google.common.base.Objects;
-
-/**
- * Mapping to extract a {@link net.shibboleth.idp.attribute.ScopedStringAttributeValue} from an AttributeValue.
- */
-public class ScopedStringAttributeValueMapper extends AbstractSAMLAttributeValueMapper {
-
- /** The scope delimiter. */
- private String delimiter = "@";
-
- /**
- * Returns the delimiter.
- *
- * @return the delimiter
- */
- @Nonnull public String getDelimiter() {
- return delimiter;
- }
-
- /**
- * Sets the delimiter.
- *
- * @param delim what to set.
- */
- public void setDelimiter(@Nonnull @NotEmpty final String delim) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- final String trimmed = StringSupport.trimOrNull(delim);
- Constraint.isNotNull(trimmed, "ScopedStringAttributeDecoder: delimiter can not be empty null");
- delimiter = trimmed;
- }
-
- /** {@inheritDoc} */
- @Nullable protected IdPAttributeValue<?> decodeValue(@Nonnull final XMLObject object) {
- Constraint.isNotNull(object, "Object supplied to must not be null");
- final String stringValue = getStringValue(object);
-
- if (null == stringValue) {
- return null;
- }
-
- final int offset = stringValue.indexOf(getDelimiter());
-
- if (offset < 0) {
- return null;
- }
-
- return ScopedStringAttributeValue.valueOf(stringValue.substring(0, offset), stringValue.substring(offset
- + getDelimiter().length()));
- }
-
- /** {@inheritDoc} */
- @Nonnull protected String getAttributeTypeName() {
- return "Scoped";
- }
-
- /** {@inheritDoc} */
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (obj instanceof ScopedStringAttributeValueMapper) {
- final ScopedStringAttributeValueMapper other = (ScopedStringAttributeValueMapper) obj;
- return java.util.Objects.equals(getDelimiter(), other.getDelimiter());
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public int hashCode() {
- return Objects.hashCode(getAttributeTypeName(), getDelimiter());
- }
-
-}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/StringAttributeValueMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/StringAttributeValueMapper.java
deleted file mode 100644
index aca6bbd..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/StringAttributeValueMapper.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeValueMapper;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
-import org.opensaml.core.xml.XMLObject;
-
-/**
- * Mapping extract a {@link org.opensaml.core.xml.schema.XSString} from an {@link IdPAttributeValue}.
- */
-public class StringAttributeValueMapper extends AbstractSAMLAttributeValueMapper {
-
- /** {@inheritDoc} */
- @Nullable protected IdPAttributeValue<?> decodeValue(final XMLObject object) {
- Constraint.isNotNull(object, "Object supplied to must not be null");
- final String value = getStringValue(object);
- if (null == value) {
- return null;
- }
- return StringAttributeValue.valueOf(value);
- }
-
- /** {@inheritDoc} */
- @Nonnull protected String getAttributeTypeName() {
- return "String";
- }
-}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/XMLObjectAttributeValueMapper.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/XMLObjectAttributeValueMapper.java
deleted file mode 100644
index 3d59d39..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/XMLObjectAttributeValueMapper.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeValueMapper;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
-import org.opensaml.core.xml.XMLObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-
-/**
- * Decoder for {@link XMLObject} into {@link XMLObjectAttributeValue}.
- */
-public class XMLObjectAttributeValueMapper extends AbstractSAMLAttributeValueMapper {
-
- /** logger . */
- private Logger log = LoggerFactory.getLogger(XMLObjectAttributeValueMapper.class);
-
- /** Do we treat the entire AttributeValue as the object to be embedded. */
- private boolean includeAttributeValue;
-
- /** Do we include the attribute value, or just its first child?
- * @return Returns the includeAttributeValue.
- */
- public boolean isIncludeAttributeValue() {
- return includeAttributeValue;
- }
-
- /** Sets whether we look at the AttributeValue, or just its child.
- * @param doInclude The includeAttributeValue to set.
- */
- public void setIncludeAttributeValue(final boolean doInclude) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- includeAttributeValue = doInclude;
- }
-
-
- /** {@inheritDoc} */
- @Nullable protected IdPAttributeValue decodeValue(@Nonnull final XMLObject object) {
- Constraint.isNotNull(object, "Object supplied to must not be null");
-
- if (includeAttributeValue) {
- return new XMLObjectAttributeValue(object);
- }
-
- final List<XMLObject> children = object.getOrderedChildren();
-
- if (null == children || children.isEmpty()) {
- log.debug("{} attribute had no XML children, ignored", getLogPrefix());
- return null;
- }
- if (children.size() > 1) {
- log.debug("{} attribute has more than one child, returning first value only", getLogPrefix());
- }
- final XMLObject child = children.get(0);
- log.debug("{} returning value of type {}", getLogPrefix(), child.getClass().toString());
- return new XMLObjectAttributeValue(child);
- }
-
- /** {@inheritDoc} */
- @Nonnull protected String getAttributeTypeName() {
- return "XMLObject";
- }
-
- /** {@inheritDoc} */
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (obj instanceof XMLObjectAttributeValueMapper) {
- final XMLObjectAttributeValueMapper other = (XMLObjectAttributeValueMapper) obj;
- return isIncludeAttributeValue() == other.isIncludeAttributeValue();
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public int hashCode() {
- return Objects.hashCode(getClass(), isIncludeAttributeValue());
- }
-}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/package-info.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/package-info.java
deleted file mode 100644
index 748f560..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/mapping/impl/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Classes to do with the reverse mapping of SAML2 attributes into IdP Attributes.
- */
-package net.shibboleth.idp.saml.attribute.mapping.impl;
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoderTest.java
deleted file mode 100644
index ecaa61b..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ByteAttributeEncoderTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSBase64Binary;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.codec.Base64Support;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML1ByteAttributeEncoder} Unit test.
- *
- * Identical code to the {@link SAML1ByteAttributeEncoder} except that the type of assertion and encoder is changed.
- */
-public class SAML1ByteAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static byte[] BYTE_ARRAY_1 = {1, 2, 3, 4, 5};
-
- /** A second test value. */
- private final static byte[] BYTE_ARRAY_2 = {4, 3, 2, 1};
-
- private SAML1ByteAttributeEncoder encoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML1ByteAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNamespace("NameSpace");
- encoder.setEncodeType(true);
- encoder.initialize();
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty() throws Exception {
- final IdPAttribute inputAttribute;
-
- inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new StringAttributeValue("foo"), new ScopedStringAttributeValue(
- "foo", "bar"), new IdPAttributeValue<Object>() {
- public Object getValue() {
- return intArray;
- }
-
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new StringAttributeValue("foo"), new ByteAttributeValue(BYTE_ARRAY_1));
- final IdPAttribute inputAttribute;
-
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- XMLObject child = children.get(0);
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME);
-
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- XSBase64Binary childAsString = (XSBase64Binary) child;
-
- byte childAsBa[] = Base64Support.decode(childAsString.getValue());
-
- Assert.assertEquals(childAsBa, BYTE_ARRAY_1, "Input equals output");
- }
-
- @Test public void multi() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(BYTE_ARRAY_1),
- new ByteAttributeValue(BYTE_ARRAY_2));
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- XMLObject child = children.get(0);
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- XSBase64Binary childAsString = (XSBase64Binary) child;
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- final byte[] res0 = Base64Support.decode(childAsString.getValue());
-
- child = children.get(1);
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- childAsString = (XSBase64Binary) child;
- final byte[] res1 = Base64Support.decode(childAsString.getValue());
-
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (BYTE_ARRAY_1.length == res0.length) {
- Assert.assertEquals(BYTE_ARRAY_1, res0, "Input matches output");
- Assert.assertEquals(BYTE_ARRAY_2, res1, "Input matches output");
- } else if (BYTE_ARRAY_1.length == res1.length) {
- Assert.assertEquals(BYTE_ARRAY_1, res1, "Input matches output");
- Assert.assertEquals(BYTE_ARRAY_2, res0, "Input matches output");
- } else {
- Assert.assertTrue(BYTE_ARRAY_1.length == res1.length || BYTE_ARRAY_2.length == res1.length,
- "One of the output's size should match an input size");
- }
- }
-
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoderTest.java
deleted file mode 100644
index c1d725e..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1ScopedStringAttributeEncoderTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.saml.xmlobject.ScopedValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.UninitializedComponentException;
-
-/**
- * {@link SAML1ScopedStringAttributeEncoder} Unit test.
- */
-public class SAML1ScopedStringAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String VALUE_1 = "ValueTheFirst";
-
- /** A second test value. */
- private final static String VALUE_2 = "Second";
-
- /** A test scope . */
- private final static String SCOPE_1 = "scope1.example.org";
-
- /** A second test value. */
- private final static String SCOPE_2 = "scope2";
-
- private final static String DELIMITER = "#";
-
- private final static String ATTRIBUTE_NAME = "Scope";
-
- private final ScopedStringAttributeValue value1 = new ScopedStringAttributeValue(VALUE_1, SCOPE_1);
-
- private final ScopedStringAttributeValue value2 = new ScopedStringAttributeValue(VALUE_2, SCOPE_2);
-
- public SAML1ScopedStringAttributeEncoder makeEncoder() {
- final SAML1ScopedStringAttributeEncoder encoder = new SAML1ScopedStringAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setScopeAttributeName(ATTRIBUTE_NAME);
- encoder.setNamespace("NameSpace");
- encoder.setEncodeType(true);
- return encoder;
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty()
- throws AttributeEncodingException, ComponentInitializationException {
- final IdPAttribute inputAttribute;
-
- inputAttribute = new IdPAttribute(ATTR_NAME);
-
- SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.initialize();
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate()
- throws AttributeEncodingException, ComponentInitializationException {
- final SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), new StringAttributeValue("dd"),
- new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
- try {
- encoder.encode(inputAttribute);
- Assert.fail("not initialized");
- } catch (UninitializedComponentException e) {
- // OK
- }
- encoder.initialize();
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws ComponentInitializationException, AttributeEncodingException {
- final SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- try {
- encoder.setScopeAttributeName(null);
- encoder.initialize();
- Assert.fail("Missing attribute name should throw");
- } catch (ComponentInitializationException e) {
- // OK
- }
- encoder.setScopeAttributeName(ATTRIBUTE_NAME);
- encoder.setScopeDelimiter(DELIMITER);
-
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1);
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.initialize();
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof ScopedValue, "Child of result attribute should be a string");
-
- final ScopedValue childAsScopedValue = (ScopedValue) child;
-
- Assert.assertEquals(childAsScopedValue.getValue(), VALUE_1, "Input equals output");
- Assert.assertEquals(childAsScopedValue.getScope(), SCOPE_1, "Input equals output");
-
- }
-
- @Test public void multi() throws ComponentInitializationException, AttributeEncodingException {
- final SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.initialize();
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1, value2);
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertTrue(children.get(0) instanceof ScopedValue && children.get(1) instanceof ScopedValue,
- "Child of result attribute should be a string");
-
- final ScopedValue child1 = (ScopedValue) children.get(0);
- Assert.assertEquals(child1.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- final ScopedValue child2 = (ScopedValue) children.get(1);
- Assert.assertEquals(child2.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (child1.getValue().length() == VALUE_1.length()) {
- Assert.assertEquals(child1.getValue(), VALUE_1, "Input matches output");
- Assert.assertEquals(child2.getValue(), VALUE_2, "Input matches output");
- Assert.assertEquals(child1.getScope(), SCOPE_1, "Input matches output");
- Assert.assertEquals(child2.getScope(), SCOPE_2, "Input matches output");
- } else if (child1.getValue().length() == VALUE_2.length()) {
- Assert.assertEquals(child2.getValue(), VALUE_1, "Input matches output");
- Assert.assertEquals(child1.getValue(), VALUE_2, "Input matches output");
- Assert.assertEquals(child2.getScope(), SCOPE_1, "Input matches output");
- Assert.assertEquals(child1.getScope(), SCOPE_2, "Input matches output");
- } else {
- Assert.fail("Value mismatch");
- }
- }
-
- @Test public void singleInline() throws ComponentInitializationException, AttributeEncodingException {
- final SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeType("wibble");
- try {
- encoder.initialize();
- Assert.fail("Bad type should throw");
- } catch (ComponentInitializationException e) {
- // OK
- }
-
- encoder.setScopeType("inline");
- encoder.setScopeDelimiter(DELIMITER);
- encoder.initialize();
-
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1);
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
-
- final XSString childAsString = (XSString) child;
-
- Assert.assertEquals(childAsString.getValue(), VALUE_1 + DELIMITER + SCOPE_1, "Input equals output");
- }
-
- @Test public void multiInline() throws Exception {
- final SAML1ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeType("inline");
- encoder.setScopeDelimiter(DELIMITER);
- encoder.setScopeAttributeName(null);
- encoder.initialize();
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1, value2);
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertTrue(children.get(0) instanceof XSString && children.get(1) instanceof XSString,
- "Child of result attribute should be a string");
-
- final XSString child1 = (XSString) children.get(0);
- Assert.assertEquals(child1.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- final XSString child2 = (XSString) children.get(1);
- Assert.assertEquals(child2.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (child1.getValue().equals(VALUE_1 + DELIMITER + SCOPE_1)) {
- Assert.assertEquals(child2.getValue(), VALUE_2 + DELIMITER + SCOPE_2, "Input matches output");
- } else {
- Assert.assertEquals(child1.getValue(), VALUE_2 + DELIMITER + SCOPE_2, "Input matches output");
- Assert.assertEquals(child2.getValue(), VALUE_1 + DELIMITER + SCOPE_1, "Input matches output");
- }
- }
-
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoderTest.java
deleted file mode 100644
index 9e6b68c..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringAttributeEncoderTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML1StringAttributeEncoder} Unit test.
- */
-public class SAML1StringAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String STRING_1 = "Value The First";
-
- /** A second test value. */
- private final static String STRING_2 = "Second string the value is";
-
- private SAML1StringAttributeEncoder encoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML1StringAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNamespace("NameSpace");
- encoder.setEncodeType(true);
- encoder.initialize();
- }
-
- @Test(expectedExceptions={AttributeEncodingException.class,}) public void empty() throws Exception {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- encoder.initialize();
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}),
- new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
- @Override
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), new StringAttributeValue(STRING_1));
-
- final IdPAttribute inputAttribute;
- inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
-
- final XSString childAsString = (XSString) child;
-
- Assert.assertEquals(childAsString.getValue(), STRING_1, "Input equals output");
- }
-
- @Test public void multi() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}),
- new StringAttributeValue(STRING_1),
- new StringAttributeValue(STRING_2),
- new ScopedStringAttributeValue(STRING_2, STRING_1));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 3, "Encoding three entries");
-
- for (final XMLObject child: children) {
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
- final String childAsString = ((XSString) children.get(0)).getValue();
- Assert.assertTrue(STRING_1.equals(childAsString)||STRING_2.equals(childAsString));
- }
- }
-
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoderTest.java
deleted file mode 100644
index c27c41a..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1XMLObjectAttributeEncoderTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml1.core.Attribute;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML1XMLObjectAttributeEncoder} Unit test.
- *
- * Identical code to the {@link SAML1ByteAttributeEncoder} except that the type of assertion and encoder is changed.
- */
-public class SAML1XMLObjectAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String STRING_1 = "Value The First";
-
- /** A second test value. */
- private final static String STRING_2 = "Second string the value is";
-
- private SAML1XMLObjectAttributeEncoder encoder;
-
- private SAML1StringAttributeEncoder strEncoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML1XMLObjectAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNamespace("NameSpace");
- encoder.initialize();
- strEncoder = new SAML1StringAttributeEncoder();
- strEncoder.setName(ATTR_NAME);
- strEncoder.setNamespace("NameSpace");
- strEncoder.setEncodeType(true);
- strEncoder.initialize();
- }
-
- /**
- * Create an XML object from a string which we can test against later. We use the Saml1StringEncoder to do the work
- * because it is handy in this package.
- *
- * @param value that we encode
- * @return an XML object
- */
- private XMLObjectAttributeValue ObjectFor(final String value) {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(Collections.singletonList(new StringAttributeValue(value)));
- try {
- return new XMLObjectAttributeValue(strEncoder.encode(inputAttribute));
- } catch (AttributeEncodingException e) {
- return null;
- }
- }
-
- /**
- * Check that the input XML object is what was expected.
- *
- * @param input the objects in question.
- * @param possibles the strings that they might be encoding.
- */
- private static void CheckValues(final XMLObject input, final String... possibles) {
- Assert.assertTrue(input instanceof Attribute);
- final Attribute attribute = (Attribute) input;
-
- final List<XMLObject> children = attribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 1, "Data must have but one entry");
- Assert.assertTrue(children.get(0) instanceof XSString, "Data must contain one string");
- final String s = ((XSString) children.get(0)).getValue();
-
- for (String possible : possibles) {
- if (s.equals(possible)) {
- return;
- }
- }
- Assert.assertTrue(false, "No potential match");
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty() throws Exception {
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}),
- new ScopedStringAttributeValue("foo", "bar"), new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), ObjectFor(STRING_1));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
- Assert.assertEquals(children.get(0).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(0).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/>");
-
- CheckValues(children.get(0).getOrderedChildren().get(0), STRING_1);
- }
-
- @Test public void testMulti() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(ObjectFor(STRING_1), ObjectFor(STRING_2));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertEquals(children.get(0).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(0).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/> for first Attribute");
-
- Assert.assertEquals(children.get(1).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(1).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/> for second Attribute");
-
- CheckValues(children.get(0).getOrderedChildren().get(0), STRING_1, STRING_2);
- CheckValues(children.get(1).getOrderedChildren().get(0), STRING_1, STRING_2);
- }
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoderTest.java
deleted file mode 100644
index 35dd30b..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ByteAttributeEncoderTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSBase64Binary;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.codec.Base64Support;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML2ByteAttributeEncoder} Unit test.
- *
- * Identical code to the {@link SAML1ByteAttributeEncoder} except that the type of assertion and encoder is changed.
- */
-public class SAML2ByteAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static byte[] BYTE_ARRAY_1 = {1, 2, 3, 4, 5};
-
- /** A second test value. */
- private final static byte[] BYTE_ARRAY_2 = {4, 3, 2, 1};
-
- private SAML2ByteAttributeEncoder encoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML2ByteAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNameFormat("NameSpace");
- encoder.setFriendlyName("friendly");
- encoder.setEncodeType(true);
- encoder.initialize();
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty() throws Exception {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- final int[] intArray = {1, 2, 3, 4};
- final List<IdPAttributeValue<?>> values =
- Arrays.asList(new StringAttributeValue("foo"), new ScopedStringAttributeValue("foo", "bar"),
- new IdPAttributeValue<Object>() {
- public Object getValue() {
- return intArray;
- }
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new StringAttributeValue("foo"), new ByteAttributeValue(BYTE_ARRAY_1));
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- XMLObject child = children.get(0);
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME);
-
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- XSBase64Binary childAsString = (XSBase64Binary) child;
-
- byte childAsBa[] = Base64Support.decode(childAsString.getValue());
-
- Assert.assertEquals(childAsBa, BYTE_ARRAY_1, "Input equals output");
- }
-
- @Test public void multi() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(BYTE_ARRAY_1), new ByteAttributeValue(BYTE_ARRAY_2));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- XMLObject child = children.get(0);
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- XSBase64Binary childAsString = (XSBase64Binary) child;
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- final byte[] res0 = Base64Support.decode(childAsString.getValue());
-
- child = children.get(1);
- Assert.assertTrue(child instanceof XSBase64Binary, "Child of result attribute should be a base64Binary");
-
- childAsString = (XSBase64Binary) child;
- final byte[] res1 = Base64Support.decode(childAsString.getValue());
-
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (BYTE_ARRAY_1.length == res0.length) {
- Assert.assertEquals(BYTE_ARRAY_1, res0, "Input matches output");
- Assert.assertEquals(BYTE_ARRAY_2, res1, "Input matches output");
- } else if (BYTE_ARRAY_1.length == res1.length) {
- Assert.assertEquals(BYTE_ARRAY_1, res1, "Input matches output");
- Assert.assertEquals(BYTE_ARRAY_2, res0, "Input matches output");
- } else {
- Assert.assertTrue(BYTE_ARRAY_1.length == res1.length || BYTE_ARRAY_2.length == res1.length,
- "One of the output's size should match an input size");
- }
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoderTest.java
deleted file mode 100644
index d3d6ce9..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2ScopedStringAttributeEncoderTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.saml.xmlobject.ScopedValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.UninitializedComponentException;
-
-/**
- * {@link SAML2ScopedStringAttributeEncoder} Unit test. Looks a lot like the SAML1 one
- */
-public class SAML2ScopedStringAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String VALUE_1 = "ValueTheFirst";
-
- /** A second test value. */
- private final static String VALUE_2 = "Second";
-
- /** A test scope . */
- private final static String SCOPE_1 = "scope1.example.org";
-
- /** A second test value. */
- private final static String SCOPE_2 = "scope2";
-
- private final static String DELIMITER = "#";
-
- private final static String ATTRIBUTE_NAME = "Scope";
-
- private final ScopedStringAttributeValue value1 = new ScopedStringAttributeValue(VALUE_1, SCOPE_1);
-
- private final ScopedStringAttributeValue value2 = new ScopedStringAttributeValue(VALUE_2, SCOPE_2);
-
- public SAML2ScopedStringAttributeEncoder makeEncoder() {
- SAML2ScopedStringAttributeEncoder encoder;
- encoder = new SAML2ScopedStringAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setScopeDelimiter(DELIMITER);
- encoder.setNameFormat("NameSpace");
- encoder.setFriendlyName("friendly");
- encoder.setEncodeType(true);
- return encoder;
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty()
- throws AttributeEncodingException, ComponentInitializationException {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.initialize();
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate()
- throws AttributeEncodingException, ComponentInitializationException {
- final SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- final int[] intArray = {1, 2, 3, 4};
- final var values =
- List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), new StringAttributeValue("dd"),
- new IdPAttributeValue<Object>() {
- public Object getValue() {
- return intArray;
- }
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
- try {
- encoder.encode(inputAttribute);
- Assert.fail("not initialized");
- } catch (UninitializedComponentException e) {
- // OK
- }
- encoder.initialize();
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void singleAttribute() throws ComponentInitializationException, AttributeEncodingException {
- final SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeType("attribute");
- try {
- encoder.setScopeAttributeName(null);
- encoder.initialize();
- Assert.fail("Missing attribute name should throw");
- } catch (ComponentInitializationException e) {
- // OK
- }
- encoder.setScopeAttributeName(ATTRIBUTE_NAME);
- encoder.setScopeDelimiter(DELIMITER);
-
- final Collection<IdPAttributeValue<?>> values =
- Arrays.asList(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1);
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.initialize();
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof ScopedValue, "Child of result attribute should be a string");
-
- final ScopedValue childAsScopedValue = (ScopedValue) child;
-
- Assert.assertEquals(childAsScopedValue.getValue(), VALUE_1, "Input equals output");
- Assert.assertEquals(childAsScopedValue.getScope(), SCOPE_1, "Input equals output");
-
- }
-
- @Test public void multiAttribute() throws ComponentInitializationException, AttributeEncodingException {
- final SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeType("attribute");
- encoder.setScopeAttributeName(ATTR_NAME);
- encoder.initialize();
- Collection<IdPAttributeValue<?>> values = List.of(value1, new ByteAttributeValue(new byte[] {1, 2, 3,}), value2);
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertTrue(children.get(0) instanceof ScopedValue && children.get(1) instanceof ScopedValue,
- "Child of result attribute should be a string");
-
- final ScopedValue child1 = (ScopedValue) children.get(0);
- Assert.assertEquals(child1.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- final ScopedValue child2 = (ScopedValue) children.get(1);
- Assert.assertEquals(child2.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (child1.getValue().length() == VALUE_1.length()) {
- Assert.assertEquals(child1.getValue(), VALUE_1, "Input matches output");
- Assert.assertEquals(child2.getValue(), VALUE_2, "Input matches output");
- Assert.assertEquals(child1.getScope(), SCOPE_1, "Input matches output");
- Assert.assertEquals(child2.getScope(), SCOPE_2, "Input matches output");
- } else if (child1.getValue().length() == VALUE_2.length()) {
- Assert.assertEquals(child2.getValue(), VALUE_1, "Input matches output");
- Assert.assertEquals(child1.getValue(), VALUE_2, "Input matches output");
- Assert.assertEquals(child2.getScope(), SCOPE_1, "Input matches output");
- Assert.assertEquals(child1.getScope(), SCOPE_2, "Input matches output");
- } else {
- Assert.fail("Value mismatch");
- }
- }
-
- @Test public void singleInline() throws ComponentInitializationException, AttributeEncodingException {
- final SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeType("wibble");
- try {
- encoder.initialize();
- Assert.fail("Bad type should throw");
- } catch (ComponentInitializationException e) {
- // OK
- }
- encoder.setScopeAttributeName(ATTRIBUTE_NAME);
- encoder.setScopeDelimiter("");
- encoder.setScopeType("inline");
- try {
- encoder.initialize();
- Assert.fail("Missing delimiter should throw");
- } catch (ComponentInitializationException e) {
- // OK
- }
- encoder.setScopeDelimiter(DELIMITER);
- encoder.initialize();
-
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1);
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
-
- final XSString childAsString = (XSString) child;
-
- Assert.assertEquals(childAsString.getValue(), VALUE_1 + DELIMITER + SCOPE_1, "Input equals output");
- }
-
- @Test public void multiInline() throws Exception {
- final SAML2ScopedStringAttributeEncoder encoder = makeEncoder();
- encoder.setScopeDelimiter(DELIMITER);
- encoder.setScopeAttributeName(null);
- encoder.initialize();
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), value1, value2);
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertTrue(children.get(0) instanceof XSString && children.get(1) instanceof XSString,
- "Child of result attribute should be a string");
-
- final XSString child1 = (XSString) children.get(0);
- Assert.assertEquals(child1.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- final XSString child2 = (XSString) children.get(1);
- Assert.assertEquals(child2.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- //
- // order of results is not guaranteed so sense the result from the length
- //
- if (child1.getValue().equals(VALUE_1 + DELIMITER + SCOPE_1)) {
- Assert.assertEquals(child2.getValue(), VALUE_2 + DELIMITER + SCOPE_2, "Input matches output");
- } else {
- Assert.assertEquals(child1.getValue(), VALUE_2 + DELIMITER + SCOPE_2, "Input matches output");
- Assert.assertEquals(child2.getValue(), VALUE_1 + DELIMITER + SCOPE_1, "Input matches output");
- }
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoderTest.java
deleted file mode 100644
index 80ce8b6..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringAttributeEncoderTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML2StringAttributeEncoder} Unit test.
- *
- * Identical code to the {@link SAML1StringAttributeEncoder} except that the type of assertion and encoder is changed.
- */
-public class SAML2StringAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String STRING_1 = "Value The First";
-
- /** A second test value. */
- private final static String STRING_2 = "Second string the value is";
-
- private SAML2StringAttributeEncoder encoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML2StringAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNameFormat("NameSpace");
- encoder.setFriendlyName("friendly");
- encoder.setEncodeType(true);
- encoder.initialize();
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty() throws Exception {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- final int[] intArray = {1, 2, 3, 4};
- final var values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
- @Override
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), new StringAttributeValue(STRING_1));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
-
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
-
- final XMLObject child = children.get(0);
-
- Assert.assertEquals(child.getElementQName(), AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
-
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
-
- final XSString childAsString = (XSString) child;
-
- Assert.assertEquals(childAsString.getValue(), STRING_1, "Input equals output");
- }
-
- @Test public void multi() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}),
- new StringAttributeValue(STRING_1),
- new StringAttributeValue(STRING_2),
- new ScopedStringAttributeValue(STRING_1, STRING_2));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
-
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 3, "Encoding three entries");
-
- for (final XMLObject child: children) {
- Assert.assertTrue(child instanceof XSString, "Child of result attribute should be a string");
- final String childAsString = ((XSString) children.get(0)).getValue();
- Assert.assertTrue(STRING_1.equals(childAsString)||STRING_2.equals(childAsString));
- }
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoderTest.java
deleted file mode 100644
index b6675a0..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2XMLObjectAttributeEncoderTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.idp.saml.attribute.encoding.impl;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * {@link SAML2XMLObjectAttributeEncoder} Unit test.
- *
- * Identical code to the {@link SAML1XMLObjectAttributeEncoder} except that the type of assertion and encoder is changed.
- */
-public class SAML2XMLObjectAttributeEncoderTest extends OpenSAMLInitBaseTestCase {
-
- /** The name we give the test attribute. */
- private final static String ATTR_NAME = "foo";
-
- /** A test value. */
- private final static String STRING_1 = "Value The First";
-
- /** A second test value. */
- private final static String STRING_2 = "Second string the value is";
-
- private SAML2XMLObjectAttributeEncoder encoder;
-
- private SAML1StringAttributeEncoder strEncoder;
-
- @BeforeClass public void initTest() throws ComponentInitializationException {
- encoder = new SAML2XMLObjectAttributeEncoder();
- encoder.setName(ATTR_NAME);
- encoder.setNameFormat("NameSpace");
- encoder.setFriendlyName("friendly");
- encoder.initialize();
-
- strEncoder = new SAML1StringAttributeEncoder();
- strEncoder.setName(ATTR_NAME);
- strEncoder.setNamespace("NameSpace");
- strEncoder.setEncodeType(true);
- strEncoder.initialize();
- }
-
- /**
- * Create an XML object from a string which we can test against later. We use the Saml1StringEncoder to do the work
- * because it is handy in this package.
- *
- * @param value that we encode
- * @return an XML object
- */
- private XMLObjectAttributeValue ObjectFor(final String value) {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(Collections.singletonList(new StringAttributeValue(value)));
- try {
- return new XMLObjectAttributeValue(strEncoder.encode(inputAttribute));
- } catch (AttributeEncodingException e) {
- return null;
- }
- }
-
- /**
- * Check that the input XML object is what was expected.
- *
- * @param input the objects in question.
- * @param possibles the strings that they might be encoding.
- */
- private static void CheckValues(final XMLObject input, final String... possibles) {
- Assert.assertTrue(input instanceof org.opensaml.saml.saml1.core.Attribute);
- final org.opensaml.saml.saml1.core.Attribute attribute = (org.opensaml.saml.saml1.core.Attribute) input;
-
- final List<XMLObject> children = attribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 1, "Data must have but one entry");
- Assert.assertTrue(children.get(0) instanceof XSString, "Data must contain one string");
- final String s = ((XSString) children.get(0)).getValue();
-
- for (String possible : possibles) {
- if (s.equals(possible)) {
- return;
- }
- }
- Assert.assertTrue(false, "No potential match");
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty() throws Exception {
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
-
- encoder.encode(inputAttribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void inappropriate() throws Exception {
- final int[] intArray = {1, 2, 3, 4};
- final var values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), new ScopedStringAttributeValue("foo",
- "bar"), new IdPAttributeValue<Object>() {
- @Override
- public Object getValue() {
- return intArray;
- }
- public String getDisplayValue() {
- return intArray.toString();
- }
- });
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- encoder.encode(inputAttribute);
- }
-
- @Test public void single() throws Exception {
- final var values = List.of(new ByteAttributeValue(new byte[] {1, 2, 3,}), ObjectFor(STRING_1));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 1, "Encoding one entry");
- Assert.assertEquals(children.get(0).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(0).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/>");
-
- CheckValues(children.get(0).getOrderedChildren().get(0), STRING_1);
- }
-
- @Test public void multi() throws Exception {
- final List<IdPAttributeValue<?>> values = List.of(ObjectFor(STRING_1), ObjectFor(STRING_2));
-
- final IdPAttribute inputAttribute = new IdPAttribute(ATTR_NAME);
- inputAttribute.setValues(values);
-
- final Attribute outputAttribute = encoder.encode(inputAttribute);
- Assert.assertNotNull(outputAttribute);
-
- final List<XMLObject> children = outputAttribute.getOrderedChildren();
- Assert.assertEquals(children.size(), 2, "Encoding two entries");
-
- Assert.assertEquals(children.get(0).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(0).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/> for first Attribute");
-
- Assert.assertEquals(children.get(1).getElementQName(),
- AttributeValue.DEFAULT_ELEMENT_NAME,
- "Attribute Value not inside <AttributeValue/>");
- Assert.assertEquals(children.get(1).getOrderedChildren().size(), 1,
- "Expected exactly one child inside the <AttributeValue/> for second Attribute");
-
- CheckValues(children.get(0).getOrderedChildren().get(0), STRING_1, STRING_2);
- CheckValues(children.get(1).getOrderedChildren().get(0), STRING_1, STRING_2);
-
- }
-
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/AttributeValueMapperTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/AttributeValueMapperTest.java
deleted file mode 100644
index 45d515f..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/AttributeValueMapperTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import net.shibboleth.idp.attribute.EmptyAttributeValue;
-import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.idp.attribute.ByteAttributeValue;
-import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
-import net.shibboleth.idp.attribute.StringAttributeValue;
-import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
-import net.shibboleth.utilities.java.support.codec.Base64Support;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.saml.ext.saml2mdui.UIInfo;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for AttributeValueMapper.
- */
-public class AttributeValueMapperTest extends MappingTests {
-
- private List<RequestedAttribute> attributes;
-
- private void loadAttributes() {
- if (null != attributes) {
- return;
- }
- attributes = loadFile("requestedAttributeValues.xml");
- }
-
- private List<XMLObject> getValues(String attributeName) {
- loadAttributes();
- for (RequestedAttribute attribute : attributes) {
- if (attributeName.equals(attribute.getName())) {
- return attribute.getAttributeValues();
- }
- }
- return null;
- }
-
- @Test public void testString() throws ComponentInitializationException {
-
- final StringAttributeValueMapper mapper = new StringAttributeValueMapper();
-
- mapper.setLogPrefix("testString");
- mapper.initialize();
- final List<IdPAttributeValue<?>> result = mapper.decodeValues(getValues("stdFormat"));
-
- Assert.assertEquals(result.size(), 4);
- final Set<String> strings = new HashSet(4);
-
- for (IdPAttributeValue val : result) {
- strings.add(((StringAttributeValue) val).getValue());
- }
- Assert.assertTrue(strings.contains("String"));
- Assert.assertTrue(strings.contains("1"));
- Assert.assertTrue(strings.contains("U2NvdCBDYW50b3IgaXMgdGhlIGdvZCBvZiBTQU1M"));
- Assert.assertTrue(strings.contains("scope at scoped.example.org"));
- }
-
- @Test public void testScopedString() throws ComponentInitializationException {
-
- ScopedStringAttributeValueMapper mapper = new ScopedStringAttributeValueMapper();
-
- mapper.setLogPrefix("testScopedString");
- mapper.initialize();
- List<IdPAttributeValue<?>> result = mapper.decodeValues(getValues("stdFormat"));
- Assert.assertEquals(result.size(), 1);
- ScopedStringAttributeValue value = (ScopedStringAttributeValue) result.get(0);
- Assert.assertEquals(value.getValue(), "scope");
- Assert.assertEquals(value.getScope(), "scoped.example.org");
-
- mapper = new ScopedStringAttributeValueMapper();
- mapper.setDelimiter("0b3IgaX");
- mapper.setLogPrefix("testScopedString2");
- mapper.initialize();
- result = mapper.decodeValues(getValues("stdFormat"));
- Assert.assertEquals(result.size(), 1);
- value = (ScopedStringAttributeValue) result.get(0);
- Assert.assertEquals(value.getValue(), "U2NvdCBDYW5");
- Assert.assertEquals(value.getScope(), "MgdGhlIGdvZCBvZiBTQU1M");
-
- result = mapper.decodeValues(getValues("urn:oid:0.9.2342.19200300.100.1.3"));
- Assert.assertTrue(result.isEmpty());
- }
-
- @Test public void testByte() throws ComponentInitializationException {
-
- ByteAttributeValueMapper mapper = new ByteAttributeValueMapper();
-
- mapper.setLogPrefix("testByte");
- mapper.initialize();
- final List<IdPAttributeValue<?>> result = mapper.decodeValues(getValues("stdFormat"));
- Assert.assertEquals(result.size(), 4);
- final Set<String> strings = new HashSet(4);
-
- for (IdPAttributeValue<?> val: result) {
- if (val instanceof EmptyAttributeValue) {
- strings.add(Base64Support.encode(new byte[0], Base64Support.CHUNKED));
- } else {
- strings.add(Base64Support.encode(((ByteAttributeValue)val).getValue(), Base64Support.CHUNKED));
- }
- }
- Assert.assertTrue(strings.contains("U2NvdCBDYW50b3IgaXMgdGhlIGdvZCBvZiBTQU1M"));
- }
-
- @Test public void testXMLObject() throws ComponentInitializationException {
-
- XMLObjectAttributeValueMapper mapper = new XMLObjectAttributeValueMapper();
-
- mapper.setLogPrefix("testXMLObject");
- mapper.initialize();
- final List<IdPAttributeValue<?>> result = mapper.decodeValues(getValues("stdFormat"));
- Assert.assertEquals(result.size(), 1);
- XMLObject object = ((XMLObjectAttributeValue) result.get(0)).getValue();
-
- Assert.assertTrue(object instanceof UIInfo);
- }
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/MappingTests.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/MappingTests.java
deleted file mode 100644
index 5de81a8..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/MappingTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.List;
-
-import org.opensaml.core.xml.XMLObjectBaseTestCase;
-import org.opensaml.saml.saml2.metadata.AttributeConsumingService;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-
-/**
- * Base class for testing attribute mapping
- */
-public class MappingTests extends XMLObjectBaseTestCase {
-
- public static final String FILE_PATH = "/net/shibboleth/idp/saml/impl/attribute/mapping/";
-
- protected static final String THE_FORMAT = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri";
-
- protected static final String SAML_NAME_ONE = "stdFormat";
-
- protected static final String SAML_NAME_TWO = "oddFormat";
-
- protected static final String SAML_NAME_THREE = "urn:oid:2.16.840.1.113730.3.1.241";
-
- protected List<RequestedAttribute> loadFile(final String file)
- {
- AttributeConsumingService service = unmarshallElement(FILE_PATH + file);
-
- return service.getRequestAttributes();
- }
-
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/NativeSpringTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/NativeSpringTest.java
deleted file mode 100644
index 2743f10..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/NativeSpringTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.Collection;
-
-import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
-
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.GenericApplicationContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * kicks the wheels tests.
- */
-public class NativeSpringTest {
-
- protected <Type> Type getBean(String fileName, Class<Type> claz) {
-
- GenericApplicationContext context = new GenericApplicationContext();
- try {
- SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
- new SchemaTypeAwareXMLBeanDefinitionReader(context);
-
- beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
- beanDefinitionReader.loadBeanDefinitions(fileName);
-
- context.refresh();
-
- Collection<Type> beans = context.getBeansOfType(claz).values();
- Assert.assertEquals(beans.size(), 1);
-
- return beans.iterator().next();
- } finally {
- context.close();
- }
- }
-
-
- @Test
- public void stringAttrValue() {
- RequestedAttributesMapper map = getBean(MappingTests.FILE_PATH + "attributesMapper.xml", RequestedAttributesMapper.class);
-
- LoggerFactory.getLogger(NativeSpringTest.class).debug(map.toString());
- }
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapperTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapperTest.java
deleted file mode 100644
index b29f6db..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributeMapperTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for {@link RequestedAttributeMapper}.
- */
-public class RequestedAttributeMapperTest extends MappingTests {
-
- private static final String ID = "atributeID";
-
- private List<RequestedAttribute> attributes;
-
- private void loadAttributes() {
- if (null != attributes) {
- return;
- }
- attributes = loadFile("requestedAttributeValues.xml");
- }
-
- private RequestedAttribute getAttr(String attributeName) {
- loadAttributes();
- for (RequestedAttribute attribute : attributes) {
- if (attributeName.equals(attribute.getName())) {
- return attribute;
- }
- }
- return null;
- }
-
- @Test public void setterGetterInit() throws ComponentInitializationException {
- final RequestedAttributeMapper mapper = new RequestedAttributeMapper();
-
- Assert.assertNull(mapper.getId());
- Assert.assertTrue(mapper.getAttributeIds().isEmpty());
- Assert.assertNull(mapper.getAttributeFormat());
- Assert.assertNull(mapper.getSAMLName());
- Assert.assertNull(mapper.getValueMapper());
-
- mapper.setId(ID);
- try {
- mapper.initialize();
- Assert.fail("SAML Name absent");
- } catch (ComponentInitializationException e) {
- // OK
- }
- mapper.setSAMLName(SAML_NAME_ONE);
-
- try {
- mapper.initialize();
- Assert.fail("Value Mapper absent");
- } catch (ComponentInitializationException e) {
- // OK
- }
- mapper.setValueMapper(new StringAttributeValueMapper());
-
- mapper.setAttributeIds(Collections.singletonList("one"));
- mapper.setAttributeFormat(THE_FORMAT);
-
- mapper.initialize();
- Assert.assertEquals(mapper.getId(), ID);
- Assert.assertEquals(mapper.getSAMLName(), SAML_NAME_ONE);
- Assert.assertEquals(mapper.getAttributeFormat(), THE_FORMAT);
-
- final List<String> list = mapper.getAttributeIds();
- Assert.assertEquals(list.size(), 1);
- Assert.assertEquals(list.get(0), "one");
-
- Assert.assertTrue(mapper.getValueMapper() instanceof StringAttributeValueMapper);
- }
-
- @Test public void mapAttributeFormat() throws ComponentInitializationException {
- RequestedAttributeMapper mapper = new RequestedAttributeMapper();
-
- mapper.setId(ID);
- mapper.setSAMLName(SAML_NAME_ONE);
- mapper.setValueMapper(new StringAttributeValueMapper());
- mapper.setAttributeIds(Arrays.asList("one", ID));
- mapper.setAttributeFormat(THE_FORMAT);
- mapper.initialize();
-
- final Map<String, IdPRequestedAttribute> result =
- mapper.mapAttribute(getAttr(SAML_NAME_ONE));
-
- Assert.assertEquals(result.size(), 2);
- Assert.assertTrue(result.containsKey(ID));
- Assert.assertTrue(result.containsKey("one"));
- Assert.assertNotNull(result.get(ID));
- Assert.assertNotNull(result.get("one"));
- Assert.assertEquals(result.get(ID).getValues().size(), 4);
-
- Assert.assertTrue(mapper.mapAttribute(getAttr(SAML_NAME_TWO)).isEmpty());
-
- mapper = new RequestedAttributeMapper();
-
- mapper.setId(ID);
- mapper.setSAMLName(SAML_NAME_TWO);
- mapper.setAttributeFormat(THE_FORMAT);
- mapper.setValueMapper(new StringAttributeValueMapper());
- mapper.setAttributeIds(Collections.singletonList(ID));
- mapper.initialize();
- Assert.assertTrue(mapper.mapAttribute(getAttr(SAML_NAME_TWO)).isEmpty());
-
- }
-
- @Test public void mapAttributeNoFormat() throws ComponentInitializationException {
- RequestedAttributeMapper mapper = new RequestedAttributeMapper();
-
- mapper.setId(ID);
- mapper.setAttributeIds(Collections.singletonList(ID));
- mapper.setSAMLName(SAML_NAME_TWO);
- mapper.setValueMapper(new StringAttributeValueMapper());
- mapper.initialize();
-
- Map<String, net.shibboleth.idp.attribute.IdPRequestedAttribute> result =
- mapper.mapAttribute(getAttr(SAML_NAME_TWO));
-
- Assert.assertEquals(result.size(), 1);
- Assert.assertTrue(result.get(ID).getValues().isEmpty());
-
- }
-
- @Test public void mapNoValueMatch() throws ComponentInitializationException {
- RequestedAttributeMapper mapper = new RequestedAttributeMapper();
-
- mapper.setId(ID);
- mapper.setAttributeIds(Collections.singletonList(ID));
- mapper.setSAMLName(SAML_NAME_THREE);
- mapper.setValueMapper(new ScopedStringAttributeValueMapper());
- mapper.initialize();
-
- Map<String, IdPRequestedAttribute> result =
- mapper.mapAttribute(getAttr(SAML_NAME_THREE));
- Assert.assertFalse(result.containsKey(ID));
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapperTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapperTest.java
deleted file mode 100644
index 060277b..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/mapping/impl/RequestedAttributesMapperTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.idp.saml.attribute.mapping.impl;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AbstractSAMLAttributeValueMapper;
-import net.shibboleth.idp.saml.attribute.mapping.AttributeMapper;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Multimap;
-
-/**
- * tests for {@link RequestedAttributesMapper}.
- */
-public class RequestedAttributesMapperTest extends MappingTests {
-
- private AttributeMapper<RequestedAttribute, IdPRequestedAttribute> buildMapper(String name, String samlFormat, AbstractSAMLAttributeValueMapper mapper) {
-
- RequestedAttributeMapper result = new RequestedAttributeMapper();
- result.setId(name);
- result.setAttributeIds(Collections.singletonList(name));
- result.setSAMLName(samlFormat);
- result.setValueMapper(mapper);
- return result;
- }
-
-
- @Test public void setterGetter() throws ComponentInitializationException {
-
- RequestedAttributesMapper mapper = new RequestedAttributesMapper();
- mapper.setId("id");
- Assert.assertTrue(mapper.getMappers().isEmpty());
- mapper.setMappers(Collections.singletonList(buildMapper("name", "saml", new StringAttributeValueMapper())));
-
- mapper.initialize();
- }
-
-
- @Test public void map() throws ComponentInitializationException {
-
- RequestedAttributesMapper mapper = new RequestedAttributesMapper();
- mapper.setId("id");
-
- mapper.setMappers(Arrays.asList(buildMapper("id", SAML_NAME_ONE, new StringAttributeValueMapper()),
- buildMapper("id", SAML_NAME_THREE, new ScopedStringAttributeValueMapper()),
- buildMapper("id2", SAML_NAME_THREE, new StringAttributeValueMapper())));
-
- mapper.initialize();
-
- Multimap<String, IdPRequestedAttribute> result = mapper.mapAttributes(loadFile("requestedAttributeValues.xml"));
-
- Assert.assertEquals(result.keySet().size(), 2);
-
- Collection<IdPRequestedAttribute> id = result.get("id");
- Assert.assertEquals(id.size(), 1);
- Iterator<IdPRequestedAttribute> itr = id.iterator();
- Assert.assertEquals(itr.next().getId(), "id");
-
- Assert.assertEquals(result.get("id2").size(), 1);
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/attributesMapper.xml b/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/attributesMapper.xml
deleted file mode 100644
index a079a3d..0000000
--- a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/attributesMapper.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- This is what we are trying to reverse map (note bi-directional aliasing, just to confuse things. And me.
-
- <AttributeDefinition xsi:type="ad:Simple" id="eduPersonAssurance" >
- <AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:eduPersonAssurance" />
- <AttributeEncoder xsi:type="SAML2String" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.11" friendlyName="eduPersonAssurance" />
- <AttributeEncoder xsi:type="SAML2String" nameFormat="http://example.org/Format" name="http://example.org/name/for/Attribute" friendlyName="otherSAMLName" />
- </AttributeDefinition>
-
- <AttributeDefinition xsi:type="ad:Simple" id="otherPersonAssurance" >
- <AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:eduPersonAssurance" />
- <AttributeEncoder xsi:type="SAML2String" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.11" friendlyName="eduPersonAssurance" />
- </AttributeDefinition>
-
- <AttributeDefinition xsi:type="ad:Scoped" id="eduPersonScopedAffiliation" scope="example.org" >
- <AttributeEncoder xsi:type="SAML1ScopedString" name="urn:mace:dir:attribute-def:eduPersonScopedAffiliation" />
- <AttributeEncoder xsi:type="SAML2ScopedString" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" friendlyName="eduPersonScopedAffiliation"
- scopeDelimiter='#'/>
- </AttributeDefinition>
-
- <AttributeDefinition xsi:type="ad:SAML2NameID" id="eduPersonTargetedID"
- nameIdFormat="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">
- <AttributeEncoder xsi:type="SAML1XMLObject" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10" />
- <AttributeEncoder xsi:type="SAML2XMLObject" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10" friendlyName="eduPersonTargetedID" />
- </AttributeDefinition>
-
-
- But note that this is unmappable (no source name)
-
- <AttributeDefinition id="transientId" xsi:type="ad:TransientId">
- <AttributeEncoder xsi:type="SAML1StringNameIdentifier" nameFormat="urn:mace:shibboleth:1.0:nameIdentifier"/>
- <AttributeEncoder xsi:type="SAML2StringNameID" nameFormat="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"/>
- </AttributeDefinition>
-
-
- -->
-
- <bean id="abstractStringMapper" init-method="initialize" abstract="true"
- class="net.shibboleth.idp.saml.attribute.mapping.impl.RequestedAttributeMapper">
- <property name="valueMapper">
- <bean
- class="net.shibboleth.idp.saml.attribute.mapping.impl.StringAttributeValueMapper" />
- </property>
- </bean>
-
- <bean id="RequestedAttributesMapper"
- class="net.shibboleth.idp.saml.attribute.mapping.impl.RequestedAttributesMapper"
- init-method="initialize" p:id="RequestedAttributesMapper">
- <property name="mappers">
- <list>
- <bean parent="abstractStringMapper">
- <property name="id" value="eduPersonAssurance" />
- <property name="SAMLName" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.11" />
- <property name="attributeIds">
- <list>
- <value>eduPersonAssurance</value>
- <value>otherPersonAssurance</value>
- </list>
- </property>
- </bean>
- <bean parent="abstractStringMapper">
- <property name="SAMLName" value="http://example.org/name/for/Attribute" />
- <property name="id" value="otherSAMLName" />
- <property name="attributeFormat" value="http://example.org/Format " />
- <property name="attributeIds">
- <list>
- <value>eduPersonAssurance</value>
- </list>
- </property>
- </bean>
- <bean parent="abstractStringMapper">
- <property name="sAMLName" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" />
- <property name="id" value="eduPersonScopedAffiliation" />
- <property name="attributeFormat" value=" format " />
- <property name="valueMapper">
- <bean
- class="net.shibboleth.idp.saml.attribute.mapping.impl.ScopedStringAttributeValueMapper"
- p:delimiter="#" />
- </property>
- <property name="attributeIds">
- <list>
- <value>eduPersonScopedAffiliation</value>
- </list>
- </property>
- </bean>
- <bean parent="abstractStringMapper">
- <property name="attributeFormat" value="format"/>
- <property name="sAMLName" value="urn:oid:1.3.6.1.4.1.5923.1.1.1.10"/>
- <property name="id" value="eduPersonTargetedID"/>
- <property name="valueMapper">
- <bean
- class="net.shibboleth.idp.saml.attribute.mapping.impl.XMLObjectAttributeValueMapper" />
- </property>
- <property name="attributeIds">
- <list>
- <value>eduPersonTargetedID</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
-</beans>
diff --git a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/requestedAttributeValues.xml b/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/requestedAttributeValues.xml
deleted file mode 100644
index f60a188..0000000
--- a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/attribute/mapping/requestedAttributeValues.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<AttributeConsumingService xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
- xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
- xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
- xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" index="1">
-
- <ServiceName xml:lang="en">Shibboleth Federated Issue
- Tracking
- </ServiceName>
- <RequestedAttribute FriendlyName="stdFormatFriendly"
- Name="stdFormat" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
- <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xsi:type="xs:string">String</saml:AttributeValue>
- <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xsi:type="xs:boolean">1</saml:AttributeValue>
- <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema">U2NvdCBDYW50b3IgaXMgdGhlIGdvZCBvZiBTQU1M
- </saml:AttributeValue>
- <saml:AttributeValue>scope at scoped.example.org</saml:AttributeValue>
- <saml:AttributeValue>
- <mdui:UIInfo>
- <mdui:DisplayName xml:lang="en">Shibboleth.net
- </mdui:DisplayName>
- <mdui:Description xml:lang="en">An identity provider
- hosted and used by the developers of Shibboleth.
- </mdui:Description>
- <mdui:Logo height="82" width="64">https://discovery.shibboleth.net/images/gryphon_64x82.png
- </mdui:Logo>
- </mdui:UIInfo>
- <mdui:UIInfo>
- <mdui:DisplayName xml:lang="en">Shibboleth.net
- </mdui:DisplayName>
- <mdui:Description xml:lang="en">An identity provider
- hosted and used by the developers of Shibboleth.
- </mdui:Description>
- <mdui:Logo height="82" width="64">https://discovery.shibboleth.net/images/gryphon_64x82.png
- </mdui:Logo>
- </mdui:UIInfo>
- </saml:AttributeValue>
- </RequestedAttribute>
- <RequestedAttribute FriendlyName="oddFormatFriendly"
- Name="oddFormat" NameFormat="https://example.org/" />
- <RequestedAttribute FriendlyName="mail"
- Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" />
- <RequestedAttribute FriendlyName="displayName"
- Name="urn:oid:2.16.840.1.113730.3.1.241" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
- <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xsi:type="xs:string">String</saml:AttributeValue>
- </RequestedAttribute>
-</AttributeConsumingService>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
index 7ca9682..dc202a7 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-afp.xsd
@@ -751,11 +751,16 @@
</complexContent>
</complexType>
- <complexType name="AttributeInMetadataType" abstract="true">
+ <complexType name="AttributeInMetadata">
<annotation>
<documentation>
- Functions that evaluate to true if an attribute (or specific values) is specified by
- supplied metadata.
+ A match function that evaluates to true if an attribute (or specific values) is specified by
+ the requesting entity's AttributeConsumingService SP metadata.
+
+ It supports both explicit checking for a named SAML RequestedAttribute in metadata, or
+ comparison via the transcoding registry to compare the internal attribute form against
+ decoded objects produced from the metadata. This is the old "mapped" functionality
+ in V3 and is now collapsed into one matcher type.
</documentation>
</annotation>
<complexContent>
@@ -783,29 +788,21 @@
</documentation>
</annotation>
</attribute>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="AttributeInMetadata">
- <annotation>
- <documentation>
- A match function that evaluates to true if an attribute (or specific values) is specified by
- the requesting entity's AttributeConsumingService SP metadata.
- </documentation>
- </annotation>
- <complexContent>
- <extension base="afp:AttributeInMetadataType">
- <attribute name="attributeName" type="string" use="optional">
+ <attribute name="attributeName" type="string">
<annotation>
<documentation>The name of a requested attribute to look for.</documentation>
</annotation>
</attribute>
- <attribute name="attributeNameFormat" type="string" use="optional">
+ <attribute name="attributeNameFormat" type="string">
<annotation>
<documentation>The name format of a requested attribute to look for.</documentation>
</annotation>
</attribute>
+ <attribute name="objectStrategyRef" type="string">
+ <annotation>
+ <documentation>Reference to locate XMLObject source of mapped attributes.</documentation>
+ </annotation>
+ </attribute>
</extension>
</complexContent>
</complexType>
@@ -813,18 +810,11 @@
<complexType name="MappedAttributeInMetadata">
<annotation>
<documentation>
- A match function that evaluates to true if a mapped attribute (or specific values) is specified by
- the requesting entity's AttributeConsumingService SP metadata.
+ Deprecated alias for afp:AttributeInMetadata type.
</documentation>
</annotation>
<complexContent>
- <extension base="afp:AttributeInMetadataType">
- <attribute name="objectStrategyRef" type="string" use="optional">
- <annotation>
- <documentation>Reference to locate XMLObject source of mapped attributes.</documentation>
- </annotation>
- </attribute>
- </extension>
+ <extension base="afp:AttributeInMetadata" />
</complexContent>
</complexType>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list