[jboss-svn-commits] JBL Code SVN: r29456 - in labs/jbossesb/workspace/dbevenius/saml_support/product: rosetta/src/org/jboss/soa/esb/services/security/auth/login and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 24 11:08:45 EDT 2009
Author: beve
Date: 2009-09-24 11:08:45 -0400 (Thu, 24 Sep 2009)
New Revision: 29456
Added:
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlCredential.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlCredentialUnitTest.java
Removed:
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java
Modified:
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlAssertionExtractor.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java
labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java
labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java
Log:
Minor refactoring and add more javadocs content.
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -21,6 +21,8 @@
package org.jboss.soa.esb.actions.security;
import java.io.Serializable;
+import java.util.Collections;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.jboss.identity.federation.api.wstrust.WSTrustClient;
@@ -40,14 +42,19 @@
import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
import org.jboss.soa.esb.services.security.auth.login.SamlContext;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
import org.w3c.dom.Element;
-
/**
* This action support issueing SAML Assertions using JBossSTS (Security Token Service).
* <p/>
*
+ * This action simulates the actions that a web service client would take to request that STS issue a security
+ * token that can be used to access a web service.
+ * When making the request to STS, the client can use WS-Security or transport-layer mechanisms to identify itself. In
+ * the current implementation we are using WS-Security to authenicate using UsernameToken. This is simple username/passwd
+ * which is configured in the jboss-sts-client.properites file.
+ *
* Usage:
* <pre>{@code
* <action name="issueToken" class="org.jboss.soa.esb.actions.security.JBossSTSAction">
@@ -108,7 +115,7 @@
log.debug("SecurityToken valid : " + wsTrustClient.validateToken(assertion));
}
- SamlContext.setContext(new SamlPrincipal(assertion));
+ SamlContext.setContext(new SamlCredential(assertion));
if (addAssertionToEsbAuthRequest)
{
@@ -124,11 +131,12 @@
private void addToEsbAuthRequest(final Element assertion, final Message message) throws ActionProcessingException
{
- final SamlPrincipal samlPrincipal = new SamlPrincipal(assertion);
- final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(samlPrincipal).build();
+ final SamlCredential samlCredential = new SamlCredential(assertion);
+ Set credentials = Collections.singleton(samlCredential);
+ final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(null, credentials).build();
try
{
- log.debug("Adding SamlPrincipal to ESB Context as an AuthenticationRequest");
+ log.debug("Adding SamlCredential to ESB Context as an AuthenticationRequest");
message.getContext().setContext(SecurityService.AUTH_REQUEST, PublicCryptoUtil.INSTANCE.encrypt((Serializable) authRequest));
}
catch (final SecurityServiceException e)
@@ -149,6 +157,4 @@
}
}
-
-
}
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -21,8 +21,8 @@
package org.jboss.soa.esb.services.security.auth.login;
import java.io.IOException;
-import java.security.Principal;
import java.util.Map;
+import java.util.Set;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
@@ -30,7 +30,6 @@
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.jboss.identity.federation.api.wstrust.WSTrustClient;
@@ -38,8 +37,6 @@
import org.jboss.identity.federation.api.wstrust.WSTrustClientFactory;
import org.jboss.identity.federation.core.exceptions.ParsingException;
import org.jboss.identity.federation.core.wstrust.WSTrustException;
-import org.jboss.identity.federation.core.wstrust.plugins.saml.SAMLUtil;
-import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
import org.jboss.security.auth.callback.ObjectCallback;
import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
import org.w3c.dom.Element;
@@ -196,11 +193,14 @@
throw new LoginException("Could not locate a AuthenticationRequest from the callback.");
}
- final Principal principal = authRequest.getPrincipal();
- if (principal instanceof SamlPrincipal)
+ Set<?> credentials = authRequest.getCredentials();
+ for (Object object : credentials)
{
- final SamlPrincipal samlPrincipal = (SamlPrincipal) principal;
- return samlPrincipal.getAssertionElement();
+ if (object instanceof SamlCredential)
+ {
+ final SamlCredential samlCredential = (SamlCredential) object;
+ return samlCredential.getAssertionElement();
+ }
}
throw new LoginException("Could not locate a SamplPrincipal in the AuthenticationRequest.");
@@ -213,7 +213,7 @@
logger.debug("Successfully validated Assertion. ");
// Add the SamlToken to the authenticated Subjects principals
- subject.getPrincipals().add(new SamlPrincipal(samlToken));
+ subject.getPublicCredentials().add(new SamlCredential(samlToken));
return true;
}
@@ -243,7 +243,7 @@
private void clearState()
{
samlToken = null;
- subject.getPrincipals(SamlPrincipal.class).clear();
+ subject.getPublicCredentials(SamlCredential.class).clear();
}
}
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -20,7 +20,7 @@
*/
package org.jboss.soa.esb.services.security.auth.login;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
/**
*
@@ -29,7 +29,7 @@
*/
public final class SamlContext
{
- private static final ThreadLocal<SamlPrincipal> CONTEXT = new ThreadLocal<SamlPrincipal>();
+ private static final ThreadLocal<SamlCredential> CONTEXT = new ThreadLocal<SamlCredential>();
private SamlContext() {}
@@ -38,12 +38,12 @@
CONTEXT.set(null);
}
- public static SamlPrincipal getContext()
+ public static SamlCredential getContext()
{
return CONTEXT.get();
}
- public static void setContext(final SamlPrincipal principal)
+ public static void setContext(final SamlCredential principal)
{
CONTEXT.set(principal);
}
Copied: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlCredential.java (from rev 29400, labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java)
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlCredential.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlCredential.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * 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.soa.esb.services.security.auth.login;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.security.Principal;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.services.security.SecurityServiceException;
+import org.jboss.util.xml.DOMUtils;
+import org.w3c.dom.Element;
+
+/**
+ * Credential that wraps a SAML Assertion.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public final class SamlCredential implements Serializable
+{
+ private static final long serialVersionUID = -8496414959425288835L;
+
+ private String assertion;
+
+ public SamlCredential(final Element assertion)
+ {
+ this.assertion = SamlCredential.assertionToString(assertion);
+ }
+
+ public SamlCredential(final String assertion)
+ {
+ AssertArgument.isNotNull(assertion, "assertion");
+ this.assertion = assertion;
+ }
+
+ public String getName()
+ {
+ return "SamlCredential";
+ }
+
+ public String getAssertion()
+ {
+ return assertion;
+ }
+
+ public Element getAssertionElement() throws IOException
+ {
+ return SamlCredential.assertionToElement(assertion);
+ }
+
+ public static Element assertionToElement(final String assertion) throws IOException
+ {
+ return DOMUtils.parse(assertion);
+ }
+
+ public static String assertionToString(final Element assertion)
+ {
+ AssertArgument.isNotNull(assertion, "assertion");
+ try
+ {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ final Source source = new DOMSource(assertion);
+ final StringWriter writer = new StringWriter();
+ final Result result = new StreamResult(writer);
+
+ transformer.transform(source, result);
+
+ return writer.toString();
+ }
+ catch (TransformerConfigurationException e)
+ {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ catch (TransformerFactoryConfigurationError e)
+ {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ catch (TransformerException e)
+ {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+}
Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * 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.soa.esb.services.security.auth.login;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.security.Principal;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-import org.jboss.soa.esb.services.security.SecurityServiceException;
-import org.jboss.util.xml.DOMUtils;
-import org.w3c.dom.Element;
-
-/**
- * Principal that wraps a SAML Assertion.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public final class SamlPrincipal implements Principal, Serializable
-{
- private static final long serialVersionUID = -8496414959425288835L;
-
- private String assertion;
-
- public SamlPrincipal(final Element assertion)
- {
- this.assertion = SamlPrincipal.assertionToString(assertion);
- }
-
- public SamlPrincipal(final String assertion)
- {
- AssertArgument.isNotNull(assertion, "assertion");
- this.assertion = assertion;
- }
-
- public String getName()
- {
- return "SamlPrincipal";
- }
-
- public String getAssertion()
- {
- return assertion;
- }
-
- public Element getAssertionElement() throws IOException
- {
- return SamlPrincipal.assertionToElement(assertion);
- }
-
- public static Element assertionToElement(final String assertion) throws IOException
- {
- return DOMUtils.parse(assertion);
- }
-
- public static String assertionToString(final Element assertion)
- {
- AssertArgument.isNotNull(assertion, "assertion");
- try
- {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- final Source source = new DOMSource(assertion);
- final StringWriter writer = new StringWriter();
- final Result result = new StreamResult(writer);
-
- transformer.transform(source, result);
-
- return writer.toString();
- }
- catch (TransformerConfigurationException e)
- {
- throw new IllegalStateException(e.getMessage(), e);
- }
- catch (TransformerFactoryConfigurationError e)
- {
- throw new IllegalStateException(e.getMessage(), e);
- }
- catch (TransformerException e)
- {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-}
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlAssertionExtractor.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlAssertionExtractor.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlAssertionExtractor.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -23,6 +23,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+import java.util.Collections;
+import java.util.Set;
import javax.xml.transform.stream.StreamSource;
@@ -30,7 +32,7 @@
import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
import org.jboss.soa.esb.services.security.auth.SecurityInfoExtractor;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
import org.jboss.soa.esb.smooks.resource.SmooksResource;
import org.jboss.soa.esb.util.ClassUtil;
import org.milyn.Smooks;
@@ -40,6 +42,7 @@
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+
/**
* Extracts SAML Assertions from a SOAP Message. </p>
*
@@ -110,7 +113,8 @@
if (samlToken != null)
{
- return new AuthenticationRequestImpl.Builder(new SamlPrincipal((Element) samlToken), null).build();
+ Set credential = Collections.singleton(new SamlCredential((Element)samlToken));
+ return new AuthenticationRequestImpl.Builder(null, credential).build();
}
else
{
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -21,7 +21,7 @@
package org.jboss.soa.esb.services.security.auth.ws;
import org.jboss.soa.esb.services.security.auth.login.SamlContext;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
/**
* Extends {@link SOAPSecurityHeaderVisitor} to add a SAML Assertion
@@ -35,7 +35,7 @@
@Override
protected String getHeaderToInsert()
{
- SamlPrincipal samlPrincipal = SamlContext.getContext();
+ SamlCredential samlPrincipal = SamlContext.getContext();
if (samlPrincipal != null)
{
return samlPrincipal.getAssertion();
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -25,8 +25,10 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
@@ -61,8 +63,9 @@
final Element samlToken = createSamlToken();
final JBossSTSCallbackHandler callbackHandler = new JBossSTSCallbackHandler();
- final SamlPrincipal samlPrincipal = new SamlPrincipal(samlToken);
- final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(samlPrincipal, null).build();
+ final SamlCredential samlCredential = new SamlCredential(samlToken);
+ Set credential = Collections.singleton(samlCredential);
+ final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(null, credential).build();
callbackHandler.setAuthenticationRequest(authRequest);
callbackHandler.setSecurityConfig(null);
@@ -88,8 +91,9 @@
final Element samlToken = createSamlToken();
final JBossSTSCallbackHandler callbackHandler = new JBossSTSCallbackHandler();
- final SamlPrincipal samlPrincipal = new SamlPrincipal(samlToken);
- final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(samlPrincipal, null).build();
+ final SamlCredential samlCredential = new SamlCredential(samlToken);
+ Set credential = Collections.singleton(samlCredential);
+ final AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(null, credential).build();
callbackHandler.setAuthenticationRequest(authRequest);
callbackHandler.setSecurityConfig(null);
Copied: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlCredentialUnitTest.java (from rev 29400, labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java)
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlCredentialUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlCredentialUnitTest.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * 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.soa.esb.services.security.auth.login;
+
+import java.io.IOException;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.services.security.SecurityServiceException;
+import org.jboss.util.xml.DOMUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Unit test for {@link SamlCredential}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class SamlCredentialUnitTest
+{
+ @BeforeClass
+ public static void setup()
+ {
+ XMLUnit.setIgnoreWhitespace( true );
+ }
+
+ @Test
+ public void stringConstructor() throws IOException, SecurityServiceException, SAXException
+ {
+ final SamlCredential samlPrincipal = new SamlCredential(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
+ final Document expected = XMLUnit.buildControlDocument(new InputSource(getClass().getResourceAsStream("assertion-expected.xml")));
+ final Document actual = XMLUnit.buildTestDocument(samlPrincipal.getAssertion());
+
+ XMLAssert.assertXMLEqual(expected, actual);
+ }
+
+ @Test
+ public void elementConstructor() throws IOException, SecurityServiceException, SAXException
+ {
+ final Element assertionElement = DOMUtils.parse(getClass().getResourceAsStream("assertion.xml"));
+ final String expectedAssertion = SamlCredential.assertionToString(assertionElement);
+
+ final SamlCredential samlPrincipal = new SamlCredential(assertionElement);
+ final String actualAssertion = samlPrincipal.getAssertion();
+
+ XMLAssert.assertXMLEqual(expectedAssertion, actualAssertion);
+ }
+
+ @Test (expected = IllegalArgumentException.class)
+ public void shoudThrowIfStringIsNull()
+ {
+ new SamlCredential((String)null);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(SamlCredentialUnitTest.class);
+ }
+
+}
Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * 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.soa.esb.services.security.auth.login;
-
-import java.io.IOException;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.soa.esb.services.security.SecurityServiceException;
-import org.jboss.util.xml.DOMUtils;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Unit test for {@link SamlPrincipal}.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class SamlPrincipalUnitTest
-{
- @BeforeClass
- public static void setup()
- {
- XMLUnit.setIgnoreWhitespace( true );
- }
-
- @Test
- public void stringConstructor() throws IOException, SecurityServiceException, SAXException
- {
- final SamlPrincipal samlPrincipal = new SamlPrincipal(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
- final Document expected = XMLUnit.buildControlDocument(new InputSource(getClass().getResourceAsStream("assertion-expected.xml")));
- final Document actual = XMLUnit.buildTestDocument(samlPrincipal.getAssertion());
-
- XMLAssert.assertXMLEqual(expected, actual);
- }
-
- @Test
- public void elementConstructor() throws IOException, SecurityServiceException, SAXException
- {
- final Element assertionElement = DOMUtils.parse(getClass().getResourceAsStream("assertion.xml"));
- final String expectedAssertion = SamlPrincipal.assertionToString(assertionElement);
-
- final SamlPrincipal samlPrincipal = new SamlPrincipal(assertionElement);
- final String actualAssertion = samlPrincipal.getAssertion();
-
- XMLAssert.assertXMLEqual(expectedAssertion, actualAssertion);
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void shoudThrowIfStringIsNull()
- {
- new SamlPrincipal((String)null);
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(SamlPrincipalUnitTest.class);
- }
-
-}
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -26,7 +26,7 @@
import org.custommonkey.xmlunit.XMLUnit;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.services.security.auth.login.SamlContext;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -56,7 +56,7 @@
final StringSource source = new StringSource("<Envelope><Header>" + SECURITY_START + "</t:Security></Header></Envelope>");
final StringResult result = new StringResult();
- final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
SamlContext.setContext(samlPrincipal);
smooks.filterSource(source, result);
@@ -96,7 +96,7 @@
final StringSource source = new StringSource(soap);
final StringResult result = new StringResult();
- final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
SamlContext.setContext(samlPrincipal);
smooks.filterSource(source, result);
@@ -115,7 +115,7 @@
final StringSource source = new StringSource(soap);
final StringResult result = new StringResult();
- final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
SamlContext.setContext(samlPrincipal);
smooks.filterSource(source, result);
@@ -134,7 +134,7 @@
final StringSource source = new StringSource(soap);
final StringResult result = new StringResult();
- final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
SamlContext.setContext(samlPrincipal);
smooks.filterSource(source, result);
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -31,7 +31,7 @@
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.jboss.soa.esb.services.security.auth.login.SamlContext;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
import org.w3c.dom.Element;
/**
@@ -54,7 +54,7 @@
try
{
- final SamlPrincipal samlPrincipal = SamlContext.getContext();
+ final SamlCredential samlPrincipal = SamlContext.getContext();
if (samlPrincipal != null)
{
final Element assertionElement = samlPrincipal.getAssertionElement();
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java 2009-09-24 13:41:14 UTC (rev 29455)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java 2009-09-24 15:08:45 UTC (rev 29456)
@@ -42,7 +42,7 @@
import org.custommonkey.xmlunit.XMLUnit;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.services.security.auth.login.SamlContext;
-import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.jboss.soa.esb.services.security.auth.login.SamlCredential;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -74,7 +74,7 @@
when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(true);
when(messageContext.getMessage()).thenReturn(soapMessage);
- SamlPrincipal samlPrincipal = new SamlPrincipal(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
+ SamlCredential samlPrincipal = new SamlCredential(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
SamlContext.setContext(samlPrincipal);
boolean result = handler.handleMessage(messageContext);
@@ -91,7 +91,7 @@
{
final SOAPElement assertionElement = assertions.next();
final Document expected = XMLUnit.buildControlDocument(samlPrincipal.getAssertion());
- final Document actual = XMLUnit.buildTestDocument(SamlPrincipal.assertionToString(assertionElement));
+ final Document actual = XMLUnit.buildTestDocument(SamlCredential.assertionToString(assertionElement));
XMLAssert.assertXMLEqual(expected, actual);
}
}
More information about the jboss-svn-commits
mailing list