Picketlink SVN: r1449 - in federation/trunk/picketlink-fed-core/src: test/java/org/picketlink/test/identity/federation/core/util and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-29 17:12:10 -0500 (Wed, 29 Feb 2012)
New Revision: 1449
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java
Log:
PLFED-268: the trim() method should be able to take empty string
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2012-02-28 16:49:30 UTC (rev 1448)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2012-02-29 22:12:10 UTC (rev 1449)
@@ -24,7 +24,6 @@
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_END_TAG;
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_TAG;
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_XSI;
-import static org.picketlink.identity.federation.core.ErrorCodes.NULL_INPUT_STREAM;
import java.io.IOException;
import java.io.InputStream;
@@ -44,6 +43,7 @@
import javax.xml.validation.Validator;
import org.apache.log4j.Logger;
+import org.picketlink.identity.federation.core.ErrorCodes;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
@@ -439,8 +439,8 @@
*/
public static final String trim(String str)
{
- if (str == null || str.length() == 0)
- throw new IllegalArgumentException(NULL_INPUT_STREAM);
+ if (str == null)
+ throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT);
return str.trim();
}
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java 2012-02-28 16:49:30 UTC (rev 1448)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java 2012-02-29 22:12:10 UTC (rev 1449)
@@ -22,12 +22,14 @@
package org.picketlink.test.identity.federation.core.util;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.util.StringUtil;
/**
@@ -80,4 +82,12 @@
throw new RuntimeException("Unknown");
}
}
+
+ @Test
+ public void trim() throws Exception
+ {
+ assertNotNull("".trim());
+ assertEquals(0, "".trim().length());
+ assertEquals(0, StaxParserUtil.trim("").length());
+ }
}
\ No newline at end of file
12 years, 10 months
Picketlink SVN: r1448 - integration-tests/trunk/ant-scripts.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-28 11:49:30 -0500 (Tue, 28 Feb 2012)
New Revision: 1448
Modified:
integration-tests/trunk/ant-scripts/ant-build.xml
Log:
change wait to 10secs
Modified: integration-tests/trunk/ant-scripts/ant-build.xml
===================================================================
--- integration-tests/trunk/ant-scripts/ant-build.xml 2012-02-28 16:01:27 UTC (rev 1447)
+++ integration-tests/trunk/ant-scripts/ant-build.xml 2012-02-28 16:49:30 UTC (rev 1448)
@@ -186,9 +186,9 @@
<http url="http://localhost:8080/idp-sig/" />
</waitfor>
<echo>:Local 8080 Started</echo>
- <echo>Going to wait 5 seconds for server to fully start up</echo>
- <sleep seconds="5"/>
- <echo>Sleep of 5 seconds Done.</echo>
+ <echo>Going to wait 10 seconds for server to fully start up</echo>
+ <sleep seconds="10"/>
+ <echo>Sleep of 10 seconds Done.</echo>
</target>
<target name="start-jboss5" depends="copy-picketlink-jbas5" >
12 years, 10 months
Picketlink SVN: r1447 - integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-28 11:01:27 -0500 (Tue, 28 Feb 2012)
New Revision: 1447
Modified:
integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2MixedBindingGlobalLogOutUnitTestCase.java
integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2PostBindingGlobalLogOutUnitTestCase.java
integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2RedirectBindingGlobalLogOutUnitTestCase.java
integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2ResponseParsingUnitTestCase.java
Log:
clear WebConversation
Modified: integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2MixedBindingGlobalLogOutUnitTestCase.java
===================================================================
--- integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2MixedBindingGlobalLogOutUnitTestCase.java 2012-02-27 19:10:45 UTC (rev 1446)
+++ integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2MixedBindingGlobalLogOutUnitTestCase.java 2012-02-28 16:01:27 UTC (rev 1447)
@@ -119,6 +119,8 @@
assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
System.out.println("Trying "+ url2);
webResponse = webConversation.getResponse( url2 );
- assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+ assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+
+ webConversation.clearContents();
}
}
Modified: integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2PostBindingGlobalLogOutUnitTestCase.java
===================================================================
--- integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2PostBindingGlobalLogOutUnitTestCase.java 2012-02-27 19:10:45 UTC (rev 1446)
+++ integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2PostBindingGlobalLogOutUnitTestCase.java 2012-02-28 16:01:27 UTC (rev 1447)
@@ -88,7 +88,8 @@
//Hit the Employee App again
System.out.println("Trying "+ getService2URL());
webResponse = webConversation.getResponse( getService2URL() );
- assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+ assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+ webConversation.clearContents();
}
public String getService1URL()
Modified: integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2RedirectBindingGlobalLogOutUnitTestCase.java
===================================================================
--- integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2RedirectBindingGlobalLogOutUnitTestCase.java 2012-02-27 19:10:45 UTC (rev 1446)
+++ integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2RedirectBindingGlobalLogOutUnitTestCase.java 2012-02-28 16:01:27 UTC (rev 1447)
@@ -90,6 +90,8 @@
//Hit the Employee App again
System.out.println("Trying "+ SERVICE_2_URL);
webResponse = webConversation.getResponse( SERVICE_2_URL );
- assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+ assertTrue( " Reached the Login page ", webResponse.getText().contains( "Login" ));
+
+ webConversation.clearContents();
}
}
\ No newline at end of file
Modified: integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2ResponseParsingUnitTestCase.java
===================================================================
--- integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2ResponseParsingUnitTestCase.java 2012-02-27 19:10:45 UTC (rev 1446)
+++ integration-tests/trunk/picketlink-saml-tests/src/test/java/org/picketlink/test/integration/saml2/SAML2ResponseParsingUnitTestCase.java 2012-02-28 16:01:27 UTC (rev 1447)
@@ -50,5 +50,7 @@
WebResponse webResponse = webConversation.getResponse( serviceRequest1 );
assertEquals( 200, webResponse.getResponseCode());
+
+ webConversation.clearContents();
}
}
\ No newline at end of file
12 years, 10 months
Picketlink SVN: r1446 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-27 14:10:45 -0500 (Mon, 27 Feb 2012)
New Revision: 1446
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/FileBasedMetadataConfigurationStoreUnitTestCase.java
Log:
hack for virtual images
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/FileBasedMetadataConfigurationStoreUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/FileBasedMetadataConfigurationStoreUnitTestCase.java 2012-02-27 18:28:39 UTC (rev 1445)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/FileBasedMetadataConfigurationStoreUnitTestCase.java 2012-02-27 19:10:45 UTC (rev 1446)
@@ -29,58 +29,61 @@
import java.util.HashMap;
import java.util.Map;
+import org.junit.Before;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.saml.v2.metadata.store.FileBasedMetadataConfigurationStore;
+import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.federation.saml.v2.metadata.EntityDescriptorType;
-
/**
* Unit test the FileBasedMetadataConfigurationStore
* @author Anil.Saldhana(a)redhat.com
* @since Apr 28, 2009
*/
-public class FileBasedMetadataConfigurationStoreUnitTestCase
+public class FileBasedMetadataConfigurationStoreUnitTestCase
{
String pkgName = "org.picketlink.identity.federation.saml.v2.metadata";
+
String id = "test";
-
+
+ @Before
+ public void setup() throws Exception
+ {
+ String userHome = System.getProperty("user.home");
+ if (StringUtil.isNotNull(userHome) && "?".equals(userHome))
+ System.setProperty("user.home", System.getProperty("user.dir"));
+ }
+
@Test
public void testStore() throws Exception
{
SAMLParser parser = new SAMLParser();
-
+
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
- tcl.getResourceAsStream("saml2/metadata/idp-entitydescriptor.xml");
- assertNotNull("Inputstream not null", is);
-
+ InputStream is = tcl.getResourceAsStream("saml2/metadata/idp-entitydescriptor.xml");
+ assertNotNull("Inputstream not null", is);
+
EntityDescriptorType edt = (EntityDescriptorType) parser.parse(is);
- assertNotNull( edt );
- /*
- Unmarshaller un = JAXBUtil.getUnmarshaller(pkgName);
- JAXBElement<EntityDescriptorType> je = (JAXBElement<EntityDescriptorType>) un.unmarshal(is);
- EntityDescriptorType edt = je.getValue();
- assertNotNull("EntityDescriptorType not null", edt);
- */
+ assertNotNull(edt);
FileBasedMetadataConfigurationStore fbd = new FileBasedMetadataConfigurationStore();
fbd.persist(edt, id);
-
+
EntityDescriptorType loaded = fbd.load(id);
assertNotNull("loaded EntityDescriptorType not null", loaded);
fbd.delete(id);
-
+
try
{
fbd.load(id);
fail("Did not delete the metadata persistent file");
}
- catch(Exception t)
+ catch (Exception t)
{
//pass
}
}
-
+
@Test
public void testTrustedProviders() throws Exception
{
@@ -89,22 +92,22 @@
trustedProviders.put("idp1", "http://localhost:8080/idp1/metadata");
trustedProviders.put("idp2", "http://localhost:8080/idp2/metadata");
fbd.persistTrustedProviders(id, trustedProviders);
-
+
//Lets get back
Map<String, String> loadTP = fbd.loadTrustedProviders(id);
assertNotNull("Loaded Trusted Providers not null", loadTP);
-
+
assertTrue("idp1", loadTP.containsKey("idp1"));
assertTrue("idp2", loadTP.containsKey("idp2"));
assertTrue("size 2", loadTP.size() == 2);
-
+
fbd.deleteTrustedProviders(id);
try
{
fbd.loadTrustedProviders(id);
fail("Did not delete the trusted providers file");
}
- catch(Exception t)
+ catch (Exception t)
{
//pass
}
12 years, 10 months
Picketlink SVN: r1445 - integration-tests/trunk/picketlink-sts-jbas7-cxf.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-27 13:28:39 -0500 (Mon, 27 Feb 2012)
New Revision: 1445
Modified:
integration-tests/trunk/picketlink-sts-jbas7-cxf/pom.xml
Log:
include the relevant test
Modified: integration-tests/trunk/picketlink-sts-jbas7-cxf/pom.xml
===================================================================
--- integration-tests/trunk/picketlink-sts-jbas7-cxf/pom.xml 2012-02-27 18:26:30 UTC (rev 1444)
+++ integration-tests/trunk/picketlink-sts-jbas7-cxf/pom.xml 2012-02-27 18:28:39 UTC (rev 1445)
@@ -38,7 +38,7 @@
<printSummary>true</printSummary>
<disableXmlReport>false</disableXmlReport>
<includes>
- <include>**/**TestCase.java</include>
+ <include>**/Picket**TestCase.java</include>
</includes>
<forkMode>pertest</forkMode>
<argLine>-Djava.endorsed.dirs=${basedir}/../picketlink-sts-tests/src/test/resources/endorsed</argLine>
12 years, 10 months
Picketlink SVN: r1444 - integration-tests/trunk.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-27 13:26:30 -0500 (Mon, 27 Feb 2012)
New Revision: 1444
Modified:
integration-tests/trunk/pom.xml
Log:
add sts as7 module
Modified: integration-tests/trunk/pom.xml
===================================================================
--- integration-tests/trunk/pom.xml 2012-02-27 18:25:49 UTC (rev 1443)
+++ integration-tests/trunk/pom.xml 2012-02-27 18:26:30 UTC (rev 1444)
@@ -26,10 +26,9 @@
<module>picketlink-sts-jbas51-native</module>
<module>picketlink-sts-jbas51-cxf</module>
<module>picketlink-sts-jbas6-cxf</module>
+ <module>picketlink-sts-jbas7-cxf</module>
<module>picketlink-pdp-tests</module>
<module>picketlink-trust-tests</module>
<module>picketlink-trust-jbas51-native</module>
-<!-- <module>picketlink-openid-tests</module> -->
-
</modules>
</project>
12 years, 10 months
Picketlink SVN: r1443 - integration-tests/trunk/common-dist/files.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-27 13:25:49 -0500 (Mon, 27 Feb 2012)
New Revision: 1443
Modified:
integration-tests/trunk/common-dist/files/standalone.xml
Log:
add trace on PL
Modified: integration-tests/trunk/common-dist/files/standalone.xml
===================================================================
--- integration-tests/trunk/common-dist/files/standalone.xml 2012-02-24 21:20:43 UTC (rev 1442)
+++ integration-tests/trunk/common-dist/files/standalone.xml 2012-02-27 18:25:49 UTC (rev 1443)
@@ -60,6 +60,7 @@
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE">
+ <level name="TRACE"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
@@ -82,6 +83,9 @@
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
+ <logger category="org.picketlink">
+ <level name="TRACE"/>
+ </logger>
<root-logger>
<level name="INFO"/>
<handlers>
12 years, 10 months
Picketlink SVN: r1442 - in federation/trunk/picketlink-fed-core/src/test: resources/signatures and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-24 16:20:43 -0500 (Fri, 24 Feb 2012)
New Revision: 1442
Added:
federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml11assertion.xml
Removed:
federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java
Log:
change file name
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java 2012-02-24 21:18:50 UTC (rev 1441)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java 2012-02-24 21:20:43 UTC (rev 1442)
@@ -90,7 +90,7 @@
@Test
public void testSAML2Assertion() throws Exception
{
- String fileName = "signatures/saml2assertion.xml";
+ String fileName = "signatures/saml11assertion.xml";
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
InputStream is = tcl.getResourceAsStream(fileName);
if (is == null)
@@ -103,10 +103,8 @@
KeyPair keyPair = KeyStoreUtil.generateKeyPair("RSA");
Element tokenElement = (Element) rstrDocument.getFirstChild();
+ rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1, signatureMethod, "");
- rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1, signatureMethod, "#"
- + tokenElement.getAttribute("ID"));
-
assertNotNull(rstrDocument);
System.out.println(DocumentUtil.asString(rstrDocument));
Added: federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml11assertion.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml11assertion.xml (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml11assertion.xml 2012-02-24 21:20:43 UTC (rev 1442)
@@ -0,0 +1,17 @@
+<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
+ AssertionID="ID_4756863b-eb25-4572-935f-af4ccc8a34ac" IssueInstant="2012-02-24T15:57:15.975Z"
+ Issuer="PicketLinkSTS" MajorVersion="1" MinorVersion="1">
+ <saml:Conditions NotBefore="2012-02-24T15:57:15.975Z"
+ NotOnOrAfter="2012-02-24T17:57:15.975Z" />
+ <saml:AuthenticationStatement
+ AuthenticationInstant="2012-02-24T15:57:15.975Z" AuthenticationMethod="urn:picketlink:auth">
+ <saml:Subject>
+ <saml:NameIdentifier
+ Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">admin</saml:NameIdentifier>
+ <saml:SubjectConfirmation>
+ <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer
+ </saml:ConfirmationMethod>
+ </saml:SubjectConfirmation>
+ </saml:Subject>
+ </saml:AuthenticationStatement>
+</saml:Assertion>
\ No newline at end of file
Deleted: federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml 2012-02-24 21:18:50 UTC (rev 1441)
+++ federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml 2012-02-24 21:20:43 UTC (rev 1442)
@@ -1,17 +0,0 @@
-<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
- AssertionID="ID_4756863b-eb25-4572-935f-af4ccc8a34ac" IssueInstant="2012-02-24T15:57:15.975Z"
- Issuer="PicketLinkSTS" MajorVersion="1" MinorVersion="1">
- <saml:Conditions NotBefore="2012-02-24T15:57:15.975Z"
- NotOnOrAfter="2012-02-24T17:57:15.975Z" />
- <saml:AuthenticationStatement
- AuthenticationInstant="2012-02-24T15:57:15.975Z" AuthenticationMethod="urn:picketlink:auth">
- <saml:Subject>
- <saml:NameIdentifier
- Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">admin</saml:NameIdentifier>
- <saml:SubjectConfirmation>
- <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer
- </saml:ConfirmationMethod>
- </saml:SubjectConfirmation>
- </saml:Subject>
- </saml:AuthenticationStatement>
-</saml:Assertion>
\ No newline at end of file
12 years, 10 months
Picketlink SVN: r1441 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-24 16:18:50 -0500 (Fri, 24 Feb 2012)
New Revision: 1441
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/StandardRequestHandler.java
Log:
PLFED-267: use empty reference uri
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/StandardRequestHandler.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/StandardRequestHandler.java 2012-02-24 19:10:05 UTC (rev 1440)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/StandardRequestHandler.java 2012-02-24 21:18:50 UTC (rev 1441)
@@ -617,8 +617,10 @@
// Set the CanonicalizationMethod if any
XMLSignatureUtil.setCanonicalizationMethodType(configuration.getXMLDSigCanonicalizationMethod());
+ /*rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1,
+ signatureMethod, "#" + tokenElement.getAttribute("ID"));*/
rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1,
- signatureMethod, "#" + tokenElement.getAttribute("ID"));
+ signatureMethod, "");
if (trace)
{
try
12 years, 10 months
Picketlink SVN: r1440 - in federation/trunk/picketlink-fed-core/src/test: resources and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2012-02-24 14:10:05 -0500 (Fri, 24 Feb 2012)
New Revision: 1440
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/resources/signatures/
federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml
federation/trunk/picketlink-fed-core/src/test/resources/signatures/wstRequestCollection.xml
Log:
testcase for XMLSignatureUtil
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLSignatureUtilUnitTestCase.java 2012-02-24 19:10:05 UTC (rev 1440)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.security.KeyPair;
+
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.SignatureMethod;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.core.util.KeyStoreUtil;
+import org.picketlink.identity.federation.core.util.XMLSignatureUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Unit test the {@link XMLSignatureUtil}
+ * @author Anil Saldhana
+ * @since Feb 24, 2012
+ */
+public class XMLSignatureUtilUnitTestCase
+{
+ @Test
+ public void testSigningWSTRequestCollection() throws Exception
+ {
+ String fileName = "signatures/wstRequestCollection.xml";
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = tcl.getResourceAsStream(fileName);
+ if (is == null)
+ throw new RuntimeException("InputStream is null");
+
+ Document rstrDocument = DocumentUtil.getDocument(is);
+ assertNotNull(rstrDocument);
+
+ Node rst = rstrDocument.getElementsByTagNameNS(WSTrustConstants.BASE_NAMESPACE, "RequestedSecurityToken").item(0);
+ Element tokenElement = null;
+ NodeList childNodes = rst.getChildNodes();
+
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node theNode = childNodes.item(i);
+ if (theNode instanceof Element)
+ {
+ tokenElement = (Element) theNode;
+ break;
+ }
+ }
+
+ String signatureMethod = SignatureMethod.RSA_SHA1;
+ KeyPair keyPair = KeyStoreUtil.generateKeyPair("RSA");
+
+ rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1, signatureMethod, "#"
+ + tokenElement.getAttribute("ID"));
+
+ assertNotNull(rstrDocument);
+
+ System.out.println(DocumentUtil.asString(rstrDocument));
+
+ assertTrue(XMLSignatureUtil.validate(rstrDocument, keyPair.getPublic()));
+ }
+
+ @Test
+ public void testSAML2Assertion() throws Exception
+ {
+ String fileName = "signatures/saml2assertion.xml";
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = tcl.getResourceAsStream(fileName);
+ if (is == null)
+ throw new RuntimeException("InputStream is null");
+
+ Document rstrDocument = DocumentUtil.getDocument(is);
+ assertNotNull(rstrDocument);
+
+ String signatureMethod = SignatureMethod.RSA_SHA1;
+ KeyPair keyPair = KeyStoreUtil.generateKeyPair("RSA");
+
+ Element tokenElement = (Element) rstrDocument.getFirstChild();
+
+ rstrDocument = XMLSignatureUtil.sign(rstrDocument, tokenElement, keyPair, DigestMethod.SHA1, signatureMethod, "#"
+ + tokenElement.getAttribute("ID"));
+
+ assertNotNull(rstrDocument);
+
+ System.out.println(DocumentUtil.asString(rstrDocument));
+
+ assertTrue(XMLSignatureUtil.validate(rstrDocument, keyPair.getPublic()));
+ }
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/signatures/saml2assertion.xml 2012-02-24 19:10:05 UTC (rev 1440)
@@ -0,0 +1,17 @@
+<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
+ AssertionID="ID_4756863b-eb25-4572-935f-af4ccc8a34ac" IssueInstant="2012-02-24T15:57:15.975Z"
+ Issuer="PicketLinkSTS" MajorVersion="1" MinorVersion="1">
+ <saml:Conditions NotBefore="2012-02-24T15:57:15.975Z"
+ NotOnOrAfter="2012-02-24T17:57:15.975Z" />
+ <saml:AuthenticationStatement
+ AuthenticationInstant="2012-02-24T15:57:15.975Z" AuthenticationMethod="urn:picketlink:auth">
+ <saml:Subject>
+ <saml:NameIdentifier
+ Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">admin</saml:NameIdentifier>
+ <saml:SubjectConfirmation>
+ <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer
+ </saml:ConfirmationMethod>
+ </saml:SubjectConfirmation>
+ </saml:Subject>
+ </saml:AuthenticationStatement>
+</saml:Assertion>
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/test/resources/signatures/wstRequestCollection.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/signatures/wstRequestCollection.xml (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/signatures/wstRequestCollection.xml 2012-02-24 19:10:05 UTC (rev 1440)
@@ -0,0 +1,47 @@
+<wst:RequestSecurityTokenResponseCollection
+ xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
+ <wst:RequestSecurityTokenResponse
+ Context="default-context">
+ <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1
+ </wst:TokenType>
+ <wst:Lifetime>
+ <wsu:Created
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit...">2012-02-24T15:57:15.975Z</wsu:Created>
+ <wsu:Expires
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit...">2012-02-24T17:57:15.975Z</wsu:Expires>
+ </wst:Lifetime>
+ <wst:KeySize>128</wst:KeySize>
+ <wst:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
+ </wst:KeyType>
+ <wst:RequestedSecurityToken>
+ <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
+ AssertionID="ID_4756863b-eb25-4572-935f-af4ccc8a34ac" IssueInstant="2012-02-24T15:57:15.975Z"
+ Issuer="PicketLinkSTS" MajorVersion="1" MinorVersion="1">
+ <saml:Conditions NotBefore="2012-02-24T15:57:15.975Z"
+ NotOnOrAfter="2012-02-24T17:57:15.975Z" />
+ <saml:AuthenticationStatement
+ AuthenticationInstant="2012-02-24T15:57:15.975Z"
+ AuthenticationMethod="urn:picketlink:auth">
+ <saml:Subject>
+ <saml:NameIdentifier
+ Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">admin</saml:NameIdentifier>
+ <saml:SubjectConfirmation>
+ <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer
+ </saml:ConfirmationMethod>
+ </saml:SubjectConfirmation>
+ </saml:Subject>
+ </saml:AuthenticationStatement>
+ </saml:Assertion>
+ </wst:RequestedSecurityToken>
+ <wst:RequestedAttachedReference>
+ <wsse:SecurityTokenReference
+ xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
+ xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"
+ wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1">
+ <wsse:KeyIdentifier
+ ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAsser...">#ID_4756863b-eb25-4572-935f-af4ccc8a34ac
+ </wsse:KeyIdentifier>
+ </wsse:SecurityTokenReference>
+ </wst:RequestedAttachedReference>
+ </wst:RequestSecurityTokenResponse>
+</wst:RequestSecurityTokenResponseCollection>
\ No newline at end of file
12 years, 10 months