Author: anil.saldhana(a)jboss.com
Date: 2008-12-09 11:10:21 -0500 (Tue, 09 Dec 2008)
New Revision: 127
Added:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/v2/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/v2/SAML2AuthnRequestUnitTestCase.java
identity-federation/trunk/identity-opensaml/src/test/resources/saml/
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestExample.xml
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestWithSignature.xml
Modified:
identity-federation/trunk/identity-opensaml/src/test/
identity-federation/trunk/identity-opensaml/src/test/java/
identity-federation/trunk/identity-opensaml/src/test/java/org/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/opensaml/
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/opensaml/saml2/
identity-federation/trunk/identity-opensaml/src/test/resources/
identity-federation/trunk/identity-opensaml/src/test/resources/endorsed/
Log:
tests
Property changes on: identity-federation/trunk/identity-opensaml/src/test
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on: identity-federation/trunk/identity-opensaml/src/test/java
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on: identity-federation/trunk/identity-opensaml/src/test/java/org
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on: identity-federation/trunk/identity-opensaml/src/test/java/org/jboss
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/opensaml
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/opensaml/saml2
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Added:
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/v2/SAML2AuthnRequestUnitTestCase.java
===================================================================
---
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/v2/SAML2AuthnRequestUnitTestCase.java
(rev 0)
+++
identity-federation/trunk/identity-opensaml/src/test/java/org/jboss/test/identity/federation/saml/v2/SAML2AuthnRequestUnitTestCase.java 2008-12-09
16:10:21 UTC (rev 127)
@@ -0,0 +1,105 @@
+/*
+ * 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.jboss.test.identity.federation.saml.v2;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import junit.framework.TestCase;
+
+import org.jboss.identity.federation.saml.v2.assertion.AudienceRestrictionType;
+import org.jboss.identity.federation.saml.v2.assertion.ConditionAbstractType;
+import org.jboss.identity.federation.saml.v2.assertion.ConditionsType;
+import org.jboss.identity.federation.saml.v2.assertion.NameIDType;
+import org.jboss.identity.federation.saml.v2.assertion.SubjectType;
+import org.jboss.identity.federation.saml.v2.factories.JBossSAMLAuthnRequestFactory;
+import org.jboss.identity.federation.saml.v2.protocol.AuthnRequestType;
+import org.jboss.identity.federation.saml.v2.protocol.RequestedAuthnContextType;
+import org.jboss.identity.federation.w3.xmldsig.SignatureType;
+
+
+
+/**
+ * Unit test the SAML2 Authn Request Context constructs
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Dec 8, 2008
+ */
+public class SAML2AuthnRequestUnitTestCase extends TestCase
+{
+ /**
+ * Test reading a saml2 authn request
+ * @throws Exception
+ */
+ public void testAuthnRequestExample() throws Exception
+ {
+ String resourceName =
"saml/v2/authnrequest/samlAuthnRequestExample.xml";
+
+ AuthnRequestType authnRequestType =
JBossSAMLAuthnRequestFactory.getAuthnRequestType(resourceName);
+
+
assertEquals("http://www.example.com/",
authnRequestType.getDestination());
+ assertEquals("urn:oasis:names:tc:SAML:2.0:consent:obtained",
authnRequestType.getConsent());
+
assertEquals("http://www.example.com/",authnRequestType.getAsse...;
+ assertEquals(Integer.valueOf("0"),
authnRequestType.getAttributeConsumingServiceIndex());
+
+ SubjectType subjectType = authnRequestType.getSubject();
+ assertNotNull(subjectType);
+
+ List<JAXBElement<?>> subjectContentList = subjectType.getContent();
+ JAXBElement<?> elem1 = subjectContentList.get(0);
+ NameIDType nameIDType = (NameIDType) elem1.getValue();
+
+
assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",nameIDType.getFormat());
+ assertEquals("j.doe(a)company.com",nameIDType.getValue());
+
+ ConditionsType conditionsType = authnRequestType.getConditions();
+ List<ConditionAbstractType> conditions =
conditionsType.getConditionOrAudienceRestrictionOrOneTimeUse();
+ assertTrue(conditions.size() == 1);
+
+ ConditionAbstractType condition = conditions.get(0);
+ assertTrue(condition instanceof AudienceRestrictionType);
+ AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType)
condition;
+ List<String> audiences = audienceRestrictionType.getAudience();
+ assertTrue(audiences.size() == 1);
+ assertEquals("urn:foo:sp.example.org", audiences.get(0));
+
+ RequestedAuthnContextType requestedAuthnContext =
authnRequestType.getRequestedAuthnContext();
+ assertEquals(
"urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
+ ,requestedAuthnContext.getAuthnContextClassRef().get(0));
+ }
+
+ /**
+ * Test reading a saml authn request from a file that
+ * contains a digital signature
+ * @throws Exception
+ */
+ public void testAuthnRequestWithSignature() throws Exception
+ {
+ String resourceName =
"saml/v2/authnrequest/samlAuthnRequestWithSignature.xml";
+
+ AuthnRequestType authnRequestType =
JBossSAMLAuthnRequestFactory.getAuthnRequestType(resourceName);
+ assertNotNull(authnRequestType);
+
+ SignatureType signatureType = authnRequestType.getSignature();
+ assertNotNull("Signature is not null", signatureType);
+ }
+}
\ No newline at end of file
Property changes on: identity-federation/trunk/identity-opensaml/src/test/resources
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/resources/endorsed
___________________________________________________________________
Name: svn:ignore
- target
+ target
target-eclipse .settings eclipse-target
Added:
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestExample.xml
===================================================================
(Binary files differ)
Property changes on:
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestExample.xml
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestWithSignature.xml
===================================================================
---
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestWithSignature.xml
(rev 0)
+++
identity-federation/trunk/identity-opensaml/src/test/resources/saml/v2/authnrequest/samlAuthnRequestWithSignature.xml 2008-12-09
16:10:21 UTC (rev 127)
@@ -0,0 +1,68 @@
+<!-- Picked up from
http://wiki.eclipse.org/SAML2_IdP_Overview -->
+<samlp:AuthnRequest
+ AssertionConsumerServiceURL="http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint"
+ Destination="http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint"
+ ID="a2sffdlgdhgfg32fdldsdghdsgdgfdglgx"
+ IssueInstant="2007-12-17T18:40:52.203Z"
+ ProtocolBinding="urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect"
+ ProviderName="Test SAML2 SP" Version="2.0"
+ xmlns="urn:oasis:names:tc:SAML:2.0:assertion"
+ xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
+
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+
+ <Issuer>Test SAML2 SP</Issuer>
+
+ <Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
+ <SignedInfo>
+ <CanonicalizationMethod
+
Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComme...
/>
+ <SignatureMethod
+
Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1" />
+ <Reference URI="#ccocfkmlnocbajegpiheahonbcambbapiibggije">
+ <Transforms>
+ <Transform
+
Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
+ </Transforms>
+ <DigestMethod
+
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
+ <DigestValue>N1Aze93QqDxax3cmBgPmKFNdM8U=</DigestValue>
+ </Reference>
+ </SignedInfo>
+ <SignatureValue>
+ KjfZwX9RkNrr3Epo/yRfDiFhqBeJCO5lFe/Ni/leBvBH8FRCT3p+2w==
+ </SignatureValue>
+ <KeyInfo>
+ <KeyValue>
+ <DSAKeyValue>
+ <P>
+ vzIPsacspz2XUcXP0hmWx2u56y9t/nTZRKGyFcVi1K/bao0C+0KjvXKkAPNhBb9TzYsCZbtZNH3a
+ OSVvsw1XVYHCeneHAircY/oJ0BqfBBg4gQe1H/CPXwixI+zjBSF5pMOBq4etcsH+SD/JYj1NsRwn
+ /2yQccUjUKeapbHn8TVNwVRYwg5QZL9AQ4b/pGoqO+df3kIqUL7lVyW+l6XprtVQU9jen47c4KQ1
+ sodHHPwgoXmT27hLAedC0cu4UUYFjwgbEoS1UBUoNajmGFNFeMpEtj1j4cHRoiZIxwYgEqzanp2f
+ Lgq7LlMa07vIuZBk6jyrw77Mza7TqxFNoVO89w==
+ </P>
+ <Q>j/ukaZe37ncVwe4c/+GQex1Kqic=</Q>
+ <G>
+ fu8RMe0ijgLi4Pw/KY57HdIBjmBge4XG1fX8IoT2wxv4QFO+FmijCqCcOiWk3osVyJIjqGJyH4kq
+ RwvSZl6pd8FAdP1HfZDMwBP9ML6NpE5WAe+MP+b3ydoUqI25JqCS2H9DypUIHxqN+NaLTDm67O9m
+ tTSckEMbXiARccwgnEgyNCFFulmm8vh8L6iT+56pesCyykMp6PDDo8AI2U9SR5EzUAQe5Yl39fCp
+ lb7H+tbOBclal00OUXezRGNh5c6JlM5J6YpY/gll2D0nv3VtubVOlc104LIpvFzphF7x5hv5HvI+
+ jUemrFIx0I8C3lv+8Xndwe8YwszLRrxvNe0jPQ==
+ </G>
+ <Y>
+ vM9EhHB8cKakhExdDZ/1pnWFeZOBKgC/c1/OoY1wGh4yAz5zDkkZPg/dXpEOkWuz241WXipcUbym
+ L+lZXcT+bTs8CQdIkw738vopoJfT0r75fKd85lT1pRH/nQ4i82J+vHrqOrfFc5CryxxqCRkZP4DW
+ B5t62LBoIMMsrdsMVKpzCJmUgnnIY8B4maJe2BYVRBBhISGoBnTKSWxObUg30fIfRlVFFxtTeWq8
+ tPS9u+MI3HuFn0MPVL+TgBw24ufSWPEEUiZU0eDdjzF51/yTVqUCHYNJH7gG7kugrQ8LdKes7rfD
+ c9glkilm1iAcSCfNvqsktKcN+BCOaCdsQhT5yw==
+ </Y>
+ </DSAKeyValue>
+ </KeyValue>
+ </KeyInfo>
+ </Signature>
+
+ <samlp:NameIDPolicy
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
+ AllowCreate="true"
+ />
+
+</samlp:AuthnRequest>
\ No newline at end of file