[java-identity-provider] 51/51: IDP-1408 Remove deprecated encoder implementations
Rod Widdowson
rdw at steadingsoftware.com
Wed Feb 6 08:43:22 EST 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=504b7b6e2a9762a77388b709d501888c4fe27945
commit 504b7b6e2a9762a77388b709d501888c4fe27945
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Feb 1 15:57:23 2019 +0000
IDP-1408 Remove deprecated encoder implementations
https://issues.shibboleth.net/jira/browse/IDP-1408
Plus all associated infrastructure
---
.../AbstractSAML1NameIdentifierEncoder.java | 84 ----------
.../encoding/AbstractSAML2NameIDEncoder.java | 84 ----------
.../nameid/NameIdentifierAttributeEncoder.java | 40 -----
.../SAML1NameIdentifierAttributeEncoder.java | 30 ----
.../saml/nameid/SAML2NameIDAttributeEncoder.java | 31 ----
.../AbstractSAML1NameIdentifierEncoderTest.java | 46 -----
.../encoding/AbstractSAML2NameIDEncoderTest.java | 55 ------
.../impl/SAML1StringNameIdentifierEncoder.java | 186 ---------------------
.../encoding/impl/SAML2StringNameIDEncoder.java | 186 ---------------------
.../nameid/impl/LegacyNameIdentifierGenerator.java | 1 -
.../impl/SAML1StringNameIdentifierEncoderTest.java | 140 ----------------
.../impl/SAML2StringNameIDEncoderTest.java | 147 ----------------
.../idp/saml/nameid/impl/TransientDecoderTest.java | 39 ++++-
13 files changed, 35 insertions(+), 1034 deletions(-)
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoder.java
deleted file mode 100644
index 188fd04..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoder.java
+++ /dev/null
@@ -1,84 +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.function.Predicate;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.saml.nameid.SAML1NameIdentifierAttributeEncoder;
-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.primitive.DeprecationSupport;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.common.xml.SAMLConstants;
-
-import com.google.common.base.Predicates;
-
-/**
- * Base class for {@link SAML1NameIdentifierAttributeEncoder}s.
- *
- * @deprecated
- */
-public abstract class AbstractSAML1NameIdentifierEncoder extends AbstractInitializableComponent
- implements SAML1NameIdentifierAttributeEncoder {
-
- /** Condition for use of this encoder. */
- @Nonnull private Predicate<ProfileRequestContext> activationCondition;
-
- /** Constructor. */
- public AbstractSAML1NameIdentifierEncoder() {
- activationCondition = Predicates.alwaysTrue();
- }
-
- /** {@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");
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public final String getProtocol() {
- return SAMLConstants.SAML11P_NS;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- DeprecationSupport.warn(ObjectType.CLASS, getClass().getName(), null, "via NameID Generation configuration");
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoder.java
deleted file mode 100644
index f63bb20..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoder.java
+++ /dev/null
@@ -1,84 +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.function.Predicate;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.saml.nameid.SAML2NameIDAttributeEncoder;
-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.primitive.DeprecationSupport;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.common.xml.SAMLConstants;
-
-import com.google.common.base.Predicates;
-
-/**
- * Base class for {@link SAML2NameIDAttributeEncoder}s.
- *
- * @deprecated
- */
-public abstract class AbstractSAML2NameIDEncoder extends AbstractInitializableComponent
- implements SAML2NameIDAttributeEncoder {
-
- /** Condition for use of this encoder. */
- @Nonnull private Predicate<ProfileRequestContext> activationCondition;
-
- /** Constructor. */
- public AbstractSAML2NameIDEncoder() {
- activationCondition = Predicates.alwaysTrue();
- }
-
- /** {@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");
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public final String getProtocol() {
- return SAMLConstants.SAML20P_NS;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- DeprecationSupport.warn(ObjectType.CLASS, getClass().getName(), null, "via NameID Generation configuration");
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/NameIdentifierAttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/NameIdentifierAttributeEncoder.java
deleted file mode 100644
index 7e787f2..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/NameIdentifierAttributeEncoder.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.nameid;
-
-import net.shibboleth.idp.attribute.AttributeEncoder;
-
-import java.util.function.Predicate;
-
-import org.opensaml.saml.common.SAMLObject;
-
-/**
- * Marker interface for {@link AttributeEncoder} that produces SAML name identifiers
- * instead of attributes.
- *
- * <p>Implementations must be able to support a predicate test indicating
- * support, or not, for a particular name identifier format.</p>
- *
- * @param <NameIdType> type of object produced
- *
- * @deprecated
- */
-public interface NameIdentifierAttributeEncoder<NameIdType extends SAMLObject>
- extends AttributeEncoder<NameIdType>, Predicate<String> {
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML1NameIdentifierAttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML1NameIdentifierAttributeEncoder.java
deleted file mode 100644
index 93e6243..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML1NameIdentifierAttributeEncoder.java
+++ /dev/null
@@ -1,30 +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.nameid;
-
-import org.opensaml.saml.saml1.core.NameIdentifier;
-
-/**
- * Marker interface for {@link net.shibboleth.idp.attribute.AttributeEncoder}
- * that produces SAML 1.x {@link NameIdentifier}s instead of attributes.
- *
- * @deprecated
- */
-public interface SAML1NameIdentifierAttributeEncoder extends NameIdentifierAttributeEncoder<NameIdentifier> {
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML2NameIDAttributeEncoder.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML2NameIDAttributeEncoder.java
deleted file mode 100644
index b51a0a9..0000000
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/nameid/SAML2NameIDAttributeEncoder.java
+++ /dev/null
@@ -1,31 +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.nameid;
-
-import org.opensaml.saml.saml2.core.NameID;
-
-
-/**
- * Marker interface for {@link net.shibboleth.idp.attribute.AttributeEncoder}
- * that produces SAML 2.0 {@link NameID}s instead of attributes.
- *
- * @deprecated
- */
-public interface SAML2NameIDAttributeEncoder extends NameIdentifierAttributeEncoder<NameID> {
-
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoderTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoderTest.java
deleted file mode 100644
index 070a411..0000000
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML1NameIdentifierEncoderTest.java
+++ /dev/null
@@ -1,46 +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.IdPAttribute;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-
-import org.opensaml.saml.saml1.core.NameIdentifier;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test for {@link AbstractSAML1NameIdentifierEncoder}.
- */
-public class AbstractSAML1NameIdentifierEncoderTest {
-
- @Test public void abstractSAML1NameIdentifierEncoder() {
-
- AbstractSAML1NameIdentifierEncoder encoder = new AbstractSAML1NameIdentifierEncoder() {
- public NameIdentifier encode(IdPAttribute attribute) throws AttributeEncodingException {
- return null;
- }
-
- public boolean test(String input) {
- return false;
- }
- };
- // Again, use constants
- Assert.assertEquals(encoder.getProtocol(), "urn:oasis:names:tc:SAML:1.1:protocol");
- }
-}
\ No newline at end of file
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoderTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoderTest.java
deleted file mode 100644
index 0142313..0000000
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/attribute/encoding/AbstractSAML2NameIDEncoderTest.java
+++ /dev/null
@@ -1,55 +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.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.AttributeEncodingException;
-import net.shibboleth.idp.attribute.IdPRequestedAttribute;
-import net.shibboleth.idp.saml.attribute.mapping.AttributeMapper;
-
-import org.opensaml.saml.saml2.core.NameID;
-import org.opensaml.saml.saml2.metadata.RequestedAttribute;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test for {@link AbstractSAML2NameIDEncoder}.
- */
-public class AbstractSAML2NameIDEncoderTest {
-
- @Test public void abstractSAML2NameIdentifierEncoder() {
-
- AbstractSAML2NameIDEncoder encoder = new AbstractSAML2NameIDEncoder() {
- public NameID encode(IdPAttribute attribute) throws AttributeEncodingException {
- return null;
- }
-
- @Nullable public AttributeMapper<RequestedAttribute, IdPRequestedAttribute> getMapper(String name) {
- return null;
- }
-
- public boolean test(String input) {
- return false;
- }
- };
- // Again, use constants
- Assert.assertEquals(encoder.getProtocol(), "urn:oasis:names:tc:SAML:2.0:protocol");
- }
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoder.java
deleted file mode 100644
index 85d4d11..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoder.java
+++ /dev/null
@@ -1,186 +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.Collection;
-
-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.saml.attribute.encoding.AbstractSAML1NameIdentifierEncoder;
-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.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.saml.common.SAMLObjectBuilder;
-import org.opensaml.saml.saml1.core.NameIdentifier;
-import org.opensaml.saml.saml1.profile.SAML1ObjectSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-
-/**
- * {@link net.shibboleth.idp.saml.nameid.NameIdentifierAttributeEncoder} that encodes the first String value of an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} to a SAML 1 {@link NameIdentifier}.
- *
- * @deprecated
- */
-public class SAML1StringNameIdentifierEncoder extends AbstractSAML1NameIdentifierEncoder {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML1StringNameIdentifierEncoder.class);
-
- /** Identifier builder. */
- @Nonnull private final SAMLObjectBuilder<NameIdentifier> identifierBuilder;
-
- /** The format of the name identifier. */
- @Nullable private String format;
-
- /** The security or administrative domain that qualifies the name identifier. */
- @Nullable private String qualifier;
-
- /** Constructor. */
- public SAML1StringNameIdentifierEncoder() {
- identifierBuilder =
- (SAMLObjectBuilder<NameIdentifier>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
- NameIdentifier.DEFAULT_ELEMENT_NAME);
- if (identifierBuilder == null) {
- throw new ConstraintViolationException("Builder unavailable for NameIdentifier objects");
- }
- format = NameIdentifier.UNSPECIFIED;
- }
-
- /**
- * Get the format of the name identifier.
- *
- * @return format of the name identifier
- */
- @Nullable public final String getNameFormat() {
- return format;
- }
-
- /**
- * Set the format of the name identifier.
- *
- * @param nameFormat format of the name identifier
- */
- public final void setNameFormat(@Nullable final String nameFormat) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- format = StringSupport.trimOrNull(nameFormat);
- }
-
- /**
- * Get the security or administrative domain that qualifies the name identifier.
- *
- * @return security or administrative domain that qualifies the name identifier
- */
- @Nullable public final String getNameQualifier() {
- return qualifier;
- }
-
- /**
- * Set the security or administrative domain that qualifies the name identifier.
- *
- * @param nameQualifier security or administrative domain that qualifies the name identifier
- */
- @Nullable public final void setNameQualifier(final String nameQualifier) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- qualifier = StringSupport.trimOrNull(nameQualifier);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean test(@Nullable final String input) {
- return SAML1ObjectSupport.areNameIdentifierFormatsEquivalent(input, format);
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public NameIdentifier encode(@Nonnull final IdPAttribute attribute) throws AttributeEncodingException {
- final String attributeId = attribute.getId();
-
- final Collection<IdPAttributeValue<?>> attributeValues = attribute.getValues();
- if (attributeValues == null || attributeValues.isEmpty()) {
- throw new AttributeEncodingException("Attribute " + attribute.getId()
- + " does not contain any values to encode");
- }
-
- final NameIdentifier nameId = identifierBuilder.buildObject();
- nameId.setFormat(format);
- nameId.setNameQualifier(qualifier);
-
- for (final IdPAttributeValue attrValue : attributeValues) {
- if (attrValue == null || attrValue.getValue() == null) {
- log.debug("Skipping null value of attribute {}", attributeId);
- continue;
- }
-
- final Object value = attrValue.getValue();
- if (value instanceof String) {
- // Check for empty or all-whitespace, but don't trim.
- if (StringSupport.trimOrNull((String) value) == null) {
- log.debug("Skipping all-whitespace value of attribute {}", attributeId);
- continue;
- }
- nameId.setValue((String) value);
- return nameId;
- } else {
- log.debug("Skipping unsupported value of type {} of attribute {}", value.getClass().getName(),
- attributeId);
- continue;
- }
- }
- throw new AttributeEncodingException("Attribute '" + attributeId + "' did not contain any encodable values");
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
-
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof SAML1StringNameIdentifierEncoder)) {
- return false;
- }
-
- final SAML1StringNameIdentifierEncoder other = (SAML1StringNameIdentifierEncoder) obj;
- return java.util.Objects.equals(getNameFormat(), other.getNameFormat())
- && java.util.Objects.equals(getNameQualifier(), other.getNameQualifier());
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hashCode(getNameFormat(), getNameQualifier(), getProtocol(),
- SAML1StringNameIdentifierEncoder.class);
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoder.java
deleted file mode 100644
index 8f76845..0000000
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoder.java
+++ /dev/null
@@ -1,186 +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.Collection;
-
-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.saml.attribute.encoding.AbstractSAML2NameIDEncoder;
-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.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.saml.common.SAMLObjectBuilder;
-import org.opensaml.saml.saml2.core.NameID;
-import org.opensaml.saml.saml2.profile.SAML2ObjectSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
-
-/**
- * {@link net.shibboleth.idp.saml.nameid.NameIdentifierAttributeEncoder} that encodes the first String value of an
- * {@link net.shibboleth.idp.attribute.IdPAttribute} to a SAML 2 {@link NameID}.
- *
- * @deprecated
- */
-public class SAML2StringNameIDEncoder extends AbstractSAML2NameIDEncoder {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(SAML2StringNameIDEncoder.class);
-
- /** Identifier builder. */
- @Nonnull private final SAMLObjectBuilder<NameID> identifierBuilder;
-
- /** The format of the name identifier. */
- @Nullable private String format;
-
- /** The security or administrative domain that qualifies the name identifier. */
- @Nullable private String qualifier;
-
- /** Constructor. */
- public SAML2StringNameIDEncoder() {
- identifierBuilder =
- (SAMLObjectBuilder<NameID>) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(
- NameID.DEFAULT_ELEMENT_NAME);
- if (identifierBuilder == null) {
- throw new ConstraintViolationException("Builder unavailable for NameID objects");
- }
- setNameFormat(NameID.UNSPECIFIED);
- }
-
- /**
- * Get the format of the name identifier.
- *
- * @return format of the name identifier
- */
- @Nullable public final String getNameFormat() {
- return format;
- }
-
- /**
- * Set the format of the name identifier.
- *
- * @param nameFormat format of the name identifier
- */
- public final void setNameFormat(@Nullable final String nameFormat) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- format = StringSupport.trimOrNull(nameFormat);
- }
-
- /**
- * Get the security or administrative domain that qualifies the name identifier.
- *
- * @return security or administrative domain that qualifies the name identifier
- */
- @Nullable public final String getNameQualifier() {
- return qualifier;
- }
-
- /**
- * Set the security or administrative domain that qualifies the name identifier.
- *
- * @param nameQualifier security or administrative domain that qualifies the name identifier
- */
- @Nullable public final void setNameQualifier(final String nameQualifier) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- qualifier = StringSupport.trimOrNull(nameQualifier);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean test(final String input) {
- return SAML2ObjectSupport.areNameIDFormatsEquivalent(input, format);
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public NameID encode(@Nonnull final IdPAttribute attribute) throws AttributeEncodingException {
- final String attributeId = attribute.getId();
-
- final Collection<IdPAttributeValue<?>> attributeValues = attribute.getValues();
- if (attributeValues == null || attributeValues.isEmpty()) {
- throw new AttributeEncodingException("Attribute " + attribute.getId()
- + " does not contain any values to encode");
- }
-
- final NameID nameId = identifierBuilder.buildObject();
- nameId.setFormat(format);
- nameId.setNameQualifier(qualifier);
-
- for (final IdPAttributeValue attrValue : attributeValues) {
- if (attrValue == null || attrValue.getValue() == null) {
- log.debug("Skipping null value of attribute {}", attributeId);
- continue;
- }
-
- final Object value = attrValue.getValue();
- if (value instanceof String) {
- // Check for empty or all-whitespace, but don't trim.
- if (StringSupport.trimOrNull((String) value) == null) {
- log.debug("Skipping all-whitespace value of attribute {}", attributeId);
- continue;
- }
- nameId.setValue((String) value);
- return nameId;
- } else {
- log.debug("Skipping unsupported value of type {} of attribute {}", value.getClass().getName(),
- attributeId);
- continue;
- }
- }
- throw new AttributeEncodingException("Attribute '" + attributeId + "' did not contain any encodable values");
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
-
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof SAML2StringNameIDEncoder)) {
- return false;
- }
-
- final SAML2StringNameIDEncoder other = (SAML2StringNameIDEncoder) obj;
- return java.util.Objects.equals(getNameFormat(), other.getNameFormat())
- && java.util.Objects.equals(getNameQualifier(), other.getNameQualifier());
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hashCode(getNameFormat(), getNameQualifier(), getProtocol(),
- SAML2StringNameIDEncoder.class);
- }
-
-}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/LegacyNameIdentifierGenerator.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/LegacyNameIdentifierGenerator.java
index 4495571..92e1ec3 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/LegacyNameIdentifierGenerator.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/LegacyNameIdentifierGenerator.java
@@ -35,7 +35,6 @@ import com.google.common.base.Predicates;
import net.shibboleth.idp.attribute.context.AttributeContext;
import net.shibboleth.idp.profile.context.RelyingPartyContext;
-import net.shibboleth.idp.saml.nameid.NameIdentifierAttributeEncoder;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoderTest.java
deleted file mode 100644
index 1c2cb42..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML1StringNameIdentifierEncoderTest.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.Collections;
-
-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.attribute.StringAttributeValue;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.saml.saml1.core.NameIdentifier;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for {@link SAML1StringNameIdentifierEncoder}.
- */
- at SuppressWarnings("deprecation")
-public class SAML1StringNameIdentifierEncoderTest extends OpenSAMLInitBaseTestCase {
-
- @Test public void settersGetters() {
- final SAML1StringNameIdentifierEncoder encoder = new SAML1StringNameIdentifierEncoder();
-
- Assert.assertEquals(encoder.getNameFormat(), "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
-
- Assert.assertNull(encoder.getNameQualifier());
-
- encoder.setNameFormat("nameFormat");
- encoder.setNameQualifier("nameQualifier");
-
- Assert.assertEquals(encoder.getNameFormat(), "nameFormat");
- Assert.assertEquals(encoder.getNameQualifier(), "nameQualifier");
- }
-
- @Test public void equalsHash() {
- final SAML1StringNameIdentifierEncoder enc1 = new SAML1StringNameIdentifierEncoder();
- enc1.setNameFormat("nameFormat");
- enc1.setNameQualifier("nameQualifier");
-
- final SAML1StringNameIdentifierEncoder enc2 = new SAML1StringNameIdentifierEncoder();
- enc2.setNameFormat("nameFormat");
- enc2.setNameQualifier("nameQualifier");
-
- final SAML1StringNameIdentifierEncoder enc3 = new SAML1StringNameIdentifierEncoder();
- enc3.setNameFormat("nameQualifier");
- enc3.setNameQualifier("nameFormat");
-
- Assert.assertFalse(enc1.equals(null));
- Assert.assertFalse(enc1.equals(new Integer(1)));
- Assert.assertFalse(enc1.equals(enc3));
- Assert.assertTrue(enc1.equals(enc2));
- Assert.assertTrue(enc1.equals(enc1));
-
- Assert.assertEquals(enc1.hashCode(), enc2.hashCode());
- Assert.assertNotEquals(enc1.hashCode(), enc3.hashCode());
- }
-
- @Test public void encode() throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
- attribute.setValues(Collections.singleton(new StringAttributeValue("value")));
-
- final SAML1StringNameIdentifierEncoder enc1 = new SAML1StringNameIdentifierEncoder();
-
- NameIdentifier nameId = enc1.encode(attribute);
- Assert.assertEquals(nameId.getValue(), "value");
- Assert.assertEquals(nameId.getFormat(), "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
- Assert.assertNull(nameId.getNameQualifier());
-
- enc1.setNameFormat("nameFormat");
- enc1.setNameQualifier("nameQualifier");
- nameId = enc1.encode(attribute);
- Assert.assertEquals(nameId.getValue(), "value");
- Assert.assertEquals(nameId.getFormat(), "nameFormat");
- Assert.assertEquals(nameId.getNameQualifier(), "nameQualifier");
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void innappropriateTypes()
- throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
-
- final SAML1StringNameIdentifierEncoder enc1 = new SAML1StringNameIdentifierEncoder();
-
- try {
- enc1.encode(attribute);
- Assert.fail();
- } catch (Exception e) {
- // OK
- }
-
- final IdPAttributeValue<?> empty = new IdPAttributeValue<String>() {
- @Override
- @Nonnull public String getValue() {
- return null;
- }
- public String getDisplayValue() {
- return null;
- }
- };
-
- attribute.setValues(Collections.singleton(empty));
- try {
- enc1.encode(attribute);
- Assert.fail();
- } catch (AttributeEncodingException e) {
- // OK
- }
-
- final IdPAttributeValue<?> wrong = new IdPAttributeValue<Integer>() {
- @Override
- @Nonnull public Integer getValue() {
- return new Integer(3);
- }
- public String getDisplayValue() {
- return "3";
- }
- };
-
- attribute.setValues(Collections.singleton(wrong));
- enc1.encode(attribute);
- }
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoderTest.java
deleted file mode 100644
index b170db8..0000000
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/attribute/encoding/impl/SAML2StringNameIDEncoderTest.java
+++ /dev/null
@@ -1,147 +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 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.attribute.StringAttributeValue;
-
-import org.opensaml.core.OpenSAMLInitBaseTestCase;
-import org.opensaml.saml.saml2.core.NameID;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for {@link SAML2StringNameIDEncoder}.
- */
- at SuppressWarnings("deprecation")
-public class SAML2StringNameIDEncoderTest extends OpenSAMLInitBaseTestCase {
-
- @Test public void settersGetters() {
- final SAML2StringNameIDEncoder encoder = new SAML2StringNameIDEncoder();
-
- Assert.assertEquals(encoder.getNameFormat(), "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
- Assert.assertNull(encoder.getNameQualifier());
-
- encoder.setNameFormat("nameFormat");
- encoder.setNameQualifier("nameQualifier");
-
- Assert.assertEquals(encoder.getNameFormat(), "nameFormat");
- Assert.assertEquals(encoder.getNameQualifier(), "nameQualifier");
- }
-
- @Test public void equalsHash() {
- final SAML2StringNameIDEncoder enc1 = new SAML2StringNameIDEncoder();
- enc1.setNameFormat("nameFormat");
- enc1.setNameQualifier("nameQualifier");
-
- final SAML2StringNameIDEncoder enc2 = new SAML2StringNameIDEncoder();
- enc2.setNameFormat("nameFormat");
- enc2.setNameQualifier("nameQualifier");
-
- final SAML2StringNameIDEncoder enc3 = new SAML2StringNameIDEncoder();
- enc3.setNameFormat("nameQualifier");
- enc3.setNameQualifier("nameFormat");
-
- final SAML1StringNameIdentifierEncoder enc4 = new SAML1StringNameIdentifierEncoder();
- enc4.setNameFormat("nameFormat");
- enc4.setNameQualifier("nameQualifier");
-
- Assert.assertFalse(enc1.equals(null));
- Assert.assertFalse(enc1.equals(enc4));
- Assert.assertFalse(enc1.equals(enc3));
- Assert.assertTrue(enc1.equals(enc2));
- Assert.assertTrue(enc1.equals(enc1));
-
- Assert.assertEquals(enc1.hashCode(), enc2.hashCode());
- Assert.assertNotEquals(enc1.hashCode(), enc3.hashCode());
- Assert.assertNotEquals(enc1.hashCode(), enc4.hashCode());
- }
-
- @Test public void encode() throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
- attribute.setValues(Collections.singleton(new StringAttributeValue("value")));
-
- final SAML2StringNameIDEncoder enc1 = new SAML2StringNameIDEncoder();
-
- NameID nameId = enc1.encode(attribute);
- Assert.assertEquals(nameId.getValue(), "value");
- Assert.assertEquals(nameId.getFormat(), "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
- Assert.assertNull(nameId.getNameQualifier());
-
- enc1.setNameFormat("nameFormat");
- enc1.setNameQualifier("nameQualifier");
- nameId = enc1.encode(attribute);
- Assert.assertEquals(nameId.getValue(), "value");
- Assert.assertEquals(nameId.getFormat(), "nameFormat");
- Assert.assertEquals(nameId.getNameQualifier(), "nameQualifier");
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void empty()
- throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
-
- final SAML2StringNameIDEncoder enc1 = new SAML2StringNameIDEncoder();
-
- enc1.encode(attribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void nullValues()
- throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
-
- final SAML2StringNameIDEncoder enc1 = new SAML2StringNameIDEncoder();
-
- final IdPAttributeValue<?> empty = new IdPAttributeValue<String>() {
- @Override
- @Nonnull public String getValue() {
- return null;
- }
- public String getDisplayValue() {
- return null;
- }
- };
-
- attribute.setValues(Collections.singleton(empty));
- enc1.encode(attribute);
- }
-
- @Test(expectedExceptions = {AttributeEncodingException.class,}) public void wrongType()
- throws AttributeEncodingException {
- IdPAttribute attribute = new IdPAttribute("id");
- final SAML2StringNameIDEncoder enc1 = new SAML2StringNameIDEncoder();
- final IdPAttributeValue<?> wrong = new IdPAttributeValue<Integer>() {
- @Override
- @Nonnull public Integer getValue() {
- return new Integer(3);
- }
- public String getDisplayValue() {
- return "3";
- }
- };
-
- attribute.setValues(Collections.singleton(wrong));
- enc1.encode(attribute);
- }
-
-}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/TransientDecoderTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/TransientDecoderTest.java
index f25e3d8..600be13 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/TransientDecoderTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/TransientDecoderTest.java
@@ -17,13 +17,14 @@
package net.shibboleth.idp.saml.nameid.impl;
+import java.util.Collection;
import java.util.Collections;
import javax.security.auth.Subject;
import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.authn.context.SubjectCanonicalizationContext;
-import net.shibboleth.idp.saml.attribute.encoding.impl.SAML2StringNameIDEncoder;
import net.shibboleth.idp.saml.attribute.resolver.impl.TransientIdAttributeDefinition;
import net.shibboleth.idp.saml.attribute.resolver.impl.TransientIdAttributeDefinitionTest;
import net.shibboleth.idp.saml.authn.principal.NameIDPrincipal;
@@ -32,10 +33,13 @@ import net.shibboleth.idp.saml.nameid.NameDecoderException;
import net.shibboleth.idp.saml.nameid.NameIDCanonicalizationFlowDescriptor;
import net.shibboleth.idp.saml.nameid.TransientIdParameters;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.opensaml.core.OpenSAMLInitBaseTestCase;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.profile.action.ActionTestingSupport;
import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.saml.common.SAMLObjectBuilder;
import org.opensaml.saml.saml2.core.NameID;
import org.opensaml.storage.impl.MemoryStorageService;
import org.testng.Assert;
@@ -129,6 +133,35 @@ public class TransientDecoderTest extends OpenSAMLInitBaseTestCase {
decoder.decode(id, PRINCIPAL);
}
+ private NameID encode(final IdPAttribute attribute) {
+
+ final Collection<IdPAttributeValue<?>> attributeValues = attribute.getValues();
+ if (attributeValues == null || attributeValues.isEmpty()) {
+ return null;
+ }
+ final SAMLObjectBuilder<NameID> identifierBuilder = (SAMLObjectBuilder<NameID>)
+ XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(NameID.DEFAULT_ELEMENT_NAME);
+ final NameID nameId = identifierBuilder.buildObject();
+ nameId.setFormat("https://example.org/");
+ for (final IdPAttributeValue attrValue : attributeValues) {
+ if (attrValue == null || attrValue.getValue() == null) {
+ continue;
+ }
+ final Object value = attrValue.getValue();
+ if (value instanceof String) {
+ // Check for empty or all-whitespace, but don't trim.
+ if (StringSupport.trimOrNull((String) value) == null) {
+ continue;
+ }
+ nameId.setValue((String) value);
+ return nameId;
+ } else {
+ continue;
+ }
+ }
+ return null;
+ }
+
@Test public void decode() throws Exception {
@@ -147,9 +180,7 @@ public class TransientDecoderTest extends OpenSAMLInitBaseTestCase {
TestSources.IDP_ENTITY_ID, TestSources.SP_ENTITY_ID));
- final SAML2StringNameIDEncoder encoder = new SAML2StringNameIDEncoder();
- encoder.setNameFormat("https://example.org/");
- final NameID nameid = encoder.encode(result);
+ final NameID nameid = encode(result);
final NameIDCanonicalizationFlowDescriptor descriptor = new NameIDCanonicalizationFlowDescriptor();
descriptor.setFormats(Collections.singleton("https://example.org/"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list