[java-opensaml] branch master updated: IDP-1297 - Missing qualifiers in LogoutRequest result in mismatch

Scott Cantor cantor.2 at osu.edu
Tue Jul 24 10:11:34 EDT 2018


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

scantor pushed a commit to branch master
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=1f4d76177488b6f2753abc2f294e620094752a60

The following commit(s) were added to refs/heads/master by this push:
       new  1f4d761   IDP-1297 - Missing qualifiers in LogoutRequest result in mismatch
1f4d761 is described below

commit 1f4d76177488b6f2753abc2f294e620094752a60
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jul 24 10:11:29 2018 -0400

    IDP-1297 - Missing qualifiers in LogoutRequest result in mismatch
    
    https://issues.shibboleth.net/jira/browse/IDP-1297
---
 .../saml/saml2/profile/SAML2ObjectSupport.java     | 45 ++++++++++++++++++----
 1 file changed, 37 insertions(+), 8 deletions(-)

diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ObjectSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ObjectSupport.java
index 92f0720..bc350e0 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ObjectSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/profile/SAML2ObjectSupport.java
@@ -23,8 +23,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.opensaml.saml.saml2.core.NameID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * A helper class for working with SAMLObjects.
@@ -42,6 +40,7 @@ public final class SAML2ObjectSupport {
      * 
      * @param format1   first format to check
      * @param format2   second format to check
+     * 
      * @return  true iff the two format values should be viewed as equivalent
      */
     public static boolean areNameIDFormatsEquivalent(@Nullable final String format1,
@@ -53,10 +52,12 @@ public final class SAML2ObjectSupport {
     }
 
     /**
-     * Return true iff the two input {@link NameID} objects are equivalent for SAML 2.0 purposes.
+     * Return true iff the two input {@link NameID} objects are equivalent for SAML 2.0 purposes, with
+     * the assumption that the qualifier attributes must match exactly.
      * 
      * @param name1   first NameID to check
      * @param name2   second NameID to check
+     * 
      * @return  true iff the two values should be viewed as equivalent
      */
     public static boolean areNameIDsEquivalent(@Nonnull final NameID name1, @Nonnull final NameID name2) {
@@ -66,14 +67,42 @@ public final class SAML2ObjectSupport {
                 && Objects.equals(name1.getSPNameQualifier(), name2.getSPNameQualifier());
     }
 
-    
     /**
-     * Get an SLF4J Logger.
+     * Return true iff the two input {@link NameID} objects are equivalent for SAML 2.0 purposes, allowing
+     * thw qualifier attributes to assume default values if not otherwise set.
+     * 
+     * @param name1   first NameID to check
+     * @param name2   second NameID to check
+     * @param assertingParty optional name of asserting party to default in as NameQualifier
+     * @param relyingParty optional name of relying party to default in as SPNameQualifier 
      * 
-     * @return a Logger instance
+     * @return  true iff the two values should be viewed as equivalent
+     * 
+     * @since 3.4.0
      */
-    @Nonnull private static Logger getLogger() {
-        return LoggerFactory.getLogger(SAML2ObjectSupport.class);
+    public static boolean areNameIDsEquivalent(@Nonnull final NameID name1, @Nonnull final NameID name2,
+            @Nullable final String assertingParty, @Nullable final String relyingParty) {
+        
+        if (!areNameIDFormatsEquivalent(name1.getFormat(), name2.getFormat())
+                || !Objects.equals(name1.getValue(), name2.getValue()))
+            return false;
+        
+        String name1qual = name1.getNameQualifier();
+        String name2qual = name2.getNameQualifier();
+        if (name1qual == null)
+            name1qual = assertingParty;
+        if (name2qual == null)
+            name2qual = assertingParty;
+        if (!Objects.equals(name1qual, name2qual))
+            return false;
+
+        name1qual = name1.getSPNameQualifier();
+        name2qual = name2.getSPNameQualifier();
+        if (name1qual == null)
+            name1qual = relyingParty;
+        if (name2qual == null)
+            name2qual = relyingParty;
+        return Objects.equals(name1qual, name2qual);
     }
 
 }
\ No newline at end of file

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


More information about the commits mailing list