[jboss-svn-commits] JBL Code SVN: r29271 - in labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta: tests/src/org/jboss/soa/esb/services/security/auth/login and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 9 04:53:45 EDT 2009
Author: beve
Date: 2009-09-09 04:53:45 -0400 (Wed, 09 Sep 2009)
New Revision: 29271
Added:
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSConstants.java
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/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java
Log:
Added Constants for the configuration options.
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSConstants.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSConstants.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSConstants.java 2009-09-09 08:53:45 UTC (rev 29271)
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JBossSTSConstants
+{
+ public static final String SERVICE_NAME_OPTION = "serviceName";
+ public static final String PORT_NAME_OPTION = "portName";
+ public static final String ENDPOINT_ADDRESS_OPTION = "endpointAddress";
+ public static final String USERNAME_OPTION = "username";
+ public static final String PASSWORD_OPTION = "password";
+ public static final String SAML_TOKEN_TYPE_OPTION = "samlTokenType";
+
+ private JBossSTSConstants()
+ {
+ }
+}
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-09 08:35:23 UTC (rev 29270)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java 2009-09-09 08:53:45 UTC (rev 29271)
@@ -46,6 +46,7 @@
/**
* JAAS LoginModule for JBoss SecurityTokenService (STS).
+ *
* This LoginModule only performs validation of existing SAML
* Assertions and does not issue and such Assertions.
*
@@ -56,16 +57,6 @@
private Logger logger = Logger.getLogger(JBossSTSLoginModule.class);
/**
- * Options for this login module
- */
- public static final String SERVICE_NAME_OPTION = "serviceName";
- public static final String PORT_NAME_OPTION = "portName";
- public static final String ENDPOINT_ADDRESS_OPTION = "endpointAddress";
- public static final String USERNAME_OPTION = "username";
- public static final String PASSWORD_OPTION = "password";
- public static final String SAML_TOKEN_TYPE_OPTION = "samlTokenType";
-
- /**
* The subject to be populated.
*/
private Subject subject;
@@ -76,16 +67,16 @@
private CallbackHandler callbackHandler;
/**
+ * Client that takes care of invoking the SecurityTokenService.
+ */
+ private WSTrustClient wsTrustClient;
+
+ /**
* WS-Trust SAML Assertion element.
*/
private Element samlToken;
/**
- * Client that takes care of invoking the SecurityTokenService.
- */
- private WSTrustClient wsTrustClient;
-
- /**
* The outcome of the authentication process.
*/
private boolean success;
@@ -110,12 +101,12 @@
{
this.subject = subject;
- final String stsServiceName = getRequiredOption(options, SERVICE_NAME_OPTION);
- final String stsPortName = getRequiredOption(options, PORT_NAME_OPTION);
- final String endpointAddress = getRequiredOption(options, ENDPOINT_ADDRESS_OPTION);
+ final String stsServiceName = getRequiredOption(options, JBossSTSConstants.SERVICE_NAME_OPTION);
+ final String stsPortName = getRequiredOption(options, JBossSTSConstants.PORT_NAME_OPTION);
+ final String endpointAddress = getRequiredOption(options, JBossSTSConstants.ENDPOINT_ADDRESS_OPTION);
- final String stsUserName = getRequiredOption(options, USERNAME_OPTION);
- final String stsPassword = getRequiredOption(options, PASSWORD_OPTION);
+ final String stsUserName = getRequiredOption(options, JBossSTSConstants.USERNAME_OPTION);
+ final String stsPassword = getRequiredOption(options, JBossSTSConstants.PASSWORD_OPTION);
if (callbackHandler == null)
{
@@ -164,16 +155,12 @@
{
// See if the AuthenticationRequest has a Saml Token associated with it.
samlToken = getSamlTokenFromCaller();
- if (samlToken == null)
- {
- }
// Verify that the Saml Token is still valid.
success = wsTrustClient.validateToken(samlToken);
if (success == false)
{
- // Throw an exception as returing false only says that this
- // login module should be ignored.
+ // Throw an exception as returing false only says that this login module should be ignored.
throw new LoginException("Could not validate the SAML Security Token :" + samlToken);
}
@@ -200,6 +187,11 @@
callbackHandler.handle(new Callback[] { objectCallback });
final AuthenticationRequest authRequest = (AuthenticationRequest) objectCallback.getCredential();
+ if (authRequest == null)
+ {
+ throw new LoginException("Could not locate a AuthenticationRequest from the callback.");
+ }
+
final Principal principal = authRequest.getPrincipal();
if (principal instanceof SamlPrincipal)
{
@@ -210,7 +202,6 @@
throw new LoginException("Could not locate a SamplPrincipal in the AuthenticationRequest.");
}
-
public boolean commit() throws LoginException
{
try
@@ -260,7 +251,7 @@
private void clearState()
{
samlToken = null;
- subject.getPrincipals().clear();
+ subject.getPrincipals(SamlPrincipal.class).clear();
}
}
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-09 08:35:23 UTC (rev 29270)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java 2009-09-09 08:53:45 UTC (rev 29271)
@@ -108,7 +108,7 @@
public void missingCallbackHanlder()
{
Map<String, String> allOptions = allOptions();
- allOptions.remove(JBossSTSLoginModule.SERVICE_NAME_OPTION);
+ allOptions.remove(JBossSTSConstants.SERVICE_NAME_OPTION);
final JBossSTSLoginModule loginModule = new JBossSTSLoginModule();
loginModule.setWSTrustClient(mock(WSTrustClient.class));
loginModule.initialize(new Subject(), null, null, allOptions());
@@ -117,31 +117,31 @@
@Test (expected = IllegalArgumentException.class)
public void missingServerNameOption()
{
- assertMissingOption(JBossSTSLoginModule.SERVICE_NAME_OPTION);
+ assertMissingOption(JBossSTSConstants.SERVICE_NAME_OPTION);
}
@Test (expected = IllegalArgumentException.class)
public void missingPortNameOption()
{
- assertMissingOption(JBossSTSLoginModule.PORT_NAME_OPTION);
+ assertMissingOption(JBossSTSConstants.PORT_NAME_OPTION);
}
@Test (expected = IllegalArgumentException.class)
public void missingEndpointAddressOption()
{
- assertMissingOption(JBossSTSLoginModule.ENDPOINT_ADDRESS_OPTION);
+ assertMissingOption(JBossSTSConstants.ENDPOINT_ADDRESS_OPTION);
}
@Test (expected = IllegalArgumentException.class)
public void missingUsernameOption()
{
- assertMissingOption(JBossSTSLoginModule.USERNAME_OPTION);
+ assertMissingOption(JBossSTSConstants.USERNAME_OPTION);
}
@Test (expected = IllegalArgumentException.class)
public void missingPasswordOption()
{
- assertMissingOption(JBossSTSLoginModule.PASSWORD_OPTION);
+ assertMissingOption(JBossSTSConstants.PASSWORD_OPTION);
}
private void assertMissingOption(final String optionName)
@@ -187,37 +187,37 @@
public OptionsBuilder serviceName(final String serviceName)
{
- options.put(JBossSTSLoginModule.SERVICE_NAME_OPTION, serviceName);
+ options.put(JBossSTSConstants.SERVICE_NAME_OPTION, serviceName);
return this;
}
public OptionsBuilder portName(final String portName)
{
- options.put(JBossSTSLoginModule.PORT_NAME_OPTION, portName);
+ options.put(JBossSTSConstants.PORT_NAME_OPTION, portName);
return this;
}
public OptionsBuilder endpointAddress(final String address)
{
- options.put(JBossSTSLoginModule.ENDPOINT_ADDRESS_OPTION, address);
+ options.put(JBossSTSConstants.ENDPOINT_ADDRESS_OPTION, address);
return this;
}
public OptionsBuilder username(final String username)
{
- options.put(JBossSTSLoginModule.USERNAME_OPTION, username);
+ options.put(JBossSTSConstants.USERNAME_OPTION, username);
return this;
}
public OptionsBuilder password(final String password)
{
- options.put(JBossSTSLoginModule.PASSWORD_OPTION, password);
+ options.put(JBossSTSConstants.PASSWORD_OPTION, password);
return this;
}
public OptionsBuilder samlTokenType(final String type)
{
- options.put(JBossSTSLoginModule.SAML_TOKEN_TYPE_OPTION, type);
+ options.put(JBossSTSConstants.SAML_TOKEN_TYPE_OPTION, type);
return this;
}
More information about the jboss-svn-commits
mailing list