Author: anil.saldhana(a)jboss.com
Date: 2010-11-30 17:16:55 -0500 (Tue, 30 Nov 2010)
New Revision: 574
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java
Log:
some fixes with xml enc
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2010-11-30
21:48:59 UTC (rev 573)
+++
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2010-11-30
22:16:55 UTC (rev 574)
@@ -21,9 +21,7 @@
*/
package org.picketlink.test.identity.federation.api.util;
-import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.io.StringWriter;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
@@ -101,48 +99,8 @@
AssertionType assertion = (AssertionType)
newRT.getAssertions().get(0).getAssertion();
assertEquals("testPrincipal", assertion.getIssuer().getValue());
- }
+ }
- public void testEncryptAssertionWithMarshalling() throws Exception
- {
- KeyPair kp = this.getKeyPair("RSA");
- SecretKey sk = this.getSecretKey();
-
- ResponseType rt = createResponse();
- Document responseDoc = sr.convert(rt);
-
- String assertionNS = JBossSAMLURIConstants.ASSERTION_NSURI.get();
-
- QName assertionQName = new QName(assertionNS, "EncryptedAssertion",
"saml");
-
- Element docElement =
XMLEncryptionUtil.encryptElementInDocument(responseDoc,kp.getPublic(), sk,
- 128, assertionQName, true);
-
- EncryptedAssertionType eet =
sr.getEncryptedAssertion(DocumentUtil.getNodeAsStream(docElement));
- rt.addAssertion( new RTChoiceType( eet ));
-
- StringWriter sw = new StringWriter();
- sr.marshall(rt, sw);
-
-
- System.out.println( sw.toString() );
-
- //Create a brand new ResponseType
- ResponseType received = sr.getResponseType(new
ByteArrayInputStream(sw.toString().getBytes("UTF-8")));
-
- EncryptedAssertionType encryptedAssertionType =
received.getAssertions().get(0).getEncryptedAssertion();
- Document eetDoc = sr.convert( encryptedAssertionType );
-
- Element decryptedDocumentElement =
XMLEncryptionUtil.decryptElementInDocument(eetDoc,kp.getPrivate());
-
- //Let us use the encrypted doc element to decrypt it
- ResponseType newRT =
sr.getResponseType(DocumentUtil.getNodeAsStream(decryptedDocumentElement));
-
- AssertionType assertion = newRT.getAssertions().get(0).getAssertion();
- assertEquals("http://identityurl", assertion.getIssuer().getValue());
- }
-
-
public void testArbitraryXML() throws Exception
{
String myXML =
"<somexml><a><b></b></a></somexml>";
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2010-11-30
21:48:59 UTC (rev 573)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2010-11-30
22:16:55 UTC (rev 574)
@@ -30,10 +30,8 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamWriter;
-import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
-import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
@@ -45,7 +43,6 @@
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusDetailType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
-import org.w3c.dom.Element;
/**
* Write a SAML Response to stream
@@ -97,15 +94,7 @@
EncryptedAssertionType encryptedAssertion =
choiceType.getEncryptedAssertion();
if( encryptedAssertion != null )
{
- Element encryptedElement = encryptedAssertion.getEncryptedElement();
- try
- {
- StaxUtil.writeCharacters(writer,
DocumentUtil.getNodeAsString(encryptedElement));
- }
- catch (ConfigurationException e)
- {
- throw new ProcessingException( e );
- }
+ //Skip
}
}
}
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-30
21:48:59 UTC (rev 573)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/StaxUtil.java 2010-11-30
22:16:55 UTC (rev 574)
@@ -244,6 +244,25 @@
throw new ProcessingException(e);
}
}
+
+ /**
+ * Write a string as text node
+ *
+ * @param writer
+ * @param value
+ * @throws ProcessingException
+ */
+ public static void writeCData(XMLStreamWriter writer, String value) throws
ProcessingException
+ {
+ try
+ {
+ writer.writeCData( value );
+ }
+ catch (XMLStreamException e)
+ {
+ throw new ProcessingException(e);
+ }
+ }
/**
* Write the default namespace
Show replies by date