[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src: main/java/net/shibboleth/idp/attribute/res...

noreply at shibboleth.net noreply at shibboleth.net
Fri Jan 23 06:12:01 EST 2015


Author: rdw
Date: Fri Jan 23 06:12:00 2015
New Revision: 7273

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7273&view=rev
Log:
IDP-573 Reintoduce the "allow null as values" semantic into the *simulated* V2 attribute

Added:
    trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/nullValue.script
      - copied unchanged from r7272, trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail7.script
Modified:
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedIdPAttributeImpl.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeTest.java
    trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail7.script

Modified: trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedIdPAttributeImpl.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedIdPAttributeImpl.java?rev=7273&r1=7272&r2=7273&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedIdPAttributeImpl.java (original)
+++ trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedIdPAttributeImpl.java Fri Jan 23 06:12:00 2015
@@ -24,6 +24,8 @@
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import net.shibboleth.idp.attribute.EmptyAttributeValue;
+import net.shibboleth.idp.attribute.EmptyAttributeValue.EmptyType;
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
@@ -78,10 +80,9 @@
                 new StringBuilder(prefix).append(" scripted attribute '").append(attribute.getId()).append("':")
                         .toString();
     }
-    
-    /**
-     *  We use an internal list of attribute values to allow the legacy use of 
-     *  getValues().add().
+
+    /**
+     * We use an internal list of attribute values to allow the legacy use of getValues().add().
      */
     private void setupAttributeValues() {
         if (null != attributeValues) {
@@ -94,6 +95,9 @@
         for (final IdPAttributeValue value : encapsulatedAttribute.getValues()) {
             if ((value instanceof StringAttributeValue) && !(value instanceof ScopedStringAttributeValue)) {
                 newValues.add(((StringAttributeValue) value).getValue());
+            } else if (value instanceof EmptyAttributeValue) {
+                // Shib2 made both empty strings and nulls null
+                newValues.add(null);
             } else {
                 newValues.add(value);
             }
@@ -109,8 +113,7 @@
      * @return a modifiable collection of the string attributes (not the String
      * @throws ResolutionException if the script has called {@link #getNativeAttribute()}
      */
-    @Override
-    @Nullable @NonnullElements public Collection<Object> getValues() throws ResolutionException {
+    @Override @Nullable @NonnullElements public Collection<Object> getValues() throws ResolutionException {
         if (calledGetNativeAttribute) {
             throw new ResolutionException(getLogPrefix()
                     + " cannot call getNativeAttribute() and getValues() or addValues() on the same attribute()");
@@ -128,8 +131,7 @@
      * @return the attribute
      * @throws ResolutionException if the script has called getValues.
      */
-    @Override
-    @Nonnull public IdPAttribute getNativeAttribute() throws ResolutionException {
+    @Override @Nonnull public IdPAttribute getNativeAttribute() throws ResolutionException {
         if (null != attributeValues) {
             throw new ResolutionException(getLogPrefix()
                     + "': cannot call getNativeAttribute() and getValues()/setValues() on the same attribute()");
@@ -143,8 +145,7 @@
      * 
      * @return the id
      */
-    @Override
-    @Nonnull @NotEmpty public String getId() {
+    @Override @Nonnull @NotEmpty public String getId() {
         return encapsulatedAttribute.getId();
     }
 
@@ -154,8 +155,10 @@
      * @param values the list to add to.
      * @param value the value to add. Known to be a {@link String} or an {@link IdPAttributeValue}
      */
-    private void addValue(@Nonnull final List<IdPAttributeValue<?>> values, @Nonnull final Object value) {
-        if (value instanceof String) {
+    private void addAsIdPAttributeValue(final List<IdPAttributeValue<?>> values, final Object value) {
+        if (null == value) {
+            values.add(new EmptyAttributeValue(EmptyType.NULL_VALUE));
+        } else if (value instanceof String) {
             values.add(StringAttributeValue.valueOf((String) value));

[... 91 lines stripped ...]


More information about the commits mailing list