mace-opensaml-users - Re: SAMLNameIdentifier.equals
Subject: OpenSAML user discussion
List archive
- From: Chad La Joie <>
- To: OpenSAML <>
- Subject: Re: SAMLNameIdentifier.equals
- Date: Fri, 13 Jan 2006 13:48:29 -0500
- Organization: UIS - Project Sentinel
Generally, the equals() method does reference comparison, as I mentioned before. The normal way, in Java, to do equality checking when there are application specific ways to do it, is to create one or more java.util.Comparator implementations. This can be used for equality comparison and ordering (with certain types of Collections). This allows application to do what they want, without having to worry/wonder about what the developer did, or might do, with the equals() method.
After talking with Scott about this, this is the route we suggest if you need to do comparisons on SAMLObjects.
Tom Scavo wrote:
The unit test
public void testSAMLNameIdentifier() throws Exception {
SAMLNameIdentifier nameid1 =
SAMLNameIdentifier.getInstance(new FileInputStream(xmlpath));
SAMLNameIdentifier nameid2 = (SAMLNameIdentifier) nameid1.clone();
assertEquals("Name identifiers are not equal", nameid1, nameid2);
}
fails with the following error message:
Name identifiers are not equal expected:<<NameIdentifier
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">uid=By-Tor,ou=tobes,dc=hades,dc=com</NameIdentifier>>
but was:<<NameIdentifier xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">uid=By-Tor,ou=tobes,dc=hades,dc=com</NameIdentifier>>
If I replace the call to assertEquals with
assertEquals("Serialized name identifiers are not equal",
nameid1.toString(), nameid2.toString());
the test succeeds.
Why does a straight 'equals' test fail? Should SAMLNameIdentifier (or
its superclass SAMLObject) define an 'equals' method?
Thanks,
Tom
--
Chad La Joie 315Q St. Mary's Hall
OIS-Middleware 202.687.0124
- RE: SAMLNameIdentifier.equals, (continued)
- RE: SAMLNameIdentifier.equals, Scott Cantor, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- RE: SAMLNameIdentifier.equals, Scott Cantor, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- Re: SAMLNameIdentifier.equals, Chad La Joie, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- RE: SAMLNameIdentifier.equals, Scott Cantor, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- RE: SAMLNameIdentifier.equals, Scott Cantor, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- RE: SAMLNameIdentifier.equals, Scott Cantor, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
- Re: SAMLNameIdentifier.equals, Tom Scavo, 01/13/2006
Archive powered by MHonArc 2.6.16.