[java-identity-provider] 01/06: IDP-1121 Remove LocalizedStringAttribute
Rod Widdowson
rdw at steadingsoftware.com
Fri May 17 09:09:59 EDT 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=825be23fa44088f42107b0e79cab35049ea7ee03
commit 825be23fa44088f42107b0e79cab35049ea7ee03
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri May 17 09:36:47 2019 +0100
IDP-1121 Remove LocalizedStringAttribute
https://issues.shibboleth.net/jira/browse/IDP-1121
---
.../attribute/LocalizedStringAttributeValue.java | 90 ----------------------
.../shibboleth/idp/attribute/AttributeTest.java | 6 +-
.../LocalizedStringAttributeValueTest.java | 48 ------------
.../impl/CASStringAttributeTranscoder.java | 11 ++-
.../impl/SAML1StringAttributeTranscoder.java | 17 ++--
.../impl/SAML2StringAttributeTranscoder.java | 17 ++--
6 files changed, 24 insertions(+), 165 deletions(-)
diff --git a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValue.java b/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValue.java
deleted file mode 100644
index 89cffdc..0000000
--- a/idp-attribute-api/src/main/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValue.java
+++ /dev/null
@@ -1,90 +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.Locale;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/** An optionally localized String value of an {@link IdPAttribute}. */
-public class LocalizedStringAttributeValue extends StringAttributeValue {
-
- /** The locale of the attribute value. */
- private final Locale valueLocale;
-
- /**
- * Constructor.
- *
- * @param attributeValue the value of the attribute
- * @param attributeValueLocale the locale of the attribute value
- */
- public LocalizedStringAttributeValue(
- @Nonnull @NotEmpty @ParameterName(name="attributeValue") final String attributeValue,
- @Nullable @ParameterName(name="attributeValueLocale") final Locale attributeValueLocale) {
- super(attributeValue);
- valueLocale = attributeValueLocale;
- }
-
- /**
- * Get the locale of the attribute value.
- *
- * @return the local of the attribute or null if there no explicit locale
- */
- @Nullable public final Locale getValueLocale() {
- return valueLocale;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(@Nullable final Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof LocalizedStringAttributeValue)) {
- return false;
- }
-
- final LocalizedStringAttributeValue other = (LocalizedStringAttributeValue) obj;
- return java.util.Objects.equals(getValue(), other.getValue())
- && java.util.Objects.equals(valueLocale, other.valueLocale);
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hashCode(getValue(), valueLocale);
- }
-
- /** {@inheritDoc} */
- @Override
- @Nonnull public String toString() {
- return MoreObjects.toStringHelper(this).add("value", getValue()).add("locale", valueLocale).toString();
- }
-}
\ No newline at end of file
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 bf3187e..13c186e 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
@@ -219,8 +219,8 @@ public class AttributeTest {
/** Tests that values are properly added and modified. */
@Test(enabled=false) public void values() {
- LocalizedStringAttributeValue value1 = new LocalizedStringAttributeValue("value1", null);
- LocalizedStringAttributeValue value2 = new LocalizedStringAttributeValue("value2", null);
+ StringAttributeValue value1 = new StringAttributeValue("value1");
+ StringAttributeValue value2 = new StringAttributeValue("value2");
IdPAttribute attrib = new IdPAttribute("foo");
Assert.assertTrue(attrib.getValues().isEmpty());
@@ -326,7 +326,7 @@ public class AttributeTest {
Assert.assertTrue(attrib.compareTo(diff) > 0);
Assert.assertEquals(attrib.compareTo(dupl) , 0);
- attrib.setValues(Collections.singletonList(new LocalizedStringAttributeValue("value1", null)));
+ attrib.setValues(Collections.singletonList(new StringAttributeValue("value1")));
attrib.setDisplayDescriptions(Collections.singletonMap(new Locale("en"), "Descrption"));
attrib.setDisplayNames(Collections.singletonMap(new Locale("en"), "Name"));
attrib.toString();
diff --git a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValueTest.java b/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValueTest.java
deleted file mode 100644
index f18e4b4..0000000
--- a/idp-attribute-api/src/test/java/net/shibboleth/idp/attribute/LocalizedStringAttributeValueTest.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.attribute;
-
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/** test for {@link LocalizedStringAttributeValue}. Derived from coverage info.
- *
- */
-public class LocalizedStringAttributeValueTest {
-
- @SuppressWarnings("unlikely-arg-type")
- @Test public void localizedStringAttributeValue() {
- Set foo = new HashSet();
-
- LocalizedStringAttributeValue val = new LocalizedStringAttributeValue("for", new Locale("en"));
-
- foo.add(val);
- foo.add(null);
- foo.add(val);
- foo.add(new LocalizedStringAttributeValue("for", new Locale("en")));
- foo.add(new LocalizedStringAttributeValue("for", new Locale("fr")));
- Assert.assertEquals(val.getValueLocale().getLanguage(), "en");
- Assert.assertFalse(val.equals(null));
- Assert.assertTrue(val.equals(val));
- Assert.assertFalse(val.equals(Integer.valueOf(2)));
- }
-}
diff --git a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/attribute/transcoding/impl/CASStringAttributeTranscoder.java b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/attribute/transcoding/impl/CASStringAttributeTranscoder.java
index f958d60..fbab63f 100644
--- a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/attribute/transcoding/impl/CASStringAttributeTranscoder.java
+++ b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/attribute/transcoding/impl/CASStringAttributeTranscoder.java
@@ -20,20 +20,19 @@ package net.shibboleth.idp.cas.attribute.transcoding.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
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.attribute.transcoding.TranscodingRule;
import net.shibboleth.idp.cas.attribute.AbstractCASAttributeTranscoder;
import net.shibboleth.idp.cas.attribute.Attribute;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* {@link net.shibboleth.idp.attribute.AttributeTranscoder} that supports {@link Attribute} and
* {@link StringAttributeValue} objects.
@@ -54,7 +53,7 @@ public class CASStringAttributeTranscoder extends AbstractCASAttributeTranscoder
@Nonnull final IdPAttribute attribute, @Nonnull final TranscodingRule rule,
@Nonnull final StringAttributeValue value) throws AttributeEncodingException {
- if (value instanceof LocalizedStringAttributeValue || value instanceof ScopedStringAttributeValue) {
+ if (value instanceof ScopedStringAttributeValue) {
log.warn("Attribute '{}': Lossy encoding of attribute value of type {} to SAML1 String Attribute",
attribute.getId(), value.getClass().getSimpleName());
}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1StringAttributeTranscoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1StringAttributeTranscoder.java
index 3e595ad..2375cbe 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1StringAttributeTranscoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML1StringAttributeTranscoder.java
@@ -20,23 +20,22 @@ package net.shibboleth.idp.saml.attribute.transcoding.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.saml.saml1.core.AttributeDesignator;
+import org.opensaml.saml.saml1.core.AttributeValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
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.attribute.transcoding.TranscodingRule;
import net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML1AttributeTranscoder;
import net.shibboleth.idp.saml.attribute.transcoding.SAMLEncoderSupport;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.saml1.core.AttributeDesignator;
-import org.opensaml.saml.saml1.core.AttributeValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* {@link net.shibboleth.idp.attribute.AttributeTranscoder} that supports {@link AttributeDesignator} and
* {@link StringAttributeValue} objects.
@@ -57,7 +56,7 @@ public class SAML1StringAttributeTranscoder extends AbstractSAML1AttributeTransc
@Nonnull final IdPAttribute attribute, @Nonnull final TranscodingRule rule,
@Nonnull final StringAttributeValue value) throws AttributeEncodingException {
- if (value instanceof LocalizedStringAttributeValue || value instanceof ScopedStringAttributeValue) {
+ if (value instanceof ScopedStringAttributeValue) {
log.warn("Attribute '{}': Lossy encoding of attribute value of type {} to SAML1 String Attribute",
attribute.getId(), value.getClass().getSimpleName());
}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2StringAttributeTranscoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2StringAttributeTranscoder.java
index 64d95b8..158b55c 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2StringAttributeTranscoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/attribute/transcoding/impl/SAML2StringAttributeTranscoder.java
@@ -20,23 +20,22 @@ package net.shibboleth.idp.saml.attribute.transcoding.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.saml.saml2.core.Attribute;
+import org.opensaml.saml.saml2.core.AttributeValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
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.attribute.transcoding.TranscodingRule;
import net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML2AttributeTranscoder;
import net.shibboleth.idp.saml.attribute.transcoding.SAMLEncoderSupport;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.saml2.core.Attribute;
-import org.opensaml.saml.saml2.core.AttributeValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* {@link net.shibboleth.idp.attribute.AttributeTranscoder} that supports {@link Attribute} and
* {@link StringAttributeValue} objects.
@@ -57,7 +56,7 @@ public class SAML2StringAttributeTranscoder extends AbstractSAML2AttributeTransc
@Nonnull final IdPAttribute attribute, @Nonnull final TranscodingRule rule,
@Nonnull final StringAttributeValue value) throws AttributeEncodingException {
- if (value instanceof LocalizedStringAttributeValue || value instanceof ScopedStringAttributeValue) {
+ if (value instanceof ScopedStringAttributeValue) {
log.warn("Attribute '{}': Lossy encoding of attribute value of type {} to SAML2 String Attribute",
attribute.getId(), value.getClass().getSimpleName());
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list