Author: anil.saldhana(a)jboss.com
Date: 2010-11-30 16:48:59 -0500 (Tue, 30 Nov 2010)
New Revision: 573
Modified:
federation/trunk/picketlink-bindings-jboss/src/main/java/org/picketlink/identity/federation/bindings/jboss/auth/SAML20TokenRoleAttributeProvider.java
federation/trunk/picketlink-bindings-jboss/src/test/java/org/picketlink/test/identity/federation/bindings/jboss/auth/STSMappingProviderUnitTestCase.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
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/SAMLParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSloResponseParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.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/constants/JBossSAMLConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLBaseFactory.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/AssertionUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/StatementUtil.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/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AttributeType.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-bindings-jboss/src/main/java/org/picketlink/identity/federation/bindings/jboss/auth/SAML20TokenRoleAttributeProvider.java
===================================================================
---
federation/trunk/picketlink-bindings-jboss/src/main/java/org/picketlink/identity/federation/bindings/jboss/auth/SAML20TokenRoleAttributeProvider.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-bindings-jboss/src/main/java/org/picketlink/identity/federation/bindings/jboss/auth/SAML20TokenRoleAttributeProvider.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -84,8 +84,7 @@
else
{
AttributeStatementType attributeStatement = new AttributeStatementType();
- AttributeType rolesAttribute = new AttributeType();
- rolesAttribute.setName(tokenRoleAttributeName);
+ AttributeType rolesAttribute = new AttributeType( tokenRoleAttributeName );
attributeStatement.addAttribute( new ASTChoiceType(rolesAttribute) );
List<Object> roles = rolesAttribute.getAttributeValue();
Modified:
federation/trunk/picketlink-bindings-jboss/src/test/java/org/picketlink/test/identity/federation/bindings/jboss/auth/STSMappingProviderUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-bindings-jboss/src/test/java/org/picketlink/test/identity/federation/bindings/jboss/auth/STSMappingProviderUnitTestCase.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-bindings-jboss/src/test/java/org/picketlink/test/identity/federation/bindings/jboss/auth/STSMappingProviderUnitTestCase.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -78,9 +78,8 @@
AssertionType assertion = new AssertionType( "ID_SOME",
XMLTimeUtil.getIssueInstant(), JBossSAMLConstants.VERSION_2_0.get());
AttributeStatementType attributeStatementType = new AttributeStatementType();
assertion.addStatement( attributeStatementType );
- AttributeType attributeType = new AttributeType();
- attributeStatementType.addAttribute( new ASTChoiceType(attributeType));
- attributeType.setName(roleAttributeName);
+ AttributeType attributeType = new AttributeType( roleAttributeName );
+ attributeStatementType.addAttribute( new ASTChoiceType(attributeType));
attributeType.getAttributeValue().add(role1);
attributeType.getAttributeValue().add(role2);
Modified:
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -305,6 +305,8 @@
/*JAXBContext jaxb = JAXBUtil.getJAXBContext(EncryptedElementType.class);
Binder<Node> binder = jaxb.createBinder();
*/
+ if( encryptedElementType == null )
+ throw new IllegalArgumentException( "encryptedElementType is null ");
Document doc = DocumentUtil.createDocument();
Node importedNode = doc.importNode( encryptedElementType.getEncryptedElement(),
true );
doc.appendChild(importedNode);
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -28,10 +28,9 @@
import java.security.KeyPair;
import java.security.KeyPairGenerator;
-import javax.xml.bind.Binder;
-import javax.xml.bind.JAXBElement;
import javax.xml.crypto.dsig.SignatureMethod;
+import org.junit.Test;
import org.picketlink.identity.federation.api.saml.v2.request.SAML2Request;
import org.picketlink.identity.federation.api.saml.v2.response.SAML2Response;
import org.picketlink.identity.federation.api.saml.v2.sig.SAML2Signature;
@@ -41,12 +40,11 @@
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.SignatureUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
-import org.picketlink.identity.federation.core.util.XMLSignatureUtil;
+import org.picketlink.identity.federation.core.util.XMLSignatureUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnStatementType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.AuthnRequestType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
-import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -126,7 +124,6 @@
assertTrue(isValid);
}
- @SuppressWarnings("unchecked")
@Test
public void testSigningAnAssertionWithinResponse() throws Exception
{
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -22,6 +22,7 @@
package org.picketlink.test.identity.federation.api.util;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.io.StringWriter;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -79,22 +80,26 @@
Element docElement =
XMLEncryptionUtil.encryptElementInDocument(responseDoc,kp.getPublic(), sk,
128, assertionQName, true);
-
- EncryptedAssertionType eet =
sr.getEncryptedAssertion(DocumentUtil.getNodeAsStream(docElement));
+
+ // System.out.println( DocumentUtil.getNodeAsString(docElement));
+
+ InputStream is = DocumentUtil.getNodeAsStream( docElement );
+ EncryptedAssertionType eet = sr.getEncryptedAssertion( is );
rt.addAssertion( new RTChoiceType( eet ) );
- RTChoiceType choiceType = rt.getAssertions().get(0);
+ RTChoiceType choiceType = rt.getAssertions().get(1);
EncryptedAssertionType encryptedAssertionType =
choiceType.getEncryptedAssertion();
Document eetDoc = sr.convert( encryptedAssertionType );
Element decryptedDocumentElement =
XMLEncryptionUtil.decryptElementInDocument(eetDoc,kp.getPrivate());
+
+ //Let us use the encrypted doc element to decrypt it
- //Let us use the encrypted doc element to decrypt it
ResponseType newRT =
sr.getResponseType(DocumentUtil.getNodeAsStream(decryptedDocumentElement));
AssertionType assertion = (AssertionType)
newRT.getAssertions().get(0).getAssertion();
- assertEquals("http://identityurl", assertion.getIssuer().getValue());
+ assertEquals("testPrincipal", assertion.getIssuer().getValue());
}
@@ -119,6 +124,9 @@
StringWriter sw = new StringWriter();
sr.marshall(rt, sw);
+
+ System.out.println( sw.toString() );
+
//Create a brand new ResponseType
ResponseType received = sr.getResponseType(new
ByteArrayInputStream(sw.toString().getBytes("UTF-8")));
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
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLAssertionParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -28,6 +28,9 @@
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stax.StAXSource;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
@@ -35,8 +38,11 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+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.util.TransformerUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.*;
+import org.w3c.dom.Document;
/**
* Parse the saml assertion
@@ -52,7 +58,39 @@
*/
public Object parse(XMLEventReader xmlEventReader) throws ParsingException
{
- StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StartElement startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+ String startElementName = StaxParserUtil.getStartElementName(startElement);
+ if( startElementName.equals( JBossSAMLConstants.ENCRYPTED_ASSERTION.get() ))
+ {
+ Document resultDocument;
+ try
+ {
+ resultDocument = DocumentUtil.createDocument();
+ DOMResult domResult = new DOMResult( resultDocument );
+
+ //Let us parse <b><c><d> using transformer
+ StAXSource source = new StAXSource(xmlEventReader);
+
+ Transformer transformer =
TransformerUtil.getStaxSourceToDomResultTransformer();
+ transformer.transform( source, domResult );
+ }
+ catch ( Exception e)
+ {
+ throw new RuntimeException( e );
+ }
+
+ EncryptedAssertionType encryptedAssertion = new EncryptedAssertionType();
+ encryptedAssertion.setEncryptedElement( resultDocument.getDocumentElement() );
+ return encryptedAssertion;
+ }
+
+
+
+
+
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+
+ //Special case: Encrypted Assertion
StaxParserUtil.validate(startElement, ASSERTION );
AssertionType assertion = parseBaseAttributes( startElement );
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -85,8 +85,12 @@
SAMLResponseParser responseParser = new SAMLResponseParser();
return responseParser.parse( xmlEventReader );
}
- else
- throw new RuntimeException( "Unknown Tag:" + elementName );
+ else if( JBossSAMLURIConstants.ASSERTION_NSURI.get().equals(nsURI) )
+ {
+ SAMLAssertionParser assertionParser = new SAMLAssertionParser();
+ return assertionParser.parse( xmlEventReader );
+ }
+ else throw new RuntimeException( "Unknown Tag:" + elementName );
}
else
{
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -31,8 +31,10 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
-import org.picketlink.identity.federation.saml.v2.assertion.NameIDType;
-import org.picketlink.identity.federation.saml.v2.protocol.ResponseType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType.RTChoiceType;
/**
* Parse the SAML Response
@@ -76,7 +78,7 @@
else if( JBossSAMLConstants.ASSERTION.get().equals( elementName ))
{
SAMLAssertionParser assertionParser = new SAMLAssertionParser();
- response.getAssertionOrEncryptedAssertion().add(
assertionParser.parse(xmlEventReader));
+ response.addAssertion( new RTChoiceType( (AssertionType)
assertionParser.parse(xmlEventReader ) ));
}
else if( JBossSAMLConstants.STATUS.get().equals( elementName ))
{
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSloResponseParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSloResponseParser.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSloResponseParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -34,8 +34,8 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
-import org.picketlink.identity.federation.saml.v2.assertion.NameIDType;
-import org.picketlink.identity.federation.saml.v2.protocol.StatusResponseType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
/**
* Parse the SLO Response
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -32,9 +32,10 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
-import org.picketlink.identity.federation.saml.v2.protocol.StatusCodeType;
-import org.picketlink.identity.federation.saml.v2.protocol.StatusResponseType;
-import org.picketlink.identity.federation.saml.v2.protocol.StatusType;
+import org.picketlink.identity.federation.core.util.NetworkUtil;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusCodeType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
/**
* Base Class for all Response Type parsing for SAML2
@@ -114,7 +115,7 @@
Attribute valueAttr = startElement.getAttributeByName( new QName(
"Value" ));
if( valueAttr != null )
{
- statusCode.setValue( StaxParserUtil.getAttributeValue( valueAttr ));
+ statusCode.setValue( NetworkUtil.createURI(
StaxParserUtil.getAttributeValue( valueAttr ) ));
}
status.setStatusCode( statusCode );
@@ -127,7 +128,7 @@
Attribute subValueAttr = startElement.getAttributeByName( new QName(
"Value" ));
if( subValueAttr != null )
{
- subStatusCodeType.setValue( StaxParserUtil.getAttributeValue(
subValueAttr ));
+ subStatusCodeType.setValue( NetworkUtil.createURI(
StaxParserUtil.getAttributeValue( subValueAttr )));
}
statusCode.setStatusCode( subStatusCodeType );
}
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
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -69,7 +69,10 @@
{
EndElement endElement = (EndElement) xmlEvent;
if( StaxParserUtil.matches(endElement , JBossSAMLConstants.SUBJECT.get() ))
- break;
+ {
+ endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ break;
+ }
else
throw new RuntimeException( "Unknown End Element:" +
StaxParserUtil.getEndElementName( endElement ) );
}
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
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -85,27 +85,27 @@
* @throws ParsingException
*/
public static AttributeType parseAttribute( XMLEventReader xmlEventReader ) throws
ParsingException
- {
- AttributeType attributeType = new AttributeType();
-
+ {
StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
StaxParserUtil.validate( startElement, JBossSAMLConstants.ATTRIBUTE.get() );
-
+ AttributeType attributeType = null;
+
+ Attribute name = startElement.getAttributeByName( new QName(
JBossSAMLConstants.NAME.get() ));
+ if( name == null )
+ throw new RuntimeException( "Required attribute Name in Attribute" );
+ attributeType = new AttributeType( StaxParserUtil.getAttributeValue( name ));
+
//Look for X500 Encoding
QName x500EncodingName = new QName( JBossSAMLURIConstants.X500_NSURI.get(),
JBossSAMLConstants.ENCODING.get() );
Attribute x500EncodingAttr = startElement.getAttributeByName( x500EncodingName );
if( x500EncodingAttr != null )
- {
+ {
attributeType.getOtherAttributes().put( x500EncodingAttr.getName(),
StaxParserUtil.getAttributeValue( x500EncodingAttr ));
}
-
- Attribute name = startElement.getAttributeByName( new QName(
JBossSAMLConstants.NAME.get() ));
- if( name == null )
- throw new RuntimeException( "Required attribute Name in Attribute" );
- attributeType.setName( StaxParserUtil.getAttributeValue( name ));
-
+
+
Attribute friendlyName = startElement.getAttributeByName( new QName(
JBossSAMLConstants.FRIENDLY_NAME.get() ));
if( friendlyName != null )
attributeType.setFriendlyName( StaxParserUtil.getAttributeValue( friendlyName
));
@@ -127,7 +127,7 @@
if( JBossSAMLConstants.ATTRIBUTE_VALUE.get().equals( tag ) )
{
Object attributeValue = parseAttributeValue(xmlEventReader);
- attributeType.getAttributeValue().add( attributeValue );
+ attributeType.addAttributeValue( attributeValue );
}
else throw new RuntimeException( "Unknown tag:" + tag );
}
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -49,6 +49,7 @@
CONSENT( "Consent" ),
DESTINATION( "Destination" ),
ENCODING( "Encoding" ),
+ ENCRYPTED_ASSERTION( "EncryptedAssertion" ),
FORMAT( "Format" ),
FRIENDLY_NAME( "FriendlyName" ),
ID( "ID" ),
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLBaseFactory.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLBaseFactory.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLBaseFactory.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -55,9 +55,8 @@
*/
public static AttributeType createAttributeForRole(String roleName)
{
- AttributeType att = new AttributeType();
- att.setFriendlyName("role");
- att.setName("role");
+ AttributeType att = new AttributeType( "role" );
+ att.setFriendlyName("role");
att.setNameFormat(JBossSAMLURIConstants.ATTRIBUTE_FORMAT_BASIC.get());
//rolename
@@ -74,7 +73,7 @@
public static AttributeStatementType createAttributeStatement(String attributeValue)
{
AttributeStatementType attribStatement = new AttributeStatementType();
- AttributeType att = new AttributeType();
+ AttributeType att = new AttributeType( attributeValue );
att.addAttributeValue(attributeValue);
attribStatement.addAttribute( new ASTChoiceType( att ));
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/AssertionUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/AssertionUtil.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/AssertionUtil.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -74,8 +74,7 @@
public static AttributeType createAttribute(String name, String nameFormat,
Object... attributeValues)
{
- AttributeType att = new AttributeType();
- att.setName(name);
+ AttributeType att = new AttributeType( name );
att.setNameFormat(nameFormat);
if(attributeValues != null && attributeValues.length > 0)
{
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/StatementUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/StatementUtil.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/StatementUtil.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -74,7 +74,7 @@
Collection<?> roles = (Collection<?>) value;
for (Object role : roles)
{
- AttributeType roleAttr = new AttributeType();
+ AttributeType roleAttr = new AttributeType( "Role" );
roleAttr.addAttributeValue(role);
attrStatement.addAttribute( new ASTChoiceType( roleAttr ));
}
@@ -83,29 +83,33 @@
else
{
- AttributeType att = getX500Attribute();
+ AttributeType att;
Object value = attributes.get(key);
if (AttributeConstants.EMAIL_ADDRESS.equals(key))
{
-
att.setFriendlyName(X500SAMLProfileConstants.EMAIL_ADDRESS.getFriendlyName());
- att.setName(X500SAMLProfileConstants.EMAIL_ADDRESS.get());
+ att = getX500Attribute( X500SAMLProfileConstants.EMAIL_ADDRESS.get() );
+
att.setFriendlyName(X500SAMLProfileConstants.EMAIL_ADDRESS.getFriendlyName());
}
else if (AttributeConstants.EMPLOYEE_NUMBER.equals(key))
{
-
att.setFriendlyName(X500SAMLProfileConstants.EMPLOYEE_NUMBER.getFriendlyName());
- att.setName(X500SAMLProfileConstants.EMPLOYEE_NUMBER.get());
+ att = getX500Attribute( X500SAMLProfileConstants.EMPLOYEE_NUMBER.get() );
+
att.setFriendlyName(X500SAMLProfileConstants.EMPLOYEE_NUMBER.getFriendlyName());
}
else if (AttributeConstants.GIVEN_NAME.equals(key))
{
-
att.setFriendlyName(X500SAMLProfileConstants.GIVENNAME.getFriendlyName());
- att.setName(X500SAMLProfileConstants.GIVENNAME.get());
+ att = getX500Attribute( X500SAMLProfileConstants.GIVENNAME.get() );
+ att.setFriendlyName(X500SAMLProfileConstants.GIVENNAME.getFriendlyName());
}
else if (AttributeConstants.TELEPHONE.equals(key))
{
+ att = getX500Attribute( X500SAMLProfileConstants.TELEPHONE.get() );
att.setFriendlyName(X500SAMLProfileConstants.TELEPHONE.getFriendlyName());
att.setName(X500SAMLProfileConstants.TELEPHONE.get());
}
+ else
+ throw new RuntimeException( "Unknown:" + key );
+
att.addAttributeValue( value );
attrStatement.addAttribute( new ASTChoiceType( att ));
}
@@ -123,16 +127,16 @@
AttributeStatementType attrStatement = new AttributeStatementType();
for (String role : roles)
{
- AttributeType attr = new AttributeType();
+ AttributeType attr = new AttributeType( "Role" );
attr.addAttributeValue( role );
attrStatement.addAttribute( new ASTChoiceType( attr ));
}
return attrStatement;
}
- private static AttributeType getX500Attribute()
+ private static AttributeType getX500Attribute( String name )
{
- AttributeType att = new AttributeType();
+ AttributeType att = new AttributeType( name );
att.getOtherAttributes().put(X500_QNAME, "LDAP");
att.setNameFormat(JBossSAMLURIConstants.ATTRIBUTE_FORMAT_URI.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
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -252,7 +252,11 @@
{
StaxUtil.writeStartElement( writer, ASSERTION_PREFIX,
JBossSAMLConstants.ATTRIBUTE.get() , ASSERTION_NSURI.get() );
- StaxUtil.writeAttribute( writer, JBossSAMLConstants.NAME.get(),
attributeType.getName() );
+ String attributeName = attributeType.getName();
+ if( attributeName != null )
+ {
+ StaxUtil.writeAttribute( writer, JBossSAMLConstants.NAME.get(), attributeName
);
+ }
String friendlyName = attributeType.getFriendlyName();
if( StringUtil.isNotNull( friendlyName ))
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -30,11 +30,14 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamWriter;
+import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
+import
org.picketlink.identity.federation.newmodel.saml.v2.assertion.EncryptedAssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
import
org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType.RTChoiceType;
@@ -42,6 +45,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusDetailType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
+import org.w3c.dom.Element;
/**
* Write a SAML Response to stream
@@ -85,10 +89,24 @@
for( RTChoiceType choiceType: choiceTypes )
{
AssertionType assertion = choiceType.getAssertion();
- if( assertion instanceof AssertionType )
+ if( assertion != null )
{
assertionWriter.write( (AssertionType) assertion );
}
+
+ EncryptedAssertionType encryptedAssertion =
choiceType.getEncryptedAssertion();
+ if( encryptedAssertion != null )
+ {
+ Element encryptedElement = encryptedAssertion.getEncryptedElement();
+ try
+ {
+ StaxUtil.writeCharacters(writer,
DocumentUtil.getNodeAsString(encryptedElement));
+ }
+ catch (ConfigurationException e)
+ {
+ throw new ProcessingException( e );
+ }
+ }
}
}
StaxUtil.writeEndElement( writer);
Modified:
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AttributeType.java
===================================================================
---
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AttributeType.java 2010-11-30
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AttributeType.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -57,6 +57,11 @@
protected String nameFormat;
protected String friendlyName;
private Map<QName, String> otherAttributes = new HashMap<QName,
String>();
+
+ public AttributeType( String name )
+ {
+ this.name = name;
+ }
public void addAttributeValue( Object value )
{
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
16:56:07 UTC (rev 572)
+++
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/AuthnContextType.java 2010-11-30
21:48:59 UTC (rev 573)
@@ -24,6 +24,7 @@
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
@@ -67,7 +68,7 @@
private AuthnContextTypeSequence sequence;
- private Set<URIType> URITypes;
+ private Set<URIType> URITypes = new HashSet<URIType>();
public void addAuthenticatingAuthority( URI aa )