Author: anil.saldhana(a)jboss.com
Date: 2010-11-30 17:48:15 -0500 (Tue, 30 Nov 2010)
New Revision: 575
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLAssertionParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-response-assertion-subject.xml
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AssertionType.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AuthnContextType.java
Log:
fixes
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLAssertionParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLAssertionParser.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLAssertionParser.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -83,11 +83,8 @@
encryptedAssertion.setEncryptedElement( resultDocument.getDocumentElement() );
return encryptedAssertion;
}
-
+
-
-
-
startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
//Special case: Encrypted Assertion
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -121,14 +121,7 @@
//Get the end tag
EndElement endElement = (EndElement)
StaxParserUtil.getNextEvent(xmlEventReader);
StaxParserUtil.matches(endElement,
JBossSAMLConstants.SUBJECT_CONFIRMATION.get() );
- }
- else if( JBossSAMLConstants.ATTRIBUTE_STATEMENT.get().equals( tag ))
- {
- throw new RuntimeException( "NYI" );
- /*AttributeStatementType attributeStatement =
SAMLParserUtil.parseAttributeStatement(xmlEventReader);
- JAXBElement<?> jaxbEl =
SAMLAssertionFactory.getObjectFactory().createAttributeStatement(attributeStatement);
- subject.getContent().add( jaxbEl );*/
- }
+ }
else throw new RuntimeException( "Unknown tag:" + tag );
}
return subject;
@@ -241,5 +234,5 @@
}
}
return keyInfo;
- }
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -37,7 +37,7 @@
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType.ASTChoiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnContextClassRefType;
-import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnContextDeclType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnContextDeclRefType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnContextType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnStatementType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
@@ -220,7 +220,7 @@
{
String text = StaxParserUtil.getElementText( xmlEventReader );
- AuthnContextDeclType aAuthnContextDeclType = new AuthnContextDeclType(
NetworkUtil.createURI(text));
+ AuthnContextDeclRefType aAuthnContextDeclType = new AuthnContextDeclRefType(
NetworkUtil.createURI(text));
authnContextType.addURIType(aAuthnContextDeclType);
EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate(endElement, JBossSAMLConstants.AUTHN_CONTEXT.get() );
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -89,7 +89,8 @@
StaxUtil.writeAttribute( writer, JBossSAMLConstants.ISSUE_INSTANT.get(),
assertion.getIssueInstant().toString() );
NameIDType issuer = assertion.getIssuer();
- write( issuer, new QName( ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get() )
);
+ if( issuer != null )
+ write( issuer, new QName( ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get()
) );
SubjectType subject = assertion.getSubject();
if( subject != null )
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -31,7 +31,6 @@
import java.util.List;
import java.util.Set;
-import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.junit.Test;
@@ -41,9 +40,19 @@
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter;
-import org.picketlink.identity.federation.core.util.StaxUtil;
-import org.picketlink.identity.federation.newmodel.saml.v2.assertion.*;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType;
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType.ASTChoiceType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AudienceRestrictionType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnStatementType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.ConditionsType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.StatementAbstractType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectConfirmationDataType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectConfirmationType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectType;
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectType.STSubType;
/**
@@ -74,12 +83,12 @@
STSubType subType = subject.getSubType();
NameIDType subjectNameID = (NameIDType) subType.getBaseID();
assertEquals( "jduke", subjectNameID.getValue() );
- assertEquals( "urn:picketlink:identity-federation",
subjectNameID.getNameQualifier() );
- SubjectConfirmationType subjectConfirmation = subject.getConfirmation().get(0 );
- SubjectConfirmationDataType subjectConfirmationDataType =
subjectConfirmation.getSubjectConfirmationData();
- assertEquals( XMLTimeUtil.parse( "2010-09-30T19:13:37.869Z" ) ,
subjectConfirmationDataType.getNotBefore() );
- assertEquals( XMLTimeUtil.parse( "2010-09-30T21:13:37.869Z" ) ,
subjectConfirmationDataType.getNotOnOrAfter() );
+ assertEquals( "urn:picketlink:identity-federation",
subjectNameID.getNameQualifier() );
+ ConditionsType conditions = assertion.getConditions();
+ assertEquals( XMLTimeUtil.parse( "2010-09-30T19:13:37.869Z" ) ,
conditions.getNotBefore() );
+ assertEquals( XMLTimeUtil.parse( "2010-09-30T21:13:37.869Z" ) ,
conditions.getNotOnOrAfter() );
+
/*List<JAXBElement<?>> content = subject.getContent();
int size = content.size();
@@ -144,7 +153,7 @@
AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType)
conditions.getConditions().get(0);
assertEquals( 1, audienceRestrictionType.getAudience().size() );
- assertEquals( "http://services.testcorp.org/provider2",
audienceRestrictionType.getAudience().get( 0 ));
+ assertEquals( "http://services.testcorp.org/provider2",
audienceRestrictionType.getAudience().get( 0 ).toASCIIString());
/*List<JAXBElement<?>> content = subject.getContent();
@@ -230,7 +239,7 @@
STSubType subType = subject.getSubType();
NameIDType subjectNameID = (NameIDType) subType.getBaseID();
assertEquals( "3f7b3dcf-1674-4ecd-92c8-1544f346baf8",
subjectNameID.getValue() );
- assertEquals( "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
subjectNameID.getFormat() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
subjectNameID.getFormat().toString() );
SubjectConfirmationType subjectConfirmation = subject.getConfirmation().get(0 );
assertEquals( "urn:oasis:names:tc:SAML:2.0:cm:bearer",
subjectConfirmation.getMethod() );
@@ -246,7 +255,7 @@
AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType)
conditions.getConditions().get(0);
assertEquals( 1, audienceRestrictionType.getAudience().size() );
- assertEquals( "https://sp.example.com/SAML2",
audienceRestrictionType.getAudience().get( 0 ));
+ assertEquals( "https://sp.example.com/SAML2",
audienceRestrictionType.getAudience().get( 0 ).toString());
/*List<JAXBElement<?>> content = subject.getContent();
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -54,11 +54,11 @@
AuthnRequestType authnRequest = ( AuthnRequestType ) parser.parse(configStream);
assertNotNull( "AuthnRequestType is not null", authnRequest );
- assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint",
authnRequest.getAssertionConsumerServiceURL() );
- assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint",
authnRequest.getDestination() );
+ assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint",
authnRequest.getAssertionConsumerServiceURL().toString() );
+ assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint",
authnRequest.getDestination().toString() );
assertEquals( "a2sffdlgdhgfg32fdldsdghdsgdgfdglgx", authnRequest.getID()
);
assertEquals( XMLTimeUtil.parse( "2007-12-17T18:40:52.203Z" ),
authnRequest.getIssueInstant() );
- assertEquals( "urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect",
authnRequest.getProtocolBinding() );
+ assertEquals( "urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect",
authnRequest.getProtocolBinding().toString() );
assertEquals( "Test SAML2 SP", authnRequest.getProviderName() );
assertEquals( "2.0", authnRequest.getVersion() );
@@ -67,7 +67,7 @@
//NameID Policy
NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
- assertEquals( "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
nameIDPolicy.getFormat() );
+ assertEquals( "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
nameIDPolicy.getFormat().toString() );
assertEquals( Boolean.TRUE , nameIDPolicy.isAllowCreate() );
//Try out writing
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -30,14 +30,12 @@
import java.util.Iterator;
import java.util.List;
-import javax.xml.bind.JAXBElement;
-
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLResponseWriter;
-import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
@@ -49,8 +47,9 @@
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectConfirmationDataType;
import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectConfirmationType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectType;
-import org.picketlink.identity.federation.newmodel.saml.v2.protocol.*;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
import
org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType.RTChoiceType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
/**
* Validate the parsing of SAML2 Response
@@ -78,7 +77,7 @@
//Status
StatusType status = response.getStatus();
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getValue() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getValue().toString() );
List<RTChoiceType> assertionList = response.getAssertions();
assertEquals( 2, assertionList.size() );
@@ -149,7 +148,7 @@
//Status
StatusType status = response.getStatus();
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getValue() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getValue().toString() );
//Get the assertion
AssertionType assertion = (AssertionType)
response.getAssertions().get(0).getAssertion();
@@ -164,7 +163,7 @@
NameIDType subjectNameID = (NameIDType) subject.getSubType().getBaseID();
assertEquals( "anil", subjectNameID.getValue() );
- assertEquals( "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
subjectNameID.getFormat() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
subjectNameID.getFormat().toString() );
SubjectConfirmationType subjectConfirmation = subject.getConfirmation().get(0);
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -66,8 +66,8 @@
//Status
StatusType status = response.getStatus();
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Responder",
status.getStatusCode().getValue() );
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getStatusCode().getValue() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Responder",
status.getStatusCode().getValue().toString() );
+ assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getStatusCode().getValue().toString() );
//Let us do some writing - currently only visual inspection. We will do proper
validation later.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified:
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-response-assertion-subject.xml
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-response-assertion-subject.xml 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-response-assertion-subject.xml 2010-11-30
22:48:15 UTC (rev 575)
@@ -17,6 +17,8 @@
InResponseTo="ID_04ded476-d73c-48af-b3a9-232a52905ffb"
NotBefore="2010-11-04T00:19:16.842-05:00"
NotOnOrAfter="2010-11-04T00:19:16.842-05:00"
Recipient="http://localhost:8080/employee/"></saml:SubjectConfirmationData>
</saml:SubjectConfirmation>
+
+ </saml:Subject>
<saml:AttributeStatement>
<saml:Attribute Name="role" FriendlyName="role"
NameFormat="role">
@@ -31,6 +33,5 @@
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
- </saml:Subject>
</saml:Assertion>
</samlp:Response>
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AssertionType.java
===================================================================
---
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AssertionType.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AssertionType.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -23,8 +23,8 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.Set;
-import java.util.TreeSet;
import javax.xml.datatype.XMLGregorianCalendar;
@@ -70,7 +70,7 @@
private ConditionsType conditions;
- private Set<StatementAbstractType> statements = new
TreeSet<StatementAbstractType>();
+ private Set<StatementAbstractType> statements = new
LinkedHashSet<StatementAbstractType>();
public AssertionType(String iD, XMLGregorianCalendar issueInstant, String version)
{
Modified:
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AuthnContextType.java
===================================================================
---
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AuthnContextType.java 2010-11-30
22:16:55 UTC (rev 574)
+++
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AuthnContextType.java 2010-11-30
22:48:15 UTC (rev 575)
@@ -25,8 +25,8 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
-import java.util.TreeSet;
@@ -64,7 +64,7 @@
*/
public class AuthnContextType
{
- private Set<URI> authenticatingAuthority = new TreeSet<URI>();
+ private Set<URI> authenticatingAuthority = new LinkedHashSet<URI>();
private AuthnContextTypeSequence sequence;