[java-identity-provider COMMIT] /trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHash...

noreply at shibboleth.net noreply at shibboleth.net
Fri Dec 19 18:47:10 EST 2014


Author: scantor
Date: Fri Dec 19 18:47:10 2014
New Revision: 7193

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7193&view=rev
Log:
Make hashing calc. consistent with uApprove.

Modified:
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java

Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java?rev=7193&r1=7192&r2=7193&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java Fri Dec 19 18:47:10 2014
@@ -26,10 +26,16 @@
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.IdPAttributeValue;
+import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
+import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
 import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.xml.SerializeSupport;
 
 import org.cryptacular.util.CodecUtil;
 import org.cryptacular.util.HashUtil;
+import org.opensaml.core.xml.io.MarshallingException;
+import org.opensaml.core.xml.util.XMLObjectSupport;
+import org.opensaml.saml.saml2.core.NameIDType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,7 +75,24 @@
             final ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
 
             for (final IdPAttributeValue value : filteredInput) {
-                objectOutputStream.writeObject(value.getValue());
+                if (value instanceof ScopedStringAttributeValue) {
+                    objectOutputStream.writeObject(((ScopedStringAttributeValue) value).getValue() + '@'
+                            + ((ScopedStringAttributeValue) value).getScope());
+                } else if (value instanceof XMLObjectAttributeValue) {
+                    if (value.getValue() instanceof NameIDType) {
+                        objectOutputStream.writeObject(((NameIDType) value.getValue()).getValue());
+                    } else {
+                        try {
+                            objectOutputStream.writeObject(SerializeSupport.nodeToString(
+                                    XMLObjectSupport.marshall(((XMLObjectAttributeValue) value).getValue())));
+                        } catch (final MarshallingException e) {
+                            log.error("Error while marshalling XMLObject value", e);
+                            return null;
+                        }
+                    }
+                } else {
+                    objectOutputStream.writeObject(value.getValue());
+                }
             }
 
             objectOutputStream.flush();
@@ -78,7 +101,7 @@
 
             return CodecUtil.b64(HashUtil.sha256(byteArrayOutputStream.toByteArray()));
 
-        } catch (IOException e) {
+        } catch (final IOException e) {
             log.error("Error while converting attribute values into a byte array", e);
             return null;
         }



More information about the commits mailing list