Author: anil.saldhana(a)jboss.com
Date: 2010-11-30 19:48:57 -0500 (Tue, 30 Nov 2010)
New Revision: 577
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAML20TokenProvider.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAMLUtil.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/wstrust/PicketLinkSTSUnitTestCase.java
Log:
updates
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java 2010-12-01
00:33:28 UTC (rev 576)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java 2010-12-01
00:48:57 UTC (rev 577)
@@ -215,6 +215,8 @@
entropy.getAny().add(binarySecret);
}
responseToken.setEntropy(entropy);
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate(endElement, WSTrustConstants.ENTROPY );
}
else if (tag.equals(WSTrustConstants.USE_KEY))
{
@@ -272,6 +274,8 @@
requestedProofToken.setAny(computedKey);
}
responseToken.setRequestedProofToken(requestedProofToken);
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate(endElement,
WSTrustConstants.REQUESTED_PROOF_TOKEN );
}
else if (tag.equals(WSTrustConstants.REQUESTED_TOKEN))
{
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java 2010-12-01
00:33:28 UTC (rev 576)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java 2010-12-01
00:48:57 UTC (rev 577)
@@ -80,7 +80,8 @@
public static NameIDType createNameID(String format, String qualifier, String value)
{
NameIDType nameID = new NameIDType();
- nameID.setFormat( NetworkUtil.createURI( format ));
+ if( format != null )
+ nameID.setFormat( NetworkUtil.createURI( format ));
nameID.setNameQualifier(qualifier);
nameID.setValue(value);
return nameID;
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAML20TokenProvider.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAML20TokenProvider.java 2010-12-01
00:33:28 UTC (rev 576)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAML20TokenProvider.java 2010-12-01
00:48:57 UTC (rev 577)
@@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import org.apache.log4j.Logger;
@@ -43,7 +42,7 @@
import
org.picketlink.identity.federation.core.wstrust.plugins.FileBasedRevocationRegistry;
import
org.picketlink.identity.federation.core.wstrust.plugins.JPABasedRevocationRegistry;
import org.picketlink.identity.federation.core.wstrust.plugins.RevocationRegistry;
-import org.picketlink.identity.federation.core.wstrust.wrappers.Lifetime;
+import org.picketlink.identity.federation.core.wstrust.wrappers.Lifetime;
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.AudienceRestrictionType;
@@ -312,7 +311,7 @@
{
oldAssertion = SAMLUtil.fromElement(oldAssertionElement);
}
- catch (JAXBException je)
+ catch ( Exception je )
{
throw new WSTrustException("Error unmarshalling assertion", je);
}
@@ -392,7 +391,7 @@
{
assertion = SAMLUtil.fromElement(assertionElement);
}
- catch (JAXBException e)
+ catch ( Exception e )
{
throw new WSTrustException("Unmarshalling error:", e);
}
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAMLUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAMLUtil.java 2010-12-01
00:33:28 UTC (rev 576)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/plugins/saml/SAMLUtil.java 2010-12-01
00:48:57 UTC (rev 577)
@@ -24,13 +24,15 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
+import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLAssertionParser;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter;
-import org.picketlink.identity.federation.core.util.JAXBUtil;
import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
import org.w3c.dom.Document;
@@ -99,10 +101,19 @@
* the {@code Element} that contains the marshaled SAMLV2.0 assertion.
* @return a reference to the unmarshaled {@code AssertionType} instance.
* @throws JAXBException if an error occurs while unmarshalling the document.
+ * @throws ConfigurationException
+ * @throws ProcessingException
+ * @throws ParsingException
*/
- public static AssertionType fromElement(Element assertionElement) throws
JAXBException
+ public static AssertionType fromElement(Element assertionElement) throws
JAXBException, ProcessingException, ConfigurationException, ParsingException
{
- Unmarshaller unmarshaller =
JAXBUtil.getUnmarshaller("org.picketlink.identity.federation.saml.v2.assertion");
+ String assertionAsString = DocumentUtil.getDOMElementAsString(assertionElement);
+
+ SAMLAssertionParser assertionParser = new SAMLAssertionParser();
+ return (AssertionType) assertionParser.parse( StaxParserUtil.getXMLEventReader( new
ByteArrayInputStream( assertionAsString.getBytes() )));
+
+
+ /*Unmarshaller unmarshaller =
JAXBUtil.getUnmarshaller("org.picketlink.identity.federation.saml.v2.assertion");
Object object = unmarshaller.unmarshal(assertionElement);
if (object instanceof AssertionType)
return (AssertionType) object;
@@ -112,6 +123,6 @@
if (element.getDeclaredType().equals(AssertionType.class))
return (AssertionType) element.getValue();
}
- throw new IllegalArgumentException("Supplied document does not contain a
SAMLV2.0 Assertion");
+ throw new IllegalArgumentException("Supplied document does not contain a
SAMLV2.0 Assertion");*/
}
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/wstrust/PicketLinkSTSUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/wstrust/PicketLinkSTSUnitTestCase.java 2010-12-01
00:33:28 UTC (rev 576)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/wstrust/PicketLinkSTSUnitTestCase.java 2010-12-01
00:48:57 UTC (rev 577)
@@ -305,8 +305,9 @@
// invoke the token service.
Source responseMessage = this.tokenService.invoke(requestMessage);
+ InputStream is = DocumentUtil.getSourceAsStream(responseMessage);
BaseRequestSecurityTokenResponse baseResponse = (BaseRequestSecurityTokenResponse)
new WSTrustParser()
- .parse(DocumentUtil.getSourceAsStream(responseMessage));
+ .parse( is );
// validate the security token response.
this.validateSAMLAssertionResponse(baseResponse, "testcontext",
"jduke", SAMLUtil.SAML2_BEARER_URI);
}
@@ -1152,6 +1153,7 @@
// unmarshall the SAMLV2.0 assertion.
Element assertionElement = (Element) requestedToken.getAny();
+ System.out.println( DocumentUtil.getNodeAsString(assertionElement));
AssertionType assertion = SAMLUtil.fromElement(assertionElement);
// verify the contents of the unmarshalled assertion.
Show replies by date