[java-shib-attribute] 03/03: IDP-1959 IdPAttributes to stop carrying Display Information

Rod Widdowson rdw at steadingsoftware.com
Sun Jul 17 14:13:58 UTC 2022


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-shib-attribute.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=cb7170a6ebe432ce1d3dc78126d2a6d06c9130b0

commit cb7170a6ebe432ce1d3dc78126d2a6d06c9130b0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jul 17 15:05:05 2022 +0100

    IDP-1959 IdPAttributes to stop carrying Display Information
    
    https://shibboleth.atlassian.net/browse/IDP-1959
    
    Remove all DisplayInformation from attributes.
---
 .../net/shibboleth/idp/attribute/IdPAttribute.java |  65 +----------
 .../shibboleth/idp/attribute/AttributeTest.java    | 122 ---------------------
 .../impl/AttributeTranscoderRegistryImplTest.java  |   4 -
 3 files changed, 1 insertion(+), 190 deletions(-)

diff --git a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
index db90a4b99..be0ff6c76 100644
--- a/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
+++ b/shib-attribute-api/src/main/java/net/shibboleth/idp/attribute/IdPAttribute.java
@@ -93,12 +93,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
     /** ID of this attribute. */
     @Nonnull private final String id;
 
-    /** Localized human intelligible attribute names. */
-    @Nonnull private Map<Locale, String> displayNames;
-
-    /** Localized human readable descriptions of attribute. */
-    @Nonnull private Map<Locale, String> displayDescriptions;
-
     /** Values for this attribute. */
     @Nonnull private List<IdPAttributeValue> values;
 
@@ -120,9 +114,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
             LOG.debug("{} - deprecated character in attribute name", id);
             LOG.trace("Stack", new Exception("Stack Trace, not a thrown exception:"));
         }
-        displayNames = Collections.emptyMap();
-        displayDescriptions = Collections.emptyMap();
-
         values = Collections.emptyList();
     }
 
@@ -154,17 +145,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
         return id;
     }
 
-    /**
-     * Gets the localized human readable name of the attribute.
-     * @deprecated These values should be calculated at point of use
-     * 
-     * @return human readable name of the attribute
-     */
-    @Deprecated(forRemoval = true, since = "4.2") @Nonnull @NonnullElements @Unmodifiable
-    public Map<Locale, String> getDisplayNames() {
-        return displayNames;
-    }
-
     /**
      * Process input to {@link #setDisplayNames(Map)} and {{@link #setDisplayDescriptions(Map)} to strip out null input,
      * null keys, and null values.
@@ -183,45 +163,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
                 toArray(Map.Entry[]::new));
     }
 
-    /**
-     * Replaces the existing display names for this attribute with the given ones.
-     * @deprecated These values should be calculated at point of use
-     * 
-     * @param newNames the new names for this attribute
-     */
-    @Deprecated(forRemoval = true, since = "4.2")
-    public void setDisplayNames(@Nonnull @NonnullElements final Map<Locale, String> newNames) {
-        DeprecationSupport.warnOnce(ObjectType.METHOD, "setDisplayNames", null, null);
-        displayNames = checkedNamesFrom(
-                Constraint.isNotNull(newNames, "Display Names should not be null"));
-    }
-
-    /**
-     * Gets the localized human readable description of attribute.
-     * @deprecated These values should be calculated at point of use
-     * 
-     * @return human readable description of attribute
-     */
-    @Deprecated(forRemoval = true, since = "4.2")
-    @Nonnull @NonnullElements @Unmodifiable public Map<Locale, String> getDisplayDescriptions() {
-        return displayDescriptions;
-    }
-
-    /**
-     * Replaces the existing display descriptions for this attribute with the given ones.
-     * @deprecated These values should be calculated at point of use
-     * 
-     * @param newDescriptions the new descriptions for this attribute
-     */
-    @Deprecated(forRemoval = true, since = "4.2")
-    public void setDisplayDescriptions(@Nonnull @NonnullElements final Map<Locale, String> newDescriptions) {
-        if (!newDescriptions.isEmpty()) {
-            DeprecationSupport.warnOnce(ObjectType.METHOD, "setDisplayDescriptions", null, null);
-        }
-        displayDescriptions = checkedNamesFrom(
-                Constraint.isNotNull(newDescriptions, "Display Descriptions should not be null"));
-    }
-
     /**
      * Get the unmodifiable ordered collection of values of the attribute.
      * 
@@ -265,8 +206,6 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
     @Override
     @Nonnull public IdPAttribute clone() throws CloneNotSupportedException {
         final IdPAttribute clone = (IdPAttribute) super.clone();
-        clone.displayDescriptions = checkedNamesFrom(this.displayDescriptions);
-        clone.displayNames = checkedNamesFrom(this.displayNames);
         clone.setValues(getValues());
         return clone;
     }
@@ -299,9 +238,7 @@ public class IdPAttribute implements Comparable<IdPAttribute>, Cloneable {
     /** {@inheritDoc} */
     @Override
     @Nonnull public String toString() {
-        return MoreObjects.toStringHelper(this).add("id", getId()).add("displayNames", displayNames)
-                .add("displayDescriptions", displayDescriptions).add("values", values)
-                .toString();
+        return MoreObjects.toStringHelper(this).add("id", getId()).add("values", values).toString();
     }
     
 }
diff --git a/shib-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java b/shib-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
index 7059dd324..077762425 100644
--- a/shib-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
+++ b/shib-attribute-api/src/test/java/net/shibboleth/idp/attribute/AttributeTest.java
@@ -49,12 +49,6 @@ public class AttributeTest extends OpenSAMLInitBaseTestCase{
 
         Assert.assertEquals(attrib.getId(), "foo");
 
-        Assert.assertNotNull(attrib.getDisplayDescriptions());
-        Assert.assertTrue(attrib.getDisplayDescriptions().isEmpty());
-
-        Assert.assertNotNull(attrib.getDisplayNames());
-        Assert.assertTrue(attrib.getDisplayNames().isEmpty());
-
         Assert.assertNotNull(attrib.getValues());
         Assert.assertTrue(attrib.getValues().isEmpty());
 
@@ -96,121 +90,7 @@ public class AttributeTest extends OpenSAMLInitBaseTestCase{
         
     }
 
-    /** Tests that display names are properly added and modified. */
-    @Test public void displayNames() {
-        Locale en = new Locale("en");
-        Locale enbr = new Locale("en", "br");
-
-        IdPAttribute attrib = new IdPAttribute("foo");
-        attrib.setDisplayNames(Collections.EMPTY_MAP);
-        Assert.assertTrue(attrib.getDisplayNames().isEmpty());
-
-        attrib.setDisplayNames(Collections.emptyMap());
-        Assert.assertTrue(attrib.getDisplayNames().isEmpty());
-
-        Map<Locale, String> displayNames = new HashMap<>();
-        // test adding one entry
-        displayNames.put(en, " english ");
-        attrib.setDisplayNames(displayNames);
-        
-        Assert.assertFalse(attrib.getDisplayNames().isEmpty());
-        Assert.assertEquals(attrib.getDisplayNames().size(), 1);
-        Assert.assertTrue(attrib.getDisplayNames().containsKey(en));
-        Assert.assertEquals(attrib.getDisplayNames().get(en), "english");
-
-        // test adding another entry
-        displayNames.put(enbr, "british");
-        displayNames.put(en, " englishX ");
-        attrib.setDisplayNames(displayNames);
-        Assert.assertFalse(attrib.getDisplayNames().isEmpty());
-        Assert.assertEquals(attrib.getDisplayNames().size(), 2);
-        Assert.assertTrue(attrib.getDisplayNames().containsKey(enbr));
-        Assert.assertEquals(attrib.getDisplayNames().get(enbr), "british");
-        Assert.assertEquals(attrib.getDisplayNames().get(en), "englishX");
-
-        // test replacing an entry
-        String replacedName = displayNames.put(en, "english ");
-        Assert.assertEquals(replacedName, " englishX ");
-
-        attrib.setDisplayNames(displayNames);
-        Assert.assertFalse(attrib.getDisplayNames().isEmpty());
-        Assert.assertEquals(attrib.getDisplayNames().size(), 2);
-        Assert.assertTrue(attrib.getDisplayNames().containsKey(en));
-        Assert.assertEquals(attrib.getDisplayNames().get(en), "english");
-
-        try {
-            // test removing an entry
-            attrib.getDisplayNames().remove(en);
-            Assert.fail();
-        } catch (UnsupportedOperationException e) {
-        }
-        try {
-            // test removing an entry
-            attrib.getDisplayNames().put(en, "foo");
-            Assert.fail();
-        } catch (UnsupportedOperationException e) {
-        }
-    }
 
-    /** Tests that display descriptions are properly added and modified. */
-    @Test public void displayDescriptions() {
-        Locale en = new Locale("en");
-        Locale enbr = new Locale("en", "br");
-
-        IdPAttribute attrib = new IdPAttribute("foo");
-        attrib.setDisplayDescriptions(Collections.EMPTY_MAP);
-        Assert.assertTrue(attrib.getDisplayNames().isEmpty());
-
-        attrib.setDisplayNames(Collections.emptyMap());
-        Assert.assertTrue(attrib.getDisplayDescriptions().isEmpty());
-
-        Map<Locale, String> displayDescriptions = new HashMap<>();
-        displayDescriptions.clear();
-        attrib.setDisplayDescriptions(displayDescriptions);
-        Assert.assertTrue(attrib.getDisplayDescriptions().isEmpty());
-
-        displayDescriptions.clear();
-        displayDescriptions.put(en, " english ");
-        attrib.setDisplayDescriptions(displayDescriptions);
-        
-        Assert.assertFalse(attrib.getDisplayDescriptions().isEmpty());
-        Assert.assertEquals(attrib.getDisplayDescriptions().size(), 1);
-        Assert.assertTrue(attrib.getDisplayDescriptions().containsKey(en));
-        Assert.assertEquals(attrib.getDisplayDescriptions().get(en), "english");
-
-        // test adding another entry
-        displayDescriptions.put(enbr, "british");
-        displayDescriptions.put(en, " englishX ");
-        attrib.setDisplayDescriptions(displayDescriptions);
-        Assert.assertFalse(attrib.getDisplayDescriptions().isEmpty());
-        Assert.assertEquals(attrib.getDisplayDescriptions().size(), 2);
-        Assert.assertTrue(attrib.getDisplayDescriptions().containsKey(enbr));
-        Assert.assertEquals(attrib.getDisplayDescriptions().get(enbr), "british");
-        Assert.assertEquals(attrib.getDisplayDescriptions().get(en), "englishX");
-
-        // test replacing an entry
-        String replacedName = displayDescriptions.put(en, "english ");
-        Assert.assertEquals(replacedName, " englishX ");
-
-        attrib.setDisplayDescriptions(displayDescriptions);
-        Assert.assertFalse(attrib.getDisplayDescriptions().isEmpty());
-        Assert.assertEquals(attrib.getDisplayDescriptions().size(), 2);
-        Assert.assertTrue(attrib.getDisplayDescriptions().containsKey(en));
-        Assert.assertEquals(attrib.getDisplayDescriptions().get(en), "english");
-
-        try {
-            // test removing an entry
-            attrib.getDisplayDescriptions().remove(en);
-            Assert.fail();
-        } catch (UnsupportedOperationException e) {
-        }
-        try {
-            // test removing an entry
-            attrib.getDisplayDescriptions().put(en, "foo");
-            Assert.fail();
-        } catch (UnsupportedOperationException e) {
-        }
-    }
 
     /** Tests that values are properly added and modified. */
     @Test(enabled=false) public void values() {
@@ -322,8 +202,6 @@ public class AttributeTest extends OpenSAMLInitBaseTestCase{
         Assert.assertEquals(attrib.compareTo(dupl) , 0);
         
         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/shib-attribute-impl/src/test/java/net/shibboleth/idp/attribute/transcoding/impl/AttributeTranscoderRegistryImplTest.java b/shib-attribute-impl/src/test/java/net/shibboleth/idp/attribute/transcoding/impl/AttributeTranscoderRegistryImplTest.java
index 1b402e780..b137de868 100644
--- a/shib-attribute-impl/src/test/java/net/shibboleth/idp/attribute/transcoding/impl/AttributeTranscoderRegistryImplTest.java
+++ b/shib-attribute-impl/src/test/java/net/shibboleth/idp/attribute/transcoding/impl/AttributeTranscoderRegistryImplTest.java
@@ -211,13 +211,9 @@ public class AttributeTranscoderRegistryImplTest {
         
         assertEquals(attributes.get(0).getId(), "foo");
         assertTrue(attributes.get(0).getValues().isEmpty());
-        assertTrue(attributes.get(0).getDisplayNames().isEmpty());
-        assertTrue(attributes.get(0).getDisplayDescriptions().isEmpty());
 
         assertEquals(attributes.get(1).getId(), "foo2");
         assertTrue(attributes.get(1).getValues().isEmpty());
-        assertTrue(attributes.get(1).getDisplayNames().isEmpty());
-        assertTrue(attributes.get(1).getDisplayDescriptions().isEmpty());
     }
 
     @Test public void testEncodeStringValues() throws AttributeEncodingException {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list