Picketlink SVN: r490 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/wstrust and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 18:26:48 -0400 (Mon, 18 Oct 2010)
New Revision: 490
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
Log:
PLFED-109: parse the symmetric key
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 22:10:21 UTC (rev 489)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 22:26:48 UTC (rev 490)
@@ -43,7 +43,9 @@
import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
+import org.picketlink.identity.federation.ws.trust.BinarySecretType;
import org.picketlink.identity.federation.ws.trust.CancelTargetType;
+import org.picketlink.identity.federation.ws.trust.EntropyType;
import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
import org.picketlink.identity.federation.ws.trust.UseKeyType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
@@ -151,7 +153,35 @@
{
throw new ParsingException( e );
}
- }
+ }
+ else if( tag.equals( WSTrustConstants.KEY_SIZE ))
+ {
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ String keySize = StaxParserUtil.getElementText(xmlEventReader);
+ try
+ {
+ requestToken.setKeySize(Long.parseLong( keySize ));
+ }
+ catch( NumberFormatException e )
+ {
+ throw new ParsingException( e );
+ }
+ }
+ else if( tag.equals( WSTrustConstants.ENTROPY ))
+ {
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ EntropyType entropy = new EntropyType();
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ if( StaxParserUtil.matches(subEvent, WSTrustConstants.BINARY_SECRET ))
+ {
+ BinarySecretType binarySecret = new BinarySecretType();
+ Attribute typeAttribute = subEvent.getAttributeByName( new QName( "", "Type" ));
+ binarySecret.setType( StaxParserUtil.getAttributeValue( typeAttribute ));
+ binarySecret.setValue( StaxParserUtil.getElementText(xmlEventReader).getBytes() );
+ entropy.getAny().add( binarySecret );
+ }
+ requestToken.setEntropy(entropy);
+ }
else if( tag.equals( WSTrustConstants.USE_KEY ))
{
subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-18 22:10:21 UTC (rev 489)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-18 22:26:48 UTC (rev 490)
@@ -82,7 +82,10 @@
public static final String RSTR_STATUS_TOKEN_TYPE = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Status";
//Element Names
+ public static final String BINARY_SECRET = "BinarySecret";
+ public static final String ENTROPY = "Entropy";
public static final String On_BEHALF_OF = "OnBehalfOf";
+ public static final String KEY_SIZE = "KeySize";
public static final String KEY_TYPE = "KeyType";
public static final String RST = "RequestSecurityToken";
public static final String RST_COLLECTION = "RequestSecurityTokenCollection";
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2010-10-18 22:10:21 UTC (rev 489)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2010-10-18 22:26:48 UTC (rev 490)
@@ -38,7 +38,7 @@
import org.w3c.dom.Element;
/**
- * Validate parsing of RST with Use Key set to a X509 certificate
+ * Validate parsing of RST with Use Key set to a RSA Public Key
* @author Anil.Saldhana(a)redhat.com
* @since Oct 18, 2010
*/
14 years, 2 months
Picketlink SVN: r489 - in federation/trunk/picketlink-fed-core/src: test/java/org/picketlink/test/identity/federation/core/parser/wst and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 18:10:21 -0400 (Mon, 18 Oct 2010)
New Revision: 489
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
Log:
PLFED-109: parse the rsa pub key as part of RST use key
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 21:47:33 UTC (rev 488)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 22:10:21 UTC (rev 489)
@@ -57,6 +57,7 @@
public class WSTRequestSecurityTokenParser implements ParserNamespaceSupport
{
public static final String X509CERTIFICATE = "X509Certificate";
+ public static final String KEYVALUE = "KeyValue";
/**
* @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
@@ -161,12 +162,21 @@
* There has to be a better way of parsing a sub section into a DOM element
*/
subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
- StaxParserUtil.validate( subEvent, X509CERTIFICATE ) ;
-
- Element domElement = getX509CertificateAsDomElement( subEvent, xmlEventReader );
+ if( StaxParserUtil.matches(subEvent, X509CERTIFICATE ))
+ {
+ Element domElement = getX509CertificateAsDomElement( subEvent, xmlEventReader );
- useKeyType.setAny( domElement );
- requestToken.setUseKey( useKeyType );
+ useKeyType.setAny( domElement );
+ requestToken.setUseKey( useKeyType );
+ }
+ else if( StaxParserUtil.matches(subEvent, KEYVALUE ))
+ {
+ Element domElement = getKeyValueAsDomElement( subEvent, xmlEventReader );
+
+ useKeyType.setAny( domElement );
+ requestToken.setUseKey( useKeyType );
+ }
+ else throw new RuntimeException( "unsupported " + StaxParserUtil.getStartElementName( subEvent ));
}
else
{
@@ -255,4 +265,86 @@
return domElement;
}
+
+
+ private Element getKeyValueAsDomElement( StartElement subEvent, XMLEventReader xmlEventReader ) throws ParsingException
+ {
+ StringBuilder builder = new StringBuilder();
+
+ QName subEventName = subEvent.getName();
+ String prefix = subEventName.getPrefix();
+ String localPart = subEventName.getLocalPart();
+
+ //ds:KeyValue
+ builder.append( "<" ).append( prefix ).append( ":").append( localPart );
+
+ @SuppressWarnings("unchecked")
+ Iterator<Attribute> iter = subEvent.getAttributes();
+
+ while( iter != null && iter.hasNext() )
+ {
+ Attribute attr = iter.next();
+ QName attrName = attr.getName();
+ if( attrName.getNamespaceURI().equals( WSTrustConstants.DSIG_NS ) )
+ {
+ builder.append( " ").append( prefix ).append( ":" ).append( attrName.getLocalPart() );
+ builder.append( "=" ).append( StaxParserUtil.getAttributeValue( attr ));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ Iterator<Namespace> namespaces = subEvent.getNamespaces();
+ while( namespaces != null && namespaces.hasNext() )
+ {
+ Namespace namespace = namespaces.next();
+ builder.append( " ").append( namespace.toString() );
+ }
+ builder.append( ">" );
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate( subEvent, "RSAKeyValue" );
+ builder.append( "<") .append( prefix) .append( ":" ).append( "RSAKeyValue>" );
+
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate( subEvent, "Modulus" );
+ builder.append( "<") .append( prefix) .append( ":" ).append( "Modulus>" );
+
+ builder.append( StaxParserUtil.getElementText(xmlEventReader) ); //We are at the end of tag
+
+ builder.append( "</" ).append( prefix ).append( ":" ).append( "Modulus" ).append( ">" );
+
+
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate( subEvent, "Exponent" );
+
+ builder.append( "<") .append( prefix) .append( ":" ).append( "Exponent>" );
+
+ builder.append( StaxParserUtil.getElementText(xmlEventReader) ); //We are at the end of tag
+
+ builder.append( "</" ).append( prefix ).append( ":" ).append( "Exponent" ).append( ">" );
+
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate(endElement, "RSAKeyValue" );
+ builder.append( "</" ).append( prefix ).append( ":" ).append( "RSAKeyValue" ).append( ">" );
+
+ endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate(endElement, KEYVALUE );
+ builder.append( "</" ).append( prefix ).append( ":" ).append( KEYVALUE ).append( ">" );
+
+
+ Element domElement = null;
+ try
+ {
+ domElement = DocumentUtil.getDocument( builder.toString() ).getDocumentElement() ;
+ }
+ catch (ConfigurationException e)
+ {
+ throw new ParsingException( e );
+ }
+ catch (ProcessingException e)
+ {
+ throw new ParsingException( e );
+ }
+
+ return domElement;
+ }
}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2010-10-18 22:10:21 UTC (rev 489)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.identity.federation.core.parser.wst;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBElement;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTRequestSecurityTokenParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
+import org.picketlink.identity.federation.ws.trust.UseKeyType;
+import org.w3c.dom.Element;
+
+/**
+ * Validate parsing of RST with Use Key set to a X509 certificate
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 18, 2010
+ */
+public class WSTrustIssuePublicKeyTestCase
+{
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testPublicKey() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-issue-public-key.xml" );
+
+ WSTrustParser parser = new WSTrustParser();
+ RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse( configStream );
+
+ assertEquals( "testcontext", requestToken.getContext() );
+ assertEquals( WSTrustConstants.ISSUE_REQUEST , requestToken.getRequestType().toASCIIString() );
+
+ AppliesTo appliesTo = requestToken.getAppliesTo();
+ JAXBElement<EndpointReferenceType> jaxb = (JAXBElement<EndpointReferenceType>) appliesTo.getAny().get(0);
+ EndpointReferenceType endpoint = jaxb.getValue();
+ assertEquals( "http://services.testcorp.org/provider2", endpoint.getAddress().getValue() );
+
+
+ assertEquals( "http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey", requestToken.getKeyType().toASCIIString() );
+
+ UseKeyType useKeyType = requestToken.getUseKey();
+ Element certEl = (Element) useKeyType.getAny();
+
+ assertEquals( "ds:" + WSTRequestSecurityTokenParser.KEYVALUE, certEl.getTagName() );
+ }
+}
\ No newline at end of file
14 years, 2 months
Picketlink SVN: r488 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 17:47:33 -0400 (Mon, 18 Oct 2010)
New Revision: 488
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
Log:
PLFED-109: parse the X509 cert as part of RST use key
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2010-10-18 21:46:06 UTC (rev 487)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2010-10-18 21:47:33 UTC (rev 488)
@@ -25,11 +25,15 @@
import java.io.InputStream;
+import javax.xml.bind.JAXBElement;
+
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.wst.WSTRequestSecurityTokenParser;
import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.UseKeyType;
import org.w3c.dom.Element;
@@ -41,6 +45,7 @@
public class WSTrustIssuePublicCertificateTestCase
{
+ @SuppressWarnings("unchecked")
@Test
public void testPublicCert() throws Exception
{
@@ -53,6 +58,14 @@
assertEquals( "testcontext", requestToken.getContext() );
assertEquals( WSTrustConstants.ISSUE_REQUEST , requestToken.getRequestType().toASCIIString() );
+ AppliesTo appliesTo = requestToken.getAppliesTo();
+ JAXBElement<EndpointReferenceType> jaxb = (JAXBElement<EndpointReferenceType>) appliesTo.getAny().get(0);
+ EndpointReferenceType endpoint = jaxb.getValue();
+ assertEquals( "http://services.testcorp.org/provider2", endpoint.getAddress().getValue() );
+
+
+ assertEquals( "http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey", requestToken.getKeyType().toASCIIString() );
+
UseKeyType useKeyType = requestToken.getUseKey();
Element certEl = (Element) useKeyType.getAny();
14 years, 2 months
Picketlink SVN: r487 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/wstrust and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 17:46:06 -0400 (Mon, 18 Oct 2010)
New Revision: 487
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
Log:
PLFED-109: parse the X509 cert as part of RST use key
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 21:45:30 UTC (rev 486)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 21:46:06 UTC (rev 487)
@@ -23,24 +23,31 @@
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
+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.ParserController;
import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
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.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.CancelTargetType;
import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
+import org.picketlink.identity.federation.ws.trust.UseKeyType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
+import org.w3c.dom.Element;
/**
* Parse the WS-Trust RequestSecurityToken
@@ -49,6 +56,8 @@
*/
public class WSTRequestSecurityTokenParser implements ParserNamespaceSupport
{
+ public static final String X509CERTIFICATE = "X509Certificate";
+
/**
* @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
*/
@@ -108,7 +117,7 @@
EndElement cancelTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate( cancelTargetEndElement, WSTrustConstants.CANCEL_TARGET ) ;
}
- else if( tag.equals( WSTrustConstants.VALIDATE_TARGET ))
+ else if( tag.equals( WSTrustConstants.VALIDATE_TARGET ))
{
subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
@@ -118,7 +127,7 @@
EndElement validateTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate( validateTargetEndElement, WSTrustConstants.VALIDATE_TARGET ) ;
}
- else if( tag.equals( WSTrustConstants.On_BEHALF_OF ))
+ else if( tag.equals( WSTrustConstants.On_BEHALF_OF ))
{
subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
@@ -128,6 +137,37 @@
EndElement onBehalfOfEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate( onBehalfOfEndElement, WSTrustConstants.On_BEHALF_OF ) ;
}
+ else if( tag.equals( WSTrustConstants.KEY_TYPE ))
+ {
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ String keyType = StaxParserUtil.getElementText(xmlEventReader);
+ try
+ {
+ URI keyTypeURI = new URI( keyType );
+ requestToken.setKeyType( keyTypeURI );
+ }
+ catch( URISyntaxException e )
+ {
+ throw new ParsingException( e );
+ }
+ }
+ else if( tag.equals( WSTrustConstants.USE_KEY ))
+ {
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ UseKeyType useKeyType = new UseKeyType();
+ StaxParserUtil.validate( subEvent, WSTrustConstants.USE_KEY ) ;
+
+ /**
+ * There has to be a better way of parsing a sub section into a DOM element
+ */
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate( subEvent, X509CERTIFICATE ) ;
+
+ Element domElement = getX509CertificateAsDomElement( subEvent, xmlEventReader );
+
+ useKeyType.setAny( domElement );
+ requestToken.setUseKey( useKeyType );
+ }
else
{
QName qname = subEvent.getName();
@@ -162,4 +202,57 @@
return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
&& WSTrustConstants.RST.equals( localPart );
}
+
+
+ private Element getX509CertificateAsDomElement( StartElement subEvent, XMLEventReader xmlEventReader ) throws ParsingException
+ {
+ StringBuilder builder = new StringBuilder();
+
+ QName subEventName = subEvent.getName();
+ String prefix = subEventName.getPrefix();
+ String localPart = subEventName.getLocalPart();
+
+ builder.append( "<" ).append( prefix ).append( ":").append( localPart );
+
+ @SuppressWarnings("unchecked")
+ Iterator<Attribute> iter = subEvent.getAttributes();
+
+ while( iter != null && iter.hasNext() )
+ {
+ Attribute attr = iter.next();
+ QName attrName = attr.getName();
+ if( attrName.getNamespaceURI().equals( WSTrustConstants.DSIG_NS ) )
+ {
+ builder.append( " ").append( prefix ).append( ":" ).append( attrName.getLocalPart() );
+ builder.append( "=" ).append( StaxParserUtil.getAttributeValue( attr ));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ Iterator<Namespace> namespaces = subEvent.getNamespaces();
+ while( namespaces != null && namespaces.hasNext() )
+ {
+ Namespace namespace = namespaces.next();
+ builder.append( " ").append( namespace.toString() );
+ }
+ builder.append( ">" );
+ builder.append( StaxParserUtil.getElementText(xmlEventReader) ); //We are at the end of tag
+
+ builder.append( "</" ).append( prefix ).append( ":" ).append( localPart ).append( ">" );
+ Element domElement = null;
+ try
+ {
+ domElement = DocumentUtil.getDocument( builder.toString() ).getDocumentElement() ;
+ }
+ catch (ConfigurationException e)
+ {
+ throw new ParsingException( e );
+ }
+ catch (ProcessingException e)
+ {
+ throw new ParsingException( e );
+ }
+
+ return domElement;
+ }
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-18 21:45:30 UTC (rev 486)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-18 21:46:06 UTC (rev 487)
@@ -83,12 +83,14 @@
//Element Names
public static final String On_BEHALF_OF = "OnBehalfOf";
+ public static final String KEY_TYPE = "KeyType";
public static final String RST = "RequestSecurityToken";
public static final String RST_COLLECTION = "RequestSecurityTokenCollection";
public static final String REQUEST_TYPE = "RequestType";
public static final String TOKEN_TYPE = "TokenType";
public static final String CANCEL_TARGET = "CancelTarget";
public static final String VALIDATE_TARGET = "ValidateTarget";
+ public static final String USE_KEY = "UseKey";
//Attribute Names
public static final String RST_CONTEXT = "Context";
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2010-10-18 21:46:06 UTC (rev 487)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.identity.federation.core.parser.wst;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTRequestSecurityTokenParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.trust.UseKeyType;
+import org.w3c.dom.Element;
+
+/**
+ * Validate parsing of RST with Use Key set to a X509 certificate
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 18, 2010
+ */
+public class WSTrustIssuePublicCertificateTestCase
+{
+
+ @Test
+ public void testPublicCert() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-issue-public-certificate.xml" );
+
+ WSTrustParser parser = new WSTrustParser();
+ RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse( configStream );
+
+ assertEquals( "testcontext", requestToken.getContext() );
+ assertEquals( WSTrustConstants.ISSUE_REQUEST , requestToken.getRequestType().toASCIIString() );
+
+ UseKeyType useKeyType = requestToken.getUseKey();
+ Element certEl = (Element) useKeyType.getAny();
+
+ assertEquals( "ds:" + WSTRequestSecurityTokenParser.X509CERTIFICATE, certEl.getTagName() );
+ }
+}
\ No newline at end of file
14 years, 2 months
Picketlink SVN: r486 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 17:45:30 -0400 (Mon, 18 Oct 2010)
New Revision: 486
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java
Log:
PLFED-109: ensure correct order of parsers registered
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java 2010-10-18 17:10:59 UTC (rev 485)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java 2010-10-18 21:45:30 UTC (rev 486)
@@ -29,6 +29,12 @@
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.parsers.wsa.WSAddressingParser;
import org.picketlink.identity.federation.core.parsers.wsp.WSPolicyParser;
+import org.picketlink.identity.federation.core.parsers.wsse.WSSecurityParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTCancelTargetParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTRequestSecurityTokenCollectionParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTRequestSecurityTokenParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTValidateTargetParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustOnBehalfOfParser;
import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
/**
@@ -49,10 +55,20 @@
static
{
+
add( new SAMLParser() );
add( new WSTrustParser() );
+
+ add( new WSSecurityParser() );
add( new WSPolicyParser() );
add( new WSAddressingParser() );
+
+
+ add( new WSTrustOnBehalfOfParser() );
+ add( new WSTValidateTargetParser() );
+ add( new WSTCancelTargetParser() );
+ add( new WSTRequestSecurityTokenParser() );
+ add( new WSTRequestSecurityTokenCollectionParser() );
};
/**
@@ -73,7 +89,7 @@
System.getSecurityManager().checkPermission( PARSER_PERM );
}
- parsers.add( parser );
+ parsers.add( 0, parser );
}
/**
14 years, 2 months
Picketlink SVN: r485 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/parsers/wsse and 3 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-18 13:10:59 -0400 (Mon, 18 Oct 2010)
New Revision: 485
Added:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsse/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsse/WSSecurityParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
Log:
PLFED-109: PLFED-110:
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsse/WSSecurityParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsse/WSSecurityParser.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsse/WSSecurityParser.java 2010-10-18 17:10:59 UTC (rev 485)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.parsers.wsse;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.AbstractParser;
+import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.ws.wss.secext.AttributedString;
+import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
+
+/**
+ * <p>
+ * Parses the WS-Security elements that can be part
+ * of the WS-T RST
+ * </p>
+ *
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WSSecurityParser extends AbstractParser
+{
+ public static final String USERNAME_TOKEN = "UsernameToken";
+
+ /**
+ * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
+ */
+ public Object parse(XMLEventReader xmlEventReader) throws ParsingException
+ {
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek( xmlEventReader );
+
+ if( xmlEvent instanceof StartElement )
+ {
+ StartElement startElement = (StartElement) xmlEvent;
+
+ String elementName = StaxParserUtil.getStartElementName( startElement );
+ if( elementName.equalsIgnoreCase( USERNAME_TOKEN ))
+ {
+ //Get the AppliesTo element
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+
+ UsernameTokenType userNameToken = new UsernameTokenType();
+
+ //Get the Id attribute
+ QName idQName = new QName( WSTrustConstants.WSU_NS, "Id" );
+ Attribute idAttribute = startElement.getAttributeByName( idQName );
+
+ if( idAttribute == null )
+ throw new RuntimeException( "missing wsu:Id attribute" );
+
+ userNameToken.setId( StaxParserUtil.getAttributeValue( idAttribute ));
+
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ String userName = StaxParserUtil.getElementText(xmlEventReader);
+
+ AttributedString attributedString = new AttributedString();
+ attributedString.setValue(userName);
+
+ userNameToken.setUsername( attributedString );
+
+ //Get the end element
+ EndElement onBehalfOfEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( onBehalfOfEndElement, USERNAME_TOKEN ) ;
+
+ return userNameToken;
+ }
+ }
+ else
+ {
+ StaxParserUtil.getNextEvent(xmlEventReader);
+ }
+ }
+ throw new RuntimeException( "WSSecurity Parsing has failed" );
+ }
+
+ /**
+ * @see {@link ParserNamespaceSupport#supports(QName)}
+ */
+ public boolean supports(QName qname)
+ {
+ String nsURI = qname.getNamespaceURI();
+
+ return WSTrustConstants.WSSE_NS.equals( nsURI );
+ }
+}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-15 17:13:07 UTC (rev 484)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-18 17:10:59 UTC (rev 485)
@@ -39,6 +39,7 @@
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.CancelTargetType;
+import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
/**
@@ -117,6 +118,16 @@
EndElement validateTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate( validateTargetEndElement, WSTrustConstants.VALIDATE_TARGET ) ;
}
+ else if( tag.equals( WSTrustConstants.On_BEHALF_OF ))
+ {
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+
+ WSTrustOnBehalfOfParser wstOnBehalfOfParser = new WSTrustOnBehalfOfParser();
+ OnBehalfOfType onBehalfOf = (OnBehalfOfType) wstOnBehalfOfParser.parse(xmlEventReader);
+ requestToken.setOnBehalfOf(onBehalfOf);
+ EndElement onBehalfOfEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( onBehalfOfEndElement, WSTrustConstants.On_BEHALF_OF ) ;
+ }
else
{
QName qname = subEvent.getName();
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java 2010-10-18 17:10:59 UTC (rev 485)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.parsers.wst;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.StartElement;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
+import org.picketlink.identity.federation.core.parsers.wsse.WSSecurityParser;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
+import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
+
+/**
+ * Parser to parse the OnBehalfOf tag
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 18, 2010
+ */
+public class WSTrustOnBehalfOfParser implements ParserNamespaceSupport
+{
+ /**
+ * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
+ */
+ public Object parse(XMLEventReader xmlEventReader) throws ParsingException
+ {
+ OnBehalfOfType onBehalfType = new OnBehalfOfType();
+ StartElement startElement = StaxParserUtil.peekNextStartElement( xmlEventReader );
+ String tag = StaxParserUtil.getStartElementName( startElement );
+
+ if( tag.equals( WSSecurityParser.USERNAME_TOKEN ) )
+ {
+ WSSecurityParser wsseParser = new WSSecurityParser();
+
+ UsernameTokenType userNameToken = (UsernameTokenType) wsseParser.parse( xmlEventReader );
+ onBehalfType.setAny( userNameToken );
+ }
+
+ return onBehalfType;
+ }
+
+
+ /**
+ * @see {@link ParserNamespaceSupport#supports(QName)}
+ */
+ public boolean supports(QName qname)
+ {
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
+ && WSTrustConstants.On_BEHALF_OF.equals( localPart );
+ }
+}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-15 17:13:07 UTC (rev 484)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-18 17:10:59 UTC (rev 485)
@@ -82,6 +82,7 @@
public static final String RSTR_STATUS_TOKEN_TYPE = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Status";
//Element Names
+ public static final String On_BEHALF_OF = "OnBehalfOf";
public static final String RST = "RequestSecurityToken";
public static final String RST_COLLECTION = "RequestSecurityTokenCollection";
public static final String REQUEST_TYPE = "RequestType";
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java 2010-10-18 17:10:59 UTC (rev 485)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.identity.federation.core.parser.wst;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
+import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
+
+/**
+ * Validate the OnBehalfOf parsing
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 18, 2010
+ */
+public class WSTrustOnBehalfOfTestCase
+{
+ @Test
+ public void testOnBehalfOfParsing() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-issue-onbehalfof.xml" );
+
+ WSTrustParser parser = new WSTrustParser();
+ RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse( configStream );
+
+ assertEquals( "testcontext", requestToken.getContext() );
+ assertEquals( WSTrustConstants.ISSUE_REQUEST , requestToken.getRequestType().toASCIIString() );
+
+ OnBehalfOfType onBehalfOf = requestToken.getOnBehalfOf();
+ UsernameTokenType userNameToken = (UsernameTokenType) onBehalfOf.getAny();
+ assertEquals( "id", userNameToken.getId() );
+ assertEquals( "anotherduke", userNameToken.getUsername().getValue() );
+ }
+}
\ No newline at end of file
14 years, 2 months
Picketlink SVN: r484 - trust/trunk/jbossws-native.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 13:13:07 -0400 (Fri, 15 Oct 2010)
New Revision: 484
Modified:
trust/trunk/jbossws-native/pom.xml
Log:
Minor change to pom name
Modified: trust/trunk/jbossws-native/pom.xml
===================================================================
--- trust/trunk/jbossws-native/pom.xml 2010-10-15 17:11:30 UTC (rev 483)
+++ trust/trunk/jbossws-native/pom.xml 2010-10-15 17:13:07 UTC (rev 484)
@@ -9,7 +9,7 @@
<groupId>org.picketlink</groupId>
<artifactId>picketlink-trust-jbossws</artifactId>
<packaging>jar</packaging>
- <name>PicketLink Trust for JBossWS Native stack</name>
+ <name>PicketLink Trust for JBossWS</name>
<url>http://labs.jboss.org/portal/picketlink/</url>
<description>Integration with JBossWS Native stack</description>
<licenses>
14 years, 2 months
Picketlink SVN: r483 - trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 13:11:30 -0400 (Fri, 15 Oct 2010)
New Revision: 483
Modified:
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
Log:
Removing useless print
Modified: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java 2010-10-15 16:44:19 UTC (rev 482)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java 2010-10-15 17:11:30 UTC (rev 483)
@@ -132,7 +132,6 @@
}
catch (Exception e)
{
- e.printStackTrace();
log.error(e);
return false;
}
14 years, 2 months
Picketlink SVN: r482 - trust/trunk/jbossws-native.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 12:44:19 -0400 (Fri, 15 Oct 2010)
New Revision: 482
Modified:
trust/trunk/jbossws-native/pom.xml
Log:
Refactoring to new artifactId without references to jbossws-native
Modified: trust/trunk/jbossws-native/pom.xml
===================================================================
--- trust/trunk/jbossws-native/pom.xml 2010-10-15 16:37:00 UTC (rev 481)
+++ trust/trunk/jbossws-native/pom.xml 2010-10-15 16:44:19 UTC (rev 482)
@@ -6,7 +6,8 @@
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>picketlink-trust-jbossws-native</artifactId>
+ <groupId>org.picketlink</groupId>
+ <artifactId>picketlink-trust-jbossws</artifactId>
<packaging>jar</packaging>
<name>PicketLink Trust for JBossWS Native stack</name>
<url>http://labs.jboss.org/portal/picketlink/</url>
14 years, 2 months
Picketlink SVN: r481 - in trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws: handler and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 12:37:00 -0400 (Fri, 15 Oct 2010)
New Revision: 481
Removed:
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerClient.java
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerServer.java
Modified:
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java
Log:
No need for separate server / client handlers as they do the same thing
Modified: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java 2010-10-15 16:09:24 UTC (rev 480)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java 2010-10-15 16:37:00 UTC (rev 481)
@@ -32,10 +32,6 @@
{
public static final String WSS_SOAP_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-secu...";
- public static final String JBOSS_WSSE_NS = "http://www.jboss.com/jbossws/ws-security";
-
- public static final String JBOSS_WSSE_PREFIX = "jboss-wsse";
-
public static final String WSSE_PREFIX = "wsse";
public static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext...";
Deleted: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerClient.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerClient.java 2010-10-15 16:09:24 UTC (rev 480)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerClient.java 2010-10-15 16:37:00 UTC (rev 481)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.trust.jbossws.handler;
-
-import javax.xml.ws.handler.MessageContext;
-
-import org.picketlink.trust.jbossws.SAML2Constants;
-import org.w3c.dom.Element;
-
-/**
- * A client side WS handler.
- * It expects a {@link Element} assertion as the value of the {@link SAML2Constants#SAML2_ASSERTION_PROPERTY} property.
- * This assertion is then included in the SOAP payload.
- *
- * @author <a href="mmoyses(a)redhat.com">Marcus Moyses</a>
- * @version $Revision: 1 $
- */
-public class SAML2HandlerClient extends SAML2Handler
-{
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- return super.handleInbound(msgContext);
- }
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- return super.handleOutbound(msgContext);
- }
-
-}
Deleted: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerServer.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerServer.java 2010-10-15 16:09:24 UTC (rev 480)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2HandlerServer.java 2010-10-15 16:37:00 UTC (rev 481)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.trust.jbossws.handler;
-
-import javax.xml.ws.handler.MessageContext;
-
-/**
- * A server side WS handler.
- * Retrieves the SAML assertion from the SOAP payload and lets invocation go to JAAS for validation.
- *
- * @author <a href="mmoyses(a)redhat.com">Marcus Moyses</a>
- * @version $Revision: 1 $
- */
-public class SAML2HandlerServer extends SAML2Handler
-{
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- return super.handleInbound(msgContext);
- }
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- return super.handleOutbound(msgContext);
- }
-
-}
14 years, 2 months