Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 10:03:15 -0500 (Mon, 08 Nov 2010)
New Revision: 537
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.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/SAMLRequestWriter.java
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/util/StaxUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
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/WSTrustIssueTestCase.java
Log:
change case of first letter of method name
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java 2010-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -31,6 +31,7 @@
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.wspolicy.WSPolicyConstants;
import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
@@ -45,8 +46,6 @@
*/
public class WSPolicyParser extends AbstractParser
{
- public static final String APPLIES_TO = "AppliesTo";
-
/**
* @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
*/
@@ -61,7 +60,7 @@
StartElement startElement = (StartElement) xmlEvent;
String elementName = StaxParserUtil.getStartElementName( startElement );
- if( elementName.equalsIgnoreCase( APPLIES_TO ))
+ if( elementName.equalsIgnoreCase( WSPolicyConstants.APPLIES_TO ))
{
//Get the AppliesTo element
startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
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-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLAssertionWriter.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -69,7 +69,7 @@
StaxUtil.writeStartElement( writer, ASSERTION_PREFIX,
JBossSAMLConstants.ASSERTION.get() , ASSERTION_NSURI.get() );
StaxUtil.writeNameSpace( writer, ASSERTION_PREFIX, ASSERTION_NSURI.get() );
- StaxUtil.WriteDefaultNameSpace( writer, ASSERTION_NSURI.get() );
+ StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
//Attributes
StaxUtil.writeAttribute( writer, JBossSAMLConstants.ID.get(), assertion.getID() );
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLRequestWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLRequestWriter.java 2010-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLRequestWriter.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -57,7 +57,7 @@
StaxUtil.writeStartElement( writer, PROTOCOL_PREFIX,
JBossSAMLConstants.AUTHN_REQUEST.get() , PROTOCOL_NSURI.get() );
StaxUtil.writeNameSpace( writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get() );
- StaxUtil.WriteDefaultNameSpace( writer, ASSERTION_NSURI.get() );
+ StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
//Attributes
StaxUtil.writeAttribute( writer, JBossSAMLConstants.ID.get(), request.getID() );
@@ -100,7 +100,7 @@
StaxUtil.writeStartElement( writer, PROTOCOL_PREFIX,
JBossSAMLConstants.LOGOUT_REQUEST.get() , PROTOCOL_NSURI.get() );
StaxUtil.writeNameSpace( writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get() );
- StaxUtil.WriteDefaultNameSpace( writer, ASSERTION_NSURI.get() );
+ StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
//Attributes
StaxUtil.writeAttribute( writer, JBossSAMLConstants.ID.get(), logOutRequest.getID()
);
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-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -63,7 +63,7 @@
StaxUtil.writeStartElement( writer, PROTOCOL_PREFIX,
JBossSAMLConstants.RESPONSE.get() , PROTOCOL_NSURI.get() );
StaxUtil.writeNameSpace( writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get() );
- StaxUtil.WriteDefaultNameSpace( writer, ASSERTION_NSURI.get() );
+ StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
writeBaseAttributes( response );
@@ -109,7 +109,7 @@
}
StaxUtil.writeNameSpace( writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get() );
- StaxUtil.WriteDefaultNameSpace( writer, ASSERTION_NSURI.get() );
+ StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
writeBaseAttributes( response );
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java 2010-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -194,7 +194,7 @@
* @param ns
* @throws ProcessingException
*/
- public static void WriteDefaultNameSpace( XMLStreamWriter writer, String ns ) throws
ProcessingException
+ public static void writeDefaultNameSpace( XMLStreamWriter writer, String ns ) throws
ProcessingException
{
try
{
@@ -206,6 +206,8 @@
}
}
+
+
/**
* Write a namespace
* @param writer
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -35,13 +35,14 @@
import org.picketlink.identity.federation.core.util.StaxUtil;
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;
/**
* Given a {@code RequestSecurityToken}, write into an {@code OutputStream}
* @author Anil.Saldhana(a)redhat.com
* @since Oct 19, 2010
*/
-public class WSTrustRSTWriter
+public class WSTrustRSTWriter extends AbstractWSWriter
{
/**
* Write the {@code RequestSecurityToken} into the {@code OutputStream}
@@ -51,8 +52,7 @@
*/
public void write( RequestSecurityToken requestToken, OutputStream out ) throws
ProcessingException
{
- //Get the XML writer
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( out );
+ verifyWriter(out);
StaxUtil.writeStartElement( writer, PREFIX, RST, BASE_NAMESPACE);
StaxUtil.writeNameSpace( writer, PREFIX, BASE_NAMESPACE );
String context = requestToken.getContext();
@@ -69,7 +69,22 @@
{
writeTokenType( writer, tokenType );
}
+ //Deal with AppliesTo
+ AppliesTo appliesTo = requestToken.getAppliesTo();
+ if( appliesTo != null )
+ {
+ WSPolicyWriter wsPolicyWriter = new WSPolicyWriter();
+ wsPolicyWriter.write( appliesTo, out );
+ }
+ URI keyType = requestToken.getKeyType();
+ if( keyType != null )
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.KEY_TYPE,
BASE_NAMESPACE);
+ StaxUtil.writeCharacters(writer, keyType.toString() );
+ StaxUtil.writeEndElement( writer );
+ }
+
StaxUtil.writeEndElement( writer );
StaxUtil.flush( writer );
}
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-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -23,6 +23,8 @@
import static org.junit.Assert.assertEquals;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.bind.JAXBElement;
@@ -30,8 +32,10 @@
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.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.core.wstrust.writers.WSTrustRSTWriter;
import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.UseKeyType;
@@ -70,5 +74,15 @@
Element certEl = (Element) useKeyType.getAny();
assertEquals( "ds:" + WSTRequestSecurityTokenParser.KEYVALUE,
certEl.getTagName() );
+
+
+ //Now for the writing part
+ WSTrustRSTWriter rstWriter = new WSTrustRSTWriter();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ rstWriter.write(requestToken, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+ DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java 2010-11-05
16:45:01 UTC (rev 536)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java 2010-11-08
15:03:15 UTC (rev 537)
@@ -23,10 +23,13 @@
import static org.junit.Assert.assertEquals;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+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.core.wstrust.writers.WSTrustRSTWriter;
@@ -43,19 +46,21 @@
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
InputStream configStream = tcl.getResourceAsStream(
"parser/wst/wst-issue.xml" );
-
+
WSTrustParser parser = new WSTrustParser();
RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse(
configStream );
-
+
assertEquals( "testcontext", requestToken.getContext() );
assertEquals( WSTrustConstants.ISSUE_REQUEST ,
requestToken.getRequestType().toASCIIString() );
assertEquals( WSTrustConstants.SAML2_TOKEN_TYPE,
requestToken.getTokenType().toASCIIString() );
-
+
//Now for the writing part
WSTrustRSTWriter rstWriter = new WSTrustRSTWriter();
- rstWriter.write(requestToken, System.out );
-
- //TODO: use a buffer output stream. Reparse the written xml and then match the
orig object model with reparsed
- //object model
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ rstWriter.write(requestToken, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+ DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
}
}
\ No newline at end of file