Picketlink SVN: r545 - in idm/branches/1.1.0: picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: bdaw
Date: 2010-11-09 03:59:39 -0500 (Tue, 09 Nov 2010)
New Revision: 545
Modified:
idm/branches/1.1.0/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java
idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java
Log:
- provide option to "switch off" bug fix checking proper case sensitive results
Modified: idm/branches/1.1.0/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2010-11-08 19:33:44 UTC (rev 544)
+++ idm/branches/1.1.0/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2010-11-09 08:59:39 UTC (rev 545)
@@ -98,6 +98,8 @@
public static final String ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION = "allowNotDefinedIdentityObjectTypes";
+ public static final String ALLOW_NOT_CASE_SENSITIVE_SEARCH = "allowNotCaseSensitiveSearch";
+
public static final String DEFAULT_REALM_NAME = HibernateIdentityStoreImpl.class.getName() + ".DEFAULT_REALM";
public static final String CREDENTIAL_TYPE_PASSWORD = "PASSWORD";
@@ -116,6 +118,8 @@
private boolean isAllowNotDefinedIdentityObjectTypes = false;
+ private boolean isAllowNotCaseSensitiveSearch = false;
+
private boolean isManageTransactionDuringBootstrap = true;
// TODO: rewrite this into some more handy object
@@ -300,6 +304,13 @@
this.isAllowNotDefinedIdentityObjectTypes = true;
}
+ String allowNotCaseSensitiveSearch = configurationMD.getOptionSingleValue(ALLOW_NOT_CASE_SENSITIVE_SEARCH);
+
+ if (allowNotCaseSensitiveSearch != null && allowNotCaseSensitiveSearch.equalsIgnoreCase("true"))
+ {
+ this.isAllowNotCaseSensitiveSearch = true;
+ }
+
// Default realm
HibernateRealm realm = null;
@@ -672,8 +683,12 @@
}
// Check result with case sensitive compare:
- if (hibernateObject != null && hibernateObject.getName().equals(name))
+ if (isAllowNotCaseSensitiveSearch())
{
+ return hibernateObject;
+ }
+ else if (hibernateObject != null && hibernateObject.getName().equals(name))
+ {
return hibernateObject;
@@ -2978,4 +2993,10 @@
{
return isManageTransactionDuringBootstrap;
}
+
+ public boolean isAllowNotCaseSensitiveSearch()
+ {
+ return isAllowNotCaseSensitiveSearch;
+ }
}
+
Modified: idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java 2010-11-08 19:33:44 UTC (rev 544)
+++ idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java 2010-11-09 08:59:39 UTC (rev 545)
@@ -90,4 +90,6 @@
int getPagedExtensionSize();
+ public boolean isAllowNotCaseSensitiveSearch();
+
}
Modified: idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2010-11-08 19:33:44 UTC (rev 544)
+++ idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2010-11-09 08:59:39 UTC (rev 545)
@@ -628,7 +628,7 @@
IdentityObject io = createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn);
// Check for case insensitive name results
- if (!io.getName().equals(name))
+ if (!configuration.isAllowNotCaseSensitiveSearch() && !io.getName().equals(name))
{
io = null;
}
Modified: idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java 2010-11-08 19:33:44 UTC (rev 544)
+++ idm/branches/1.1.0/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java 2010-11-09 08:59:39 UTC (rev 545)
@@ -91,7 +91,9 @@
private final boolean createMissingContexts;
+ private final boolean allowNotCaseSensitiveSearch;
+
// Consts
public static final String PROVIDER_URL = "providerURL";
@@ -144,6 +146,8 @@
public static final String CREATE_MISSING_CONTEXTS = "createMissingContexts";
+ public static final String ALLOW_NOT_CASE_SENSITIVE_SEARCH = "allowNotCaseSensitiveSearch";
+
public SimpleLDAPIdentityStoreConfiguration(IdentityStoreConfigurationMetaData storeMD)
{
if (storeMD == null)
@@ -227,6 +231,16 @@
this.createMissingContexts = false;
}
+ String allowNotCaseSensitiveSearch = storeMD.getOptionSingleValue(ALLOW_NOT_CASE_SENSITIVE_SEARCH);
+ if (allowNotCaseSensitiveSearch != null && allowNotCaseSensitiveSearch.equalsIgnoreCase("true"))
+ {
+ this.allowNotCaseSensitiveSearch = true;
+ }
+ else
+ {
+ this.allowNotCaseSensitiveSearch = false;
+ }
+
Map<String, LDAPIdentityObjectTypeConfiguration> types = new HashMap<String, LDAPIdentityObjectTypeConfiguration>();
for (IdentityObjectTypeMetaData identityObjectTypeMetaData : storeMD.getSupportedIdentityTypes())
@@ -539,4 +553,9 @@
{
return pagedExtensionSize;
}
+
+ public boolean isAllowNotCaseSensitiveSearch()
+ {
+ return allowNotCaseSensitiveSearch;
+ }
}
14 years, 1 month
Picketlink SVN: r544 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 14:33:44 -0500 (Mon, 08 Nov 2010)
New Revision: 544
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
Log:
add javadoc
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-08 18:17:09 UTC (rev 543)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-08 19:33:44 UTC (rev 544)
@@ -157,6 +157,11 @@
StaxUtil.flush( writer );
}
+ /**
+ * Write an {@code EntropyType} to stream
+ * @param entropy
+ * @throws ProcessingException
+ */
private void writeEntropyType(EntropyType entropy) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.ENTROPY, BASE_NAMESPACE);
@@ -176,6 +181,11 @@
StaxUtil.writeEndElement( writer );
}
+ /**
+ * Write an {@code UseKeyType} to stream
+ * @param useKeyType
+ * @throws ProcessingException
+ */
private void writeUseKeyType(UseKeyType useKeyType) throws ProcessingException
{
Object useKeyTypeValue = useKeyType.getAny();
@@ -188,6 +198,12 @@
throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
}
+ /**
+ * Write an {@code OnBehalfOfType} to stream
+ * @param onBehalfOf
+ * @param out
+ * @throws ProcessingException
+ */
private void writeOnBehalfOfType(OnBehalfOfType onBehalfOf, OutputStream out) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.On_BEHALF_OF, BASE_NAMESPACE);
@@ -199,6 +215,12 @@
StaxUtil.writeEndElement( writer );
}
+ /**
+ * Write an {@code ValidateTargetType} to stream
+ * @param validateTarget
+ * @param out
+ * @throws ProcessingException
+ */
private void writeValidateTargetType(ValidateTargetType validateTarget, OutputStream out) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.VALIDATE_TARGET, BASE_NAMESPACE);
@@ -216,6 +238,12 @@
StaxUtil.writeEndElement( writer );
}
+ /**
+ * Write an {@code CancelTargetType} to Stream
+ * @param cancelTarget
+ * @param out
+ * @throws ProcessingException
+ */
private void writeCancelTargetType(CancelTargetType cancelTarget, OutputStream out) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.CANCEL_TARGET, BASE_NAMESPACE);
@@ -248,6 +276,12 @@
StaxUtil.writeEndElement(writer);
}
+ /**
+ * Write a Request Type
+ * @param writer
+ * @param uri
+ * @throws ProcessingException
+ */
private void writeRequestType( XMLStreamWriter writer , URI uri ) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.REQUEST_TYPE, BASE_NAMESPACE );
@@ -255,6 +289,12 @@
StaxUtil.writeEndElement(writer);
}
+ /**
+ * Write Token Type
+ * @param writer
+ * @param uri
+ * @throws ProcessingException
+ */
private void writeTokenType( XMLStreamWriter writer , URI uri ) throws ProcessingException
{
StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.TOKEN_TYPE, BASE_NAMESPACE );
14 years, 1 month
Picketlink SVN: r543 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/wstrust/writers and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 13:17:09 -0500 (Mon, 08 Nov 2010)
New Revision: 543
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/writers/WSTrustRSTWriter.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
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/WSTrustIssueSymmetricKeyTestCase.java
Log:
PLFED-109: wst writing
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-11-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -99,4 +99,5 @@
//Attribute Names
public static final String RST_CONTEXT = "Context";
+ public static final String TYPE = "Type";
}
\ No newline at end of file
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-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -22,22 +22,31 @@
package org.picketlink.identity.federation.core.wstrust.writers;
import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.BASE_NAMESPACE;
-import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.RST_CONTEXT;
import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.PREFIX;
import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.RST;
+import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.RST_COLLECTION;
+import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.RST_CONTEXT;
import java.io.OutputStream;
import java.net.URI;
+import java.util.List;
import javax.xml.stream.XMLStreamWriter;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter;
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.core.wstrust.wrappers.RequestSecurityTokenCollection;
+import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
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;
import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
import org.w3c.dom.Element;
@@ -49,6 +58,31 @@
public class WSTrustRSTWriter extends AbstractWSWriter
{
/**
+ * Write the {@code RequestSecurityTokenCollection} into the {@code OutputStream}
+ * @param requestTokenCollection
+ * @param out
+ * @throws ProcessingException
+ */
+ public void write( RequestSecurityTokenCollection requestTokenCollection, OutputStream out ) throws ProcessingException
+ {
+ verifyWriter(out);
+ StaxUtil.writeStartElement( writer, PREFIX, RST_COLLECTION, BASE_NAMESPACE);
+ StaxUtil.writeNameSpace( writer, PREFIX, BASE_NAMESPACE );
+
+ List<RequestSecurityToken> tokenList = requestTokenCollection.getRequestSecurityTokens();
+ if( tokenList == null )
+ throw new ProcessingException( "RST list is null" );
+
+ for( RequestSecurityToken token: tokenList )
+ {
+ write(token, out);
+ }
+
+ StaxUtil.writeEndElement( writer );
+ StaxUtil.flush( writer );
+ }
+
+ /**
* Write the {@code RequestSecurityToken} into the {@code OutputStream}
* @param requestToken
* @param out
@@ -88,35 +122,131 @@
StaxUtil.writeCharacters(writer, keyType.toString() );
StaxUtil.writeEndElement( writer );
}
+ EntropyType entropy = requestToken.getEntropy();
+ if( entropy != null )
+ {
+ writeEntropyType(entropy);
+ }
UseKeyType useKeyType = requestToken.getUseKey();
if( useKeyType != null )
{
- Object useKeyTypeValue = useKeyType.getAny();
- if( useKeyTypeValue instanceof Element )
- {
- Element domElement = (Element) useKeyTypeValue;
- StaxUtil.writeDOMElement( writer, domElement );
- }
- else
- throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
+ writeUseKeyType(useKeyType);
}
OnBehalfOfType onBehalfOf = requestToken.getOnBehalfOf();
if( onBehalfOf != null )
{
- StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.On_BEHALF_OF, BASE_NAMESPACE);
- StaxUtil.writeCharacters(writer, "" );
-
- UsernameTokenType usernameToken = (UsernameTokenType) onBehalfOf.getAny();
- WSSecurityWriter wsseWriter = new WSSecurityWriter();
- wsseWriter.write( usernameToken, out );
- StaxUtil.writeEndElement( writer );
+ writeOnBehalfOfType(onBehalfOf, out);
}
+ ValidateTargetType validateTarget = requestToken.getValidateTarget();
+ if( validateTarget != null )
+ {
+
+ writeValidateTargetType(validateTarget, out);
+ }
+
+ CancelTargetType cancelTarget = requestToken.getCancelTarget();
+ if( cancelTarget != null )
+ {
+ writeCancelTargetType(cancelTarget, out);
+ }
+
StaxUtil.writeEndElement( writer );
StaxUtil.flush( writer );
}
+
+ private void writeEntropyType(EntropyType entropy) throws ProcessingException
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.ENTROPY, BASE_NAMESPACE);
+
+ List<Object> entropyList = entropy.getAny();
+ if( entropyList != null )
+ {
+ for( Object entropyObj: entropyList )
+ {
+ if( entropyObj instanceof BinarySecretType )
+ {
+ BinarySecretType binarySecret = (BinarySecretType) entropyObj;
+ writeBinarySecretType( writer, binarySecret );
+ }
+ }
+ }
+ StaxUtil.writeEndElement( writer );
+ }
+
+ private void writeUseKeyType(UseKeyType useKeyType) throws ProcessingException
+ {
+ Object useKeyTypeValue = useKeyType.getAny();
+ if( useKeyTypeValue instanceof Element )
+ {
+ Element domElement = (Element) useKeyTypeValue;
+ StaxUtil.writeDOMElement( writer, domElement );
+ }
+ else
+ throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
+ }
+
+ private void writeOnBehalfOfType(OnBehalfOfType onBehalfOf, OutputStream out) throws ProcessingException
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.On_BEHALF_OF, BASE_NAMESPACE);
+ StaxUtil.writeCharacters(writer, "" );
+
+ UsernameTokenType usernameToken = (UsernameTokenType) onBehalfOf.getAny();
+ WSSecurityWriter wsseWriter = new WSSecurityWriter();
+ wsseWriter.write( usernameToken, out );
+ StaxUtil.writeEndElement( writer );
+ }
+
+ private void writeValidateTargetType(ValidateTargetType validateTarget, OutputStream out) throws ProcessingException
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.VALIDATE_TARGET, BASE_NAMESPACE);
+ StaxUtil.writeCharacters(writer, "" );
+
+ Object validateTargetObj = validateTarget.getAny();
+ if( validateTargetObj instanceof AssertionType )
+ {
+ AssertionType assertion = (AssertionType) validateTargetObj;
+ SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter();
+ samlAssertionWriter.write(assertion, out);
+ }
+ else throw new ProcessingException( "Unknown validate target type=" + validateTargetObj.getClass().getName() );
+
+ StaxUtil.writeEndElement( writer );
+ }
+
+ private void writeCancelTargetType(CancelTargetType cancelTarget, OutputStream out) throws ProcessingException
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.CANCEL_TARGET, BASE_NAMESPACE);
+ StaxUtil.writeCharacters(writer, "" );
+
+ Object cancelTargetObj = cancelTarget.getAny();
+ if( cancelTargetObj instanceof AssertionType )
+ {
+ AssertionType assertion = (AssertionType) cancelTargetObj;
+ SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter();
+ samlAssertionWriter.write(assertion, out);
+ }
+ else throw new ProcessingException( "Unknown cancel target type=" + cancelTargetObj.getClass().getName() );
+
+ StaxUtil.writeEndElement( writer );
+ }
+
+ /**
+ * Write a {@code BinarySecretType} to stream
+ * @param writer
+ * @param binarySecret
+ * @throws ProcessingException
+ */
+ private void writeBinarySecretType( XMLStreamWriter writer, BinarySecretType binarySecret ) throws ProcessingException
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.BINARY_SECRET, BASE_NAMESPACE );
+ String type = binarySecret.getType();
+ StaxUtil.writeAttribute(writer, WSTrustConstants.TYPE, type );
+ StaxUtil.writeCharacters(writer, new String( binarySecret.getValue() ) );
+ StaxUtil.writeEndElement(writer);
+ }
private void writeRequestType( XMLStreamWriter writer , URI uri ) throws ProcessingException
{
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java 2010-11-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -24,14 +24,18 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.List;
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.wrappers.RequestSecurityTokenCollection;
+import org.picketlink.identity.federation.core.wstrust.writers.WSTrustRSTWriter;
/**
* Validate the parsing of wst-batch-validate.xml
@@ -62,6 +66,16 @@
assertEquals( "validatecontext2", rst2.getContext() );
assertEquals( WSTrustConstants.BATCH_VALIDATE_REQUEST , rst2.getRequestType().toASCIIString() );
assertEquals( WSTrustConstants.RSTR_STATUS_TOKEN_TYPE , rst2.getTokenType().toASCIIString() );
+
+ //Now for the writing part
+ WSTrustRSTWriter rstWriter = new WSTrustRSTWriter();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ rstWriter.write( requestCollection, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+ DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
+ baos.close();
}
}
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2010-11-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -24,6 +24,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.List;
@@ -33,8 +35,10 @@
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
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.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.saml.v2.assertion.AssertionType;
import org.picketlink.identity.federation.saml.v2.assertion.ConditionsType;
import org.picketlink.identity.federation.saml.v2.assertion.NameIDType;
@@ -56,14 +60,23 @@
InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-cancel-saml.xml" );
WSTrustParser parser = new WSTrustParser();
- RequestSecurityToken rst1 = (RequestSecurityToken) parser.parse( configStream );
- assertEquals( "cancelcontext", rst1.getContext() );
- assertEquals( WSTrustConstants.CANCEL_REQUEST, rst1.getRequestType().toASCIIString() );
+ RequestSecurityToken requestToken = (RequestSecurityToken) parser.parse( configStream );
+ assertEquals( "cancelcontext", requestToken.getContext() );
+ assertEquals( WSTrustConstants.CANCEL_REQUEST, requestToken.getRequestType().toASCIIString() );
- CancelTargetType cancelTarget = rst1.getCancelTarget();
+ CancelTargetType cancelTarget = requestToken.getCancelTarget();
AssertionType assertion = (AssertionType) cancelTarget.getAny();
validateAssertion( assertion );
+
+ //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() ));
}
private void validateAssertion( AssertionType assertion ) throws Exception
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-11-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -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,14 @@
Element certEl = (Element) useKeyType.getAny();
assertEquals( "ds:" + WSTRequestSecurityTokenParser.X509CERTIFICATE, 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/WSTrustIssueSymmetricKeyTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java 2010-11-08 17:36:26 UTC (rev 542)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java 2010-11-08 18:17:09 UTC (rev 543)
@@ -23,14 +23,18 @@
import static org.junit.Assert.assertEquals;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.bind.JAXBElement;
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;
import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.BinarySecretType;
@@ -69,5 +73,14 @@
assertEquals( WSTrustConstants.BS_TYPE_NONCE, binarySecret.getType() );
assertEquals( "M0/7qLpV49c=" , new String( binarySecret.getValue() ));
+
+ //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
14 years, 1 month
Picketlink SVN: r542 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/wsse and 2 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 12:36:26 -0500 (Mon, 08 Nov 2010)
New Revision: 542
Added:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsse/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsse/WSSecurityConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSSecurityWriter.java
Modified:
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/WSTrustOnBehalfOfTestCase.java
Log:
PLFED-109: wst writing
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsse/WSSecurityConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsse/WSSecurityConstants.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsse/WSSecurityConstants.java 2010-11-08 17:36:26 UTC (rev 542)
@@ -0,0 +1,39 @@
+/*
+ * 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.wsse;
+
+/**
+ * Constants for WSS and WSSE
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 8, 2010
+ */
+public interface WSSecurityConstants
+{
+ String ID = "Id";
+ String USERNAME = "Username";
+ String USERNAME_TOKEN = "UsernameToken";
+ String WSSE_PREFIX = "wsse";
+ String WSU_PREFIX = "wsu";
+ String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext...";
+ String WSSE11_NS = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";
+ String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit...";
+}
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSSecurityWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSSecurityWriter.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSSecurityWriter.java 2010-11-08 17:36:26 UTC (rev 542)
@@ -0,0 +1,83 @@
+/*
+ * 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.wstrust.writers;
+
+
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.ID;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.USERNAME;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.USERNAME_TOKEN;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.WSSE_NS;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.WSSE_PREFIX;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.WSU_NS;
+import static org.picketlink.identity.federation.core.wsse.WSSecurityConstants.WSU_PREFIX;
+
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.core.util.StringUtil;
+import org.picketlink.identity.federation.ws.wss.secext.AttributedString;
+import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
+
+/**
+ * Write WS-Security Elements
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 8, 2010
+ */
+public class WSSecurityWriter extends AbstractWSWriter
+{
+ /**
+ * Write an {@code UsernameTokenType} to the stream
+ * @param appliesTo
+ * @param out
+ * @throws ProcessingException
+ */
+ public void write( UsernameTokenType usernameToken, OutputStream out ) throws ProcessingException
+ {
+ verifyWriter(out);
+
+ StaxUtil.writeStartElement( writer, WSSE_PREFIX, USERNAME_TOKEN, WSSE_NS );
+ StaxUtil.writeNameSpace( writer, WSSE_PREFIX, WSSE_NS );
+
+ String id = usernameToken.getId();
+ if( StringUtil.isNullOrEmpty( id ))
+ throw new ProcessingException( " Id on the UsernameToken is null" );
+
+ StaxUtil.setPrefix(writer, WSU_PREFIX, WSU_NS );
+ QName wsuIDQName = new QName( WSU_NS, ID, WSU_PREFIX );
+ StaxUtil.writeAttribute(writer, wsuIDQName, id );
+ StaxUtil.writeNameSpace(writer, WSU_PREFIX, WSU_NS );
+
+ AttributedString userNameAttr = usernameToken.getUsername();
+ if( userNameAttr == null )
+ throw new ProcessingException( " User Name is null on the UsernameToken" );
+
+ StaxUtil.writeStartElement( writer, WSSE_PREFIX, USERNAME, WSSE_NS );
+ StaxUtil.writeCharacters(writer, userNameAttr.getValue() );
+ StaxUtil.writeEndElement( writer );
+
+ StaxUtil.writeEndElement( writer );
+ StaxUtil.flush( writer );
+ }
+}
\ No newline at end of file
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-08 17:08:34 UTC (rev 541)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-08 17:36:26 UTC (rev 542)
@@ -36,7 +36,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.OnBehalfOfType;
import org.picketlink.identity.federation.ws.trust.UseKeyType;
+import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
import org.w3c.dom.Element;
/**
@@ -100,6 +102,18 @@
throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
}
+ OnBehalfOfType onBehalfOf = requestToken.getOnBehalfOf();
+ if( onBehalfOf != null )
+ {
+ StaxUtil.writeStartElement( writer, PREFIX, WSTrustConstants.On_BEHALF_OF, BASE_NAMESPACE);
+ StaxUtil.writeCharacters(writer, "" );
+
+ UsernameTokenType usernameToken = (UsernameTokenType) onBehalfOf.getAny();
+ WSSecurityWriter wsseWriter = new WSSecurityWriter();
+ wsseWriter.write( usernameToken, out );
+ 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/WSTrustOnBehalfOfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java 2010-11-08 17:08:34 UTC (rev 541)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java 2010-11-08 17:36:26 UTC (rev 542)
@@ -23,12 +23,16 @@
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;
import org.picketlink.identity.federation.ws.trust.OnBehalfOfType;
import org.picketlink.identity.federation.ws.wss.secext.UsernameTokenType;
@@ -55,5 +59,14 @@
UsernameTokenType userNameToken = (UsernameTokenType) onBehalfOf.getAny();
assertEquals( "id", userNameToken.getId() );
assertEquals( "anotherduke", userNameToken.getUsername().getValue() );
+
+ //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
14 years, 1 month
Picketlink SVN: r541 - in federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core: stax and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 12:08:34 -0500 (Mon, 08 Nov 2010)
New Revision: 541
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java
Log:
simple test case for DOM element to stax
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java 2010-11-08 17:08:34 UTC (rev 541)
@@ -0,0 +1,56 @@
+/*
+ * 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.stax;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.w3c.dom.Document;
+
+/**
+ * Test how we write a DOM Element to Stax writer
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 8, 2010
+ */
+public class DomElementToStaxWritingTestCase
+{
+ @Test
+ public void testDOM2Stax() throws Exception
+ {
+ String xml = "<a xmlns=\'urn:hello\' > <b> <c/> <d xmlns=\'urn:t\' test=\'tt\'/> </b></a>";
+
+ Document doc = DocumentUtil.getDocument( xml );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
+ StaxUtil.writeDOMElement(writer, doc.getDocumentElement() );
+
+ String writtenDoc = new String( baos.toByteArray() );
+ System.out.println( writtenDoc );
+ doc = DocumentUtil.getDocument( writtenDoc );
+ }
+}
\ No newline at end of file
14 years, 1 month
Picketlink SVN: r540 - in federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core: wsa and 2 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 12:07:52 -0500 (Mon, 08 Nov 2010)
New Revision: 540
Added:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
Log:
add ws-t writing
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,35 @@
+/*
+ * 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.wsa;
+
+/**
+ * WS-Addressing Constants
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 5, 2010
+ */
+public interface WSAddressingConstants
+{
+ String ADDRESS = "Address";
+ String ENDPOINT_REFERENCE = "EndpointReference";
+ String WSA_PREFIX = "wsa";
+ String WSA_NS = "http://www.w3.org/2005/08/addressing";
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,34 @@
+/*
+ * 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.wspolicy;
+
+/**
+ * Constants for WS-Policy
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 5, 2010
+ */
+public interface WSPolicyConstants
+{
+ String APPLIES_TO = "AppliesTo";
+ String WSP_PREFIX = "wsp";
+ String WSP_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,48 @@
+/*
+ * 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.wstrust.writers;
+
+import java.io.OutputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+
+/**
+ * Base class for the WS Stax Writers
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 5, 2010
+ */
+public class AbstractWSWriter
+{
+ protected XMLStreamWriter writer = null;
+
+ protected void verifyWriter( OutputStream out ) throws ProcessingException
+ {
+ if( writer == null )
+ {
+ writer = StaxUtil.getXMLStreamWriter( out );
+ }
+ }
+
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,64 @@
+/*
+ * 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.wstrust.writers;
+
+
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.ADDRESS;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.ENDPOINT_REFERENCE;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.WSA_NS;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.WSA_PREFIX;
+
+import java.io.OutputStream;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.ws.addressing.AttributedURIType;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+
+/**
+ * Write WS-Addressing Elements
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 5, 2010
+ */
+public class WSAddressingWriter extends AbstractWSWriter
+{
+ public void write( EndpointReferenceType endpointReference, OutputStream out ) throws ProcessingException
+ {
+ verifyWriter(out);
+
+ StaxUtil.writeStartElement( writer, WSA_PREFIX, ENDPOINT_REFERENCE, WSA_NS );
+ StaxUtil.writeNameSpace( writer, WSA_PREFIX, WSA_NS );
+
+ AttributedURIType attributedURI = endpointReference.getAddress();
+ if( attributedURI != null )
+ {
+ String value = attributedURI.getValue();
+
+ StaxUtil.writeStartElement( writer, WSA_PREFIX, ADDRESS, WSA_NS );
+ StaxUtil.writeCharacters( writer, value );
+ StaxUtil.writeEndElement( writer );
+ }
+
+ StaxUtil.writeEndElement( writer );
+ StaxUtil.flush( writer );
+ }
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,78 @@
+/*
+ * 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.wstrust.writers;
+
+
+import static org.picketlink.identity.federation.core.wspolicy.WSPolicyConstants.APPLIES_TO;
+import static org.picketlink.identity.federation.core.wspolicy.WSPolicyConstants.WSP_PREFIX;
+import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.WSP_NS;
+
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
+
+/**
+ * Write the WS-Policy Elements
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 5, 2010
+ */
+public class WSPolicyWriter extends AbstractWSWriter
+{
+ /**
+ * Write an {@code AppliesTo} to the stream
+ * @param appliesTo
+ * @param out
+ * @throws ProcessingException
+ */
+ public void write( AppliesTo appliesTo, OutputStream out ) throws ProcessingException
+ {
+ verifyWriter(out);
+
+ StaxUtil.writeStartElement( writer, WSP_PREFIX, APPLIES_TO, WSP_NS );
+ StaxUtil.writeNameSpace( writer, WSP_PREFIX, WSP_NS );
+ StaxUtil.writeCharacters(writer, "" ); //Seems like JDK bug - not writing end character
+
+ List<Object> contentList = appliesTo.getAny();
+ if( contentList != null )
+ {
+ for( Object content: contentList )
+ {
+ JAXBElement<?> jaxb = (JAXBElement<?>) content;
+ if( EndpointReferenceType.class.equals( jaxb.getDeclaredType() ) )
+ {
+ EndpointReferenceType endpointReference = (EndpointReferenceType) jaxb.getValue();
+ WSAddressingWriter wsAddressingWriter = new WSAddressingWriter();
+ wsAddressingWriter.write(endpointReference, out);
+ }
+ }
+ }
+
+ StaxUtil.writeEndElement( writer );
+ StaxUtil.flush( writer );
+ }
+}
\ No newline at end of file
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-08 17:06:59 UTC (rev 539)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java 2010-11-08 17:07:52 UTC (rev 540)
@@ -36,6 +36,8 @@
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.UseKeyType;
+import org.w3c.dom.Element;
/**
* Given a {@code RequestSecurityToken}, write into an {@code OutputStream}
@@ -85,6 +87,19 @@
StaxUtil.writeEndElement( writer );
}
+ UseKeyType useKeyType = requestToken.getUseKey();
+ if( useKeyType != null )
+ {
+ Object useKeyTypeValue = useKeyType.getAny();
+ if( useKeyTypeValue instanceof Element )
+ {
+ Element domElement = (Element) useKeyTypeValue;
+ StaxUtil.writeDOMElement( writer, domElement );
+ }
+ else
+ throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
+ }
+
StaxUtil.writeEndElement( writer );
StaxUtil.flush( writer );
}
14 years, 1 month
Picketlink SVN: r539 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 12:06:59 -0500 (Mon, 08 Nov 2010)
New Revision: 539
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/TransformerUtil.java
Log:
add prefix to element
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/TransformerUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/TransformerUtil.java 2010-11-08 17:06:33 UTC (rev 538)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/TransformerUtil.java 2010-11-08 17:06:59 UTC (rev 539)
@@ -269,8 +269,13 @@
String prefix = elementName.getPrefix();
String localPart = elementName.getLocalPart();
- String qual = prefix != null && prefix != "" ? prefix + ":" + localPart : localPart ;
- Element el = doc.createElementNS( ns, qual );
+ String qual = prefix != null && prefix != "" ? prefix + ":" + localPart : localPart ;
+ Element el = doc.createElementNS( ns, qual );
+
+ if( StringUtil.isNotNull( prefix ))
+ {
+ el.setPrefix( prefix );
+ }
//Look for attributes
@SuppressWarnings("unchecked")
@@ -285,6 +290,7 @@
doc.createAttributeNS( ns, qual );
el.setAttributeNS( ns, qual , attr.getValue() );
}
+
XMLEvent nextEvent = StaxParserUtil.peek(xmlEventReader);
if( nextEvent.getEventType() == XMLEvent.CHARACTERS )
14 years, 1 month
Picketlink SVN: r538 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-08 12:06:33 -0500 (Mon, 08 Nov 2010)
New Revision: 538
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java
Log:
add stax writing dom element
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-08 15:03:15 UTC (rev 537)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java 2010-11-08 17:06:33 UTC (rev 538)
@@ -22,6 +22,7 @@
package org.picketlink.identity.federation.core.util;
import java.io.OutputStream;
+import java.util.Stack;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventWriter;
@@ -30,6 +31,11 @@
import javax.xml.stream.XMLStreamWriter;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
/**
* Utility class that deals with StAX
@@ -38,6 +44,8 @@
*/
public class StaxUtil
{
+ private static ThreadLocal<Stack<String>> registeredNSStack = new ThreadLocal<Stack<String>>();
+
/**
* Flush the stream writer
* @param writer
@@ -206,6 +214,122 @@
}
}
+ /**
+ * Write a DOM Node to the stream
+ * @param writer
+ * @param node
+ * @throws ProcessingException
+ */
+ public static void writeDOMNode( XMLStreamWriter writer, Node node ) throws ProcessingException
+ {
+ try
+ {
+ short nodeType = node.getNodeType();
+
+ switch( nodeType )
+ {
+ case Node.ELEMENT_NODE:
+ writeDOMElement( writer, (Element) node);
+ break;
+ case Node.TEXT_NODE:
+ writer.writeCharacters(node.getNodeValue());
+ break;
+ case Node.COMMENT_NODE:
+ writer.writeComment(node.getNodeValue());
+ break;
+ case Node.CDATA_SECTION_NODE:
+ writer.writeCData(node.getNodeValue());
+ break;
+ default:
+ //Don't care
+ }
+ }
+ catch (DOMException e)
+ {
+ throw new ProcessingException( e );
+ }
+ catch (XMLStreamException e)
+ {
+ throw new ProcessingException( e );
+ }
+ }
+
+
+ /**
+ * Write DOM Element to the stream
+ * @param writer
+ * @param domElement
+ * @throws ProcessingException
+ */
+ public static void writeDOMElement( XMLStreamWriter writer, Element domElement ) throws ProcessingException
+ {
+ if( registeredNSStack.get() == null )
+ {
+ registeredNSStack.set( new Stack<String>() );
+ }
+ String domElementPrefix = domElement.getPrefix();
+
+ if (domElementPrefix == null)
+ {
+ domElementPrefix = "";
+ }
+
+ String domElementNS = domElement.getNamespaceURI();
+ if (domElementNS == null)
+ {
+ domElementNS = "";
+ }
+
+ writeStartElement(writer, domElementPrefix, domElement.getLocalName(), domElementNS);
+
+
+ //Should we register namespace
+ if( domElementPrefix != "" && !registeredNSStack.get().contains(domElementNS) )
+ {
+ writeNameSpace(writer, domElementPrefix, domElementNS );
+ registeredNSStack.get().push( domElementNS );
+ }
+
+ // Deal with Attributes
+ NamedNodeMap attrs = domElement.getAttributes();
+ for (int i = 0, len = attrs.getLength(); i < len; ++i)
+ {
+ Attr attr = (Attr) attrs.item(i);
+ String attributePrefix = attr.getPrefix();
+ String attribLocalName = attr.getLocalName();
+ String attribValue = attr.getValue();
+
+ if (attributePrefix == null || attributePrefix.length() == 0)
+ {
+ if ( "xmlns".equals( attribLocalName ))
+ {
+ writeDefaultNameSpace( writer, attribValue );
+ }
+ else
+ {
+ writeAttribute( writer, attribLocalName, attribValue );
+ }
+ }
+ else
+ {
+ if ( "xmlns".equals( attributePrefix ))
+ {
+ writeNameSpace( writer, attribLocalName, attribValue);
+ }
+ else
+ {
+ writeAttribute( writer, new QName( attr.getNamespaceURI(), attribLocalName, attributePrefix ), attribValue);
+ }
+ }
+ }
+
+ for ( Node child = domElement.getFirstChild(); child != null; child = child.getNextSibling() )
+ {
+ writeDOMNode( writer, child);
+ }
+
+ writeEndElement(writer);
+ }
/**
14 years, 1 month
Picketlink SVN: r537 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/saml/v2/writers and 3 other directories.
by picketlink-commits@lists.jboss.org
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
14 years, 1 month
Picketlink SVN: r536 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-11-05 12:45:01 -0400 (Fri, 05 Nov 2010)
New Revision: 536
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
Log:
validate writing with dom parsing
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2010-11-05 15:50:37 UTC (rev 535)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2010-11-05 16:45:01 UTC (rev 536)
@@ -24,6 +24,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.List;
@@ -34,6 +36,7 @@
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
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.saml.v2.writers.SAMLAssertionWriter;
import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
@@ -245,6 +248,12 @@
}
SAMLAssertionWriter writer = new SAMLAssertionWriter();
- writer.write(assertion, System.out );
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write(assertion, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+
+ ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
+ DocumentUtil.getDocument( bis ); //throws exceptions
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2010-11-05 15:50:37 UTC (rev 535)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2010-11-05 16:45:01 UTC (rev 536)
@@ -24,10 +24,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLRequestWriter;
import org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType;
@@ -67,7 +70,13 @@
assertEquals( Boolean.TRUE , nameIDPolicy.isAllowCreate() );
//Try out writing
- SAMLRequestWriter writer = new SAMLRequestWriter();
- writer.write(authnRequest, System.out );
+ SAMLRequestWriter writer = new SAMLRequestWriter();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write( authnRequest, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+
+ ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
+ DocumentUtil.getDocument( bis ); //throws exceptions
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2010-11-05 15:50:37 UTC (rev 535)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2010-11-05 16:45:01 UTC (rev 536)
@@ -24,6 +24,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.List;
@@ -31,6 +33,7 @@
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLResponseWriter;
import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
@@ -98,8 +101,14 @@
assertEquals( "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", authnContextDeclRefJaxb.getValue() );
//Let us do some writing - currently only visual inspection. We will do proper validation later.
- SAMLResponseWriter writer = new SAMLResponseWriter();
- writer.write(response, System.out );
+ SAMLResponseWriter writer = new SAMLResponseWriter();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write(response, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+
+ ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
+ DocumentUtil.getDocument( bis ); //throws exceptions
}
@Test
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java 2010-11-05 15:50:37 UTC (rev 535)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java 2010-11-05 16:45:01 UTC (rev 536)
@@ -24,10 +24,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLRequestWriter;
import org.picketlink.identity.federation.saml.v2.protocol.LogoutRequestType;
@@ -56,7 +59,13 @@
assertEquals( "http://localhost:8080/sales/", lotRequest.getIssuer().getValue() );
//Try out writing
- SAMLRequestWriter writer = new SAMLRequestWriter();
- writer.write( lotRequest, System.out );
+ SAMLRequestWriter writer = new SAMLRequestWriter();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write( lotRequest, baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+
+ ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
+ DocumentUtil.getDocument( bis ); //throws exceptions
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2010-11-05 15:50:37 UTC (rev 535)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2010-11-05 16:45:01 UTC (rev 536)
@@ -26,12 +26,15 @@
import static org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants.PROTOCOL_NSURI;
import static org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants.LOGOUT_RESPONSE;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.namespace.QName;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLResponseWriter;
import org.picketlink.identity.federation.saml.v2.protocol.StatusResponseType;
@@ -67,7 +70,13 @@
assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success", status.getStatusCode().getStatusCode().getValue() );
//Let us do some writing - currently only visual inspection. We will do proper validation later.
- SAMLResponseWriter writer = new SAMLResponseWriter();
- writer.write(response, new QName( PROTOCOL_NSURI.get(), LOGOUT_RESPONSE.get(), "samlp"), System.out );
+ SAMLResponseWriter writer = new SAMLResponseWriter();ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write(response, new QName( PROTOCOL_NSURI.get(), LOGOUT_RESPONSE.get(), "samlp"), baos );
+
+ System.out.println( new String( baos.toByteArray() ));
+
+ ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
+ DocumentUtil.getDocument( bis ); //throws exceptions
+
}
}
\ No newline at end of file
14 years, 1 month