[jboss-cvs] JBossAS SVN: r73225 - in projects/security/security-jboss-sx/trunk/jbosssx/src: main/org/jboss/security/config and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 9 12:48:44 EDT 2008
Author: sguilhen at redhat.com
Date: 2008-05-09 12:48:44 -0400 (Fri, 09 May 2008)
New Revision: 73225
Modified:
projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/auth/login/XMLLoginConfigImpl.java
projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/config/BaseSecurityInfo.java
projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/WebJASPIAuthMgrUnitTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPILoginModuleDelgateUnitTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPIWorkflowUnitTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/security/identitytrust/IdentityTrustUnitTestCase.java
Log:
Added static getInstance() method to XMLLoginConfigImpl to implement the singleton pattern.
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/auth/login/XMLLoginConfigImpl.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/auth/login/XMLLoginConfigImpl.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/auth/login/XMLLoginConfigImpl.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.security.auth.login;
import java.io.File;
@@ -48,96 +48,112 @@
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
-/** An concrete implementation of the javax.security.auth.login.Configuration
- class that parses an xml configuration of the form:
-
- <policy>
- <application-policy name = "test-domain">
- <authentication>
- <login-module code = "org.jboss.security.plugins.samples.IdentityLoginModule"
- flag = "required">
- <module-option name = "principal">starksm</module-option>
- </login-module>
- </authentication>
- </application-policy>
- </policy>
-
- @see javax.security.auth.login.Configuration
-
- @author Scott.Stark at jboss.org
- @author Anil.Saldhana at jboss.org
- @version $Revision: 57482 $
+/**
+ * An concrete implementation of the javax.security.auth.login.Configuration class that parses an xml configuration of
+ * the form:
+ *
+ * <policy> <application-policy name = "test-domain"> <authentication> <login-module code =
+ * "org.jboss.security.plugins.samples.IdentityLoginModule" flag = "required"> <module-option name = "principal">starksm</module-option>
+ * </login-module> </authentication> </application-policy> </policy>
+ *
+ * @see javax.security.auth.login.Configuration
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at jboss.org
+ * @version $Revision: 57482 $
*/
public class XMLLoginConfigImpl extends Configuration implements Serializable, ApplicationPolicyRegistration
{
/** The serialVersionUID */
private static final long serialVersionUID = -8965860493224188277L;
+
private static final String DEFAULT_APP_CONFIG_NAME = "other";
+
private static final AuthPermission REFRESH_PERM = new AuthPermission("refreshLoginConfiguration");
+
private static Logger log = Logger.getLogger(XMLLoginConfigImpl.class);
- /** A mapping of application name to AppConfigurationEntry[]
- protected Map appConfigs = Collections.synchronizedMap(new HashMap());
- */
+
PolicyConfig appConfigs = new PolicyConfig();
+
/** The URL to the XML or Sun login configuration */
protected URL loginConfigURL;
+
/** The inherited configuration we delegate to */
protected Configuration parentConfig;
+
/** A flag indicating if XML configs should be validated */
private boolean validateDTD = true;
+ private static final XMLLoginConfigImpl instance = new XMLLoginConfigImpl();
+
+ /**
+ * <p>
+ * Obtains a reference to the singleton.
+ * </p>
+ *
+ * @return a reference to the singleton {@code XMLLoginConfigImpl} instance.
+ */
+ public static XMLLoginConfigImpl getInstance()
+ {
+ return instance;
+ }
+
// --- Begin Configuration method overrrides
+ @Override
public void refresh()
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(REFRESH_PERM);
if (log.isTraceEnabled())
- log.trace("Begin refresh");
+ log.trace("Begin refresh");
appConfigs.clear();
loadConfig();
if (log.isTraceEnabled())
- log.trace("End refresh");
+ log.trace("End refresh");
}
+ @Override
public AppConfigurationEntry[] getAppConfigurationEntry(String appName)
{
if (log.isTraceEnabled())
- log.trace("Begin getAppConfigurationEntry("+appName+"), size="+appConfigs.size());
-
- //Load the config if PolicyConfig is empty
- if(this.appConfigs.size() == 0)
+ log.trace("Begin getAppConfigurationEntry(" + appName + "), size=" + appConfigs.size());
+
+ // Load the config if PolicyConfig is empty
+ if (this.appConfigs.size() == 0)
this.loadConfig();
AppConfigurationEntry[] entry = null;
- ApplicationPolicy aPolicy = this.getApplicationPolicy(appName);
+ ApplicationPolicy aPolicy = this.getApplicationPolicy(appName);
AuthenticationInfo authInfo = null;
- if(aPolicy != null)
+ if (aPolicy != null)
{
BaseAuthenticationInfo bai = aPolicy.getAuthenticationInfo();
- if(bai instanceof AuthenticationInfo)
- authInfo = (AuthenticationInfo)bai;
- }
-
+ if (bai instanceof AuthenticationInfo)
+ authInfo = (AuthenticationInfo) bai;
+ }
+
if (authInfo == null)
{
if (log.isTraceEnabled())
- log.trace("getAppConfigurationEntry("+appName+"), no entry in appConfigs, tyring parentCont: "+parentConfig);
+ log.trace("getAppConfigurationEntry(" + appName + "), no entry in appConfigs, tyring parentCont: "
+ + parentConfig);
if (parentConfig != null)
entry = parentConfig.getAppConfigurationEntry(appName);
if (entry == null)
{
if (log.isTraceEnabled())
- log.trace("getAppConfigurationEntry("+appName+"), no entry in parentConfig, trying: "+DEFAULT_APP_CONFIG_NAME);
+ log.trace("getAppConfigurationEntry(" + appName + "), no entry in parentConfig, trying: "
+ + DEFAULT_APP_CONFIG_NAME);
}
- ApplicationPolicy defPolicy = (ApplicationPolicy)appConfigs.get(DEFAULT_APP_CONFIG_NAME);
- authInfo = defPolicy != null ?(AuthenticationInfo) defPolicy.getAuthenticationInfo() : null;
+ ApplicationPolicy defPolicy = appConfigs.get(DEFAULT_APP_CONFIG_NAME);
+ authInfo = defPolicy != null ? (AuthenticationInfo) defPolicy.getAuthenticationInfo() : null;
}
if (authInfo != null)
{
if (log.isTraceEnabled())
- log.trace("End getAppConfigurationEntry("+appName+"), authInfo=" + authInfo);
+ log.trace("End getAppConfigurationEntry(" + appName + "), authInfo=" + authInfo);
// Make a copy of the authInfo object
final AuthenticationInfo theAuthInfo = authInfo;
PrivilegedAction action = new PrivilegedAction()
@@ -152,31 +168,31 @@
else
{
if (log.isTraceEnabled())
- log.trace("End getAppConfigurationEntry("+appName+"), failed to find entry");
+ log.trace("End getAppConfigurationEntry(" + appName + "), failed to find entry");
}
return entry;
}
+
// --- End Configuration method overrrides
- /** Set the URL of the XML login configuration file that should
- be loaded by this mbean on startup.
+ /**
+ * Set the URL of the XML login configuration file that should be loaded by this mbean on startup.
*/
public URL getConfigURL()
{
return loginConfigURL;
}
- /** Set the URL of the XML login configuration file that should
- be loaded by this mbean on startup.
+ /**
+ * Set the URL of the XML login configuration file that should be loaded by this mbean on startup.
*/
public void setConfigURL(URL loginConfigURL)
{
this.loginConfigURL = loginConfigURL;
}
- public void setConfigResource(String resourceName)
- throws IOException
+ public void setConfigResource(String resourceName) throws IOException
{
ClassLoader tcl = SecurityActions.getContextClassLoader();
loginConfigURL = tcl.getResource(resourceName);
@@ -189,20 +205,22 @@
this.parentConfig = parentConfig;
}
- /** Get whether the login config xml document is validated againsts its DTD
+ /**
+ * Get whether the login config xml document is validated againsts its DTD
*/
public boolean getValidateDTD()
{
return this.validateDTD;
}
- /** Set whether the login config xml document is validated againsts its DTD
+ /**
+ * Set whether the login config xml document is validated againsts its DTD
*/
public void setValidateDTD(boolean flag)
{
this.validateDTD = flag;
}
-
+
/**
* @see ApplicationPolicyRegistration#addApplicationPolicy(String, ApplicationPolicy)
*/
@@ -210,58 +228,58 @@
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkPermission(REFRESH_PERM);
+ sm.checkPermission(REFRESH_PERM);
appConfigs.add(aPolicy);
handleJASPIDelegation(aPolicy);
SecurityConfiguration.addApplicationPolicy(aPolicy);
}
- /** Add an application configuration
+ /**
+ * Add an application configuration
*/
public void addAppConfig(String appName, AppConfigurationEntry[] entries)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkPermission(REFRESH_PERM);
+ sm.checkPermission(REFRESH_PERM);
AuthenticationInfo authInfo = new AuthenticationInfo(appName);
authInfo.setAppConfigurationEntry(entries);
if (log.isTraceEnabled())
- log.trace("addAppConfig("+appName+"), authInfo=" + authInfo);
+ log.trace("addAppConfig(" + appName + "), authInfo=" + authInfo);
ApplicationPolicy aPolicy = new ApplicationPolicy(appName, authInfo);
appConfigs.add(aPolicy);
SecurityConfiguration.addApplicationPolicy(aPolicy);
}
/**
- * @deprecated
+ * @deprecated
* @see #removeApplicationPolicy(String)
* @param appName
*/
+ @Deprecated
public void removeAppConfig(String appName)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(REFRESH_PERM);
if (log.isTraceEnabled())
- log.trace("removeAppConfig, appName="+appName);
+ log.trace("removeAppConfig, appName=" + appName);
appConfigs.remove(appName);
}
-
-
+
/**
* @see ApplicationPolicyRegistration#getApplicationPolicy(String)
*/
public ApplicationPolicy getApplicationPolicy(String domainName)
{
- if(appConfigs == null || appConfigs.size() == 0)
+ if (appConfigs == null || appConfigs.size() == 0)
loadConfig();
- ApplicationPolicy aPolicy = (ApplicationPolicy)appConfigs.get(domainName);
- if(aPolicy != null)
+ ApplicationPolicy aPolicy = appConfigs.get(domainName);
+ if (aPolicy != null)
SecurityConfiguration.addApplicationPolicy(aPolicy);
return aPolicy;
- }
+ }
-
/**
* @see ApplicationPolicyRegistration#removeApplicationPolicy(String)
*/
@@ -271,22 +289,21 @@
if (sm != null)
sm.checkPermission(REFRESH_PERM);
if (log.isTraceEnabled())
- log.trace("removeAppConfig, appName="+appName);
+ log.trace("removeAppConfig, appName=" + appName);
appConfigs.remove(appName);
return true;
}
-
+
/**
- * Method that returns the parsed AuthenticationInfo needed by
- * the JASPI framework until a seperate Configuration mechanism
- * for JASPI is established
+ * Method that returns the parsed AuthenticationInfo needed by the JASPI framework until a seperate Configuration
+ * mechanism for JASPI is established
*
* @return the parsed AuthenticationInfo object
*/
public BaseAuthenticationInfo getAuthenticationInfo(String domainName)
- {
- ApplicationPolicy aPolicy = getApplicationPolicy( domainName);
- return aPolicy != null ? aPolicy.getAuthenticationInfo() : null;
+ {
+ ApplicationPolicy aPolicy = getApplicationPolicy(domainName);
+ return aPolicy != null ? aPolicy.getAuthenticationInfo() : null;
}
public void clear()
@@ -294,8 +311,9 @@
}
- /** Called to try to load the config from the java.security.auth.login.config
- * property value when there is no loginConfigURL.
+ /**
+ * Called to try to load the config from the java.security.auth.login.config property value when there is no
+ * loginConfigURL.
*/
public void loadConfig()
{
@@ -341,13 +359,13 @@
}
if (log.isTraceEnabled())
- log.trace("Begin loadConfig, loginConfigURL="+loginConfigURL);
+ log.trace("Begin loadConfig, loginConfigURL=" + loginConfigURL);
// Try to load the config if found
try
{
loadConfig(loginConfigURL);
if (log.isTraceEnabled())
- log.trace("End loadConfig, loginConfigURL="+loginConfigURL);
+ log.trace("End loadConfig, loginConfigURL=" + loginConfigURL);
}
catch (Exception e)
{
@@ -367,7 +385,7 @@
{
loadXMLConfig(config, configNames);
}
- catch(Throwable e)
+ catch (Throwable e)
{
log.debug("Failed to load config as XML", e);
log.debug("Try loading config as Sun format, url=" + config);
@@ -377,28 +395,27 @@
configNames.toArray(names);
return names;
}
-
+
/**
- * Handle the case when JASPI Info may have login module stack holder
- * which delegates to a login module stack
+ * Handle the case when JASPI Info may have login module stack holder which delegates to a login module stack
+ *
* @param aPolicy
*/
private void handleJASPIDelegation(ApplicationPolicy aPolicy)
{
BaseAuthenticationInfo bai = aPolicy.getAuthenticationInfo();
- if(bai instanceof JASPIAuthenticationInfo)
+ if (bai instanceof JASPIAuthenticationInfo)
{
- JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo)bai;
+ JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) bai;
LoginModuleStackHolder[] lmsharr = jai.getLoginModuleStackHolder();
- for(LoginModuleStackHolder lmsh:lmsharr)
+ for (LoginModuleStackHolder lmsh : lmsharr)
{
this.addAppConfig(lmsh.getName(), lmsh.getAppConfigurationEntry());
}
}
}
- private void loadSunConfig(URL sunConfig, ArrayList configNames)
- throws Exception
+ private void loadSunConfig(URL sunConfig, ArrayList configNames) throws Exception
{
InputStream is = sunConfig.openStream();
if (is == null)
@@ -409,8 +426,7 @@
SunConfigParser.doParse(configFile, this, trace);
}
- private void loadXMLConfig(URL loginConfigURL, ArrayList configNames)
- throws IOException, JBossXBException
+ private void loadXMLConfig(URL loginConfigURL, ArrayList configNames) throws IOException, JBossXBException
{
LoginConfigObjectModelFactory lcomf = new SecurityConfigObjectModelFactory();
UsersObjectModelFactory uomf = new UsersObjectModelFactory();
@@ -423,8 +439,8 @@
Set<String> cnames = config.getConfigNames();
configNames.addAll(cnames);
appConfigs.copy(config);
- //Add the config to SecurityConfiguration
- for(String cname:cnames)
+ // Add the config to SecurityConfiguration
+ for (String cname : cnames)
{
ApplicationPolicy ap = config.get(cname);
SecurityConfiguration.addApplicationPolicy(ap);
@@ -432,8 +448,7 @@
}
}
- private InputStreamReader loadURL(URL configURL)
- throws IOException
+ private InputStreamReader loadURL(URL configURL) throws IOException
{
InputStream is = configURL.openStream();
if (is == null)
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/config/BaseSecurityInfo.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/config/BaseSecurityInfo.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/main/org/jboss/security/config/BaseSecurityInfo.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.security.config;
import java.util.ArrayList;
@@ -26,72 +26,77 @@
import javax.security.auth.AuthPermission;
-//$Id$
+// $Id$
/**
- * Base Class of the security info
- * @author Anil.Saldhana at redhat.com
- * @since Sep 27, 2007
- * @version $Revision$
+ * Base Class of the security info
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Sep 27, 2007
+ * @version $Revision$
* @param <T>
*/
public abstract class BaseSecurityInfo<T>
{
public static final AuthPermission GET_CONFIG_ENTRY_PERM = new AuthPermission("getLoginConfiguration");
+
public static final AuthPermission SET_CONFIG_ENTRY_PERM = new AuthPermission("setLoginConfiguration");
+
protected String name;
+
protected ArrayList<T> moduleEntries = new ArrayList<T>();
public BaseSecurityInfo()
- {
+ {
}
-
+
public BaseSecurityInfo(String name)
{
this.name = name;
}
-
+
public void add(T ame)
{
moduleEntries.add(ame);
- }
-
+ }
+
public void add(List<? extends T> moduleEntries)
{
SecurityManager sm = System.getSecurityManager();
- if( sm != null )
- sm.checkPermission(SET_CONFIG_ENTRY_PERM);
+ if (sm != null)
+ sm.checkPermission(SET_CONFIG_ENTRY_PERM);
this.moduleEntries.addAll(moduleEntries);
}
-
+
public List<T> getModuleEntries()
{
SecurityManager sm = System.getSecurityManager();
- if( sm != null )
- sm.checkPermission(GET_CONFIG_ENTRY_PERM);
+ if (sm != null)
+ sm.checkPermission(GET_CONFIG_ENTRY_PERM);
return this.moduleEntries;
}
-
+
public String getName()
{
return name;
- }
-
+ }
+
public void setName(String name)
{
this.name = name;
}
-
+
protected abstract BaseSecurityInfo<T> create(String name);
public BaseSecurityInfo<T> merge(BaseSecurityInfo<T> bi)
{
- if(bi == null)
+ if (bi == null)
return this;
- List<T> al = bi.getModuleEntries();
+ List<T> al = new ArrayList<T>();
+ al.addAll(bi.getModuleEntries());
al.addAll(this.moduleEntries);
BaseSecurityInfo<T> mergedBAI = create(name);
- mergedBAI.add(al);
+ mergedBAI.add(al);
return mergedBAI;
}
}
\ No newline at end of file
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/WebJASPIAuthMgrUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/WebJASPIAuthMgrUnitTestCase.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/WebJASPIAuthMgrUnitTestCase.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,29 +1,28 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.test.authentication;
import java.net.URL;
-import javax.security.auth.login.Configuration;
import javax.security.auth.message.MessageInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -39,19 +38,19 @@
import org.jboss.test.SecurityActions;
import org.jboss.test.util.TestHttpServletRequest;
-
/**
- * Unit tests for the JBossAuthenticationManager with JASPI
- * @author Anil.Saldhana at redhat.com
- * @since May 10, 2007
- * @version $Revision$
+ * Unit tests for the JBossAuthenticationManager with JASPI
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since May 10, 2007
+ * @version $Revision$
*/
-public class WebJASPIAuthMgrUnitTestCase
-extends JBossAuthenticationManagerUnitTestCase
-{
+public class WebJASPIAuthMgrUnitTestCase extends JBossAuthenticationManagerUnitTestCase
+{
String securityDomain = "web-jaspi";
+
AppCallbackHandler acbh = new AppCallbackHandler();
-
+
@Override
protected void setUp() throws Exception
{
@@ -59,38 +58,40 @@
JBossSecurityContext jsc = new JBossSecurityContext(securityDomain);
SecurityContextAssociation.setSecurityContext(jsc);
establishSecurityConfiguration();
- }
-
+ }
+
+ @Override
public void testLogin() throws Exception
- {
+ {
HttpServletRequest hsr = getHttpServletRequest("jduke", "theduke");
- MessageInfo mi = new GenericMessageInfo(hsr, (HttpServletResponse)null);
- AuthenticationManager am = new JBossAuthenticationManager(securityDomain,acbh);
- assertTrue(am.isValid(mi, null, "HTTP"));
- }
-
+ MessageInfo mi = new GenericMessageInfo(hsr, (HttpServletResponse) null);
+ AuthenticationManager am = new JBossAuthenticationManager(securityDomain, acbh);
+ assertTrue(am.isValid(mi, null, "HTTP"));
+ }
+
+ @Override
public void testUnsuccessfulLogin() throws Exception
{
HttpServletRequest hsr = getHttpServletRequest("jduke", "BAD");
- MessageInfo mi = new GenericMessageInfo(hsr, (HttpServletResponse)null);
- AuthenticationManager am = new JBossAuthenticationManager(securityDomain,acbh);
- assertFalse(am.isValid(mi, null, "HTTP"));
- }
-
+ MessageInfo mi = new GenericMessageInfo(hsr, (HttpServletResponse) null);
+ AuthenticationManager am = new JBossAuthenticationManager(securityDomain, acbh);
+ assertFalse(am.isValid(mi, null, "HTTP"));
+ }
+
private void establishSecurityConfiguration()
- {
- XMLLoginConfigImpl xli = new XMLLoginConfigImpl();
- SecurityActions.setJAASConfiguration((Configuration)xli);
+ {
+ XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
+ SecurityActions.setJAASConfiguration(xli);
URL configURL = Thread.currentThread().getContextClassLoader().getResource("config/jaspi-config.xml");
- assertNotNull("Config URL",configURL);
+ assertNotNull("Config URL", configURL);
xli.setConfigURL(configURL);
- xli.loadConfig();
- }
-
+ xli.loadConfig();
+ }
+
@SuppressWarnings("unchecked")
public HttpServletRequest getHttpServletRequest(String username, String pass)
{
- HttpServletRequest hsr = new TestHttpServletRequest(new SimplePrincipal(username), pass, "GET");
+ HttpServletRequest hsr = new TestHttpServletRequest(new SimplePrincipal(username), pass, "GET");
hsr.getParameterMap().put("j_username", username);
hsr.getParameterMap().put("j_password", pass);
return hsr;
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPILoginModuleDelgateUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPILoginModuleDelgateUnitTestCase.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPILoginModuleDelgateUnitTestCase.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,31 +1,30 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.test.authentication.jaspi;
import java.net.URL;
import java.util.HashMap;
import javax.security.auth.Subject;
-import javax.security.auth.login.Configuration;
import javax.security.auth.message.AuthException;
import javax.security.auth.message.AuthStatus;
import javax.security.auth.message.MessageInfo;
@@ -45,85 +44,84 @@
import org.jboss.security.plugins.JBossSecurityContext;
import org.jboss.test.SecurityActions;
-//$Id$
+// $Id$
/**
- * Test the delegation to a JAAS Login Module
- * by a Server Auth Module
- * @author Anil.Saldhana at redhat.com
- * @since Jul 27, 2007
- * @version $Revision$
+ * Test the delegation to a JAAS Login Module by a Server Auth Module
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 27, 2007
+ * @version $Revision$
*/
public class JASPILoginModuleDelgateUnitTestCase extends TestCase
-{
+{
AuthConfigFactory factory = null;
+
String layer = SecurityConstants.SERVLET_LAYER;
+
String appId = "localhost /petstore";
-
- String configFile="config/jaspi-config.xml";
+ String configFile = "config/jaspi-config.xml";
+
@Override
protected void setUp() throws Exception
- {
+ {
factory = AuthConfigFactory.getFactory();
- factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()),
- layer, appId, "Test Config Provider");
-
+ factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()), layer, appId, "Test Config Provider");
+
JBossSecurityContext jsc = new JBossSecurityContext("conf-jaspi-2");
SecurityContextAssociation.setSecurityContext(jsc);
-
- XMLLoginConfigImpl xli = new XMLLoginConfigImpl();
- SecurityActions.setJAASConfiguration((Configuration)xli);
-
+
+ XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
+ SecurityActions.setJAASConfiguration(xli);
+
URL configURL = Thread.currentThread().getContextClassLoader().getResource(configFile);
- assertNotNull("Config URL",configURL);
-
+ assertNotNull("Config URL", configURL);
+
xli.setConfigURL(configURL);
xli.loadConfig();
- }
-
+ }
+
public void testSuccessfulJASPI() throws Exception
{
- AuthConfigProvider provider = factory.getConfigProvider(layer,appId,null);
- ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer,appId,
- new AppCallbackHandler("jduke","theduke".toCharArray()));
- assertNotNull("ServerAuthConfig is not null", serverConfig);
-
+ AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
+ ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("jduke",
+ "theduke".toCharArray()));
+ assertNotNull("ServerAuthConfig is not null", serverConfig);
+
MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
String authContextID = serverConfig.getAuthContextID(mi);
- assertNotNull("AuthContext ID != null",authContextID);
- ServerAuthContext sctx = serverConfig.getAuthContext(authContextID,
- new Subject(), new HashMap());
- assertNotNull("ServerAuthContext != null",sctx);
+ assertNotNull("AuthContext ID != null", authContextID);
+ ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
+ assertNotNull("ServerAuthContext != null", sctx);
Subject clientSubject = new Subject();
Subject serviceSubject = new Subject();
AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
- assertEquals(AuthStatus.SUCCESS, status );
+ assertEquals(AuthStatus.SUCCESS, status);
}
-
+
public void testUnSuccessfulJASPI() throws Exception
{
- AuthConfigProvider provider = factory.getConfigProvider(layer,appId,null);
- ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer,appId,
- new AppCallbackHandler("jduke","badpwd".toCharArray()));
- assertNotNull("ServerAuthConfig is not null", serverConfig);
-
+ AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
+ ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("jduke",
+ "badpwd".toCharArray()));
+ assertNotNull("ServerAuthConfig is not null", serverConfig);
+
MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
String authContextID = serverConfig.getAuthContextID(mi);
- assertNotNull("AuthContext ID != null",authContextID);
- ServerAuthContext sctx = serverConfig.getAuthContext(authContextID,
- new Subject(), new HashMap());
- assertNotNull("ServerAuthContext != null",sctx);
+ assertNotNull("AuthContext ID != null", authContextID);
+ ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
+ assertNotNull("ServerAuthContext != null", sctx);
Subject clientSubject = new Subject();
Subject serviceSubject = new Subject();
try
- {
+ {
AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
- assertEquals(AuthStatus.FAILURE, status );
+ assertEquals(AuthStatus.FAILURE, status);
}
- catch(AuthException ae)
+ catch (AuthException ae)
{
- //Pass
+ // Pass
}
- }
+ }
}
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPIWorkflowUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPIWorkflowUnitTestCase.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/authentication/jaspi/JASPIWorkflowUnitTestCase.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,31 +1,30 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.test.authentication.jaspi;
import java.net.URL;
import java.util.HashMap;
import javax.security.auth.Subject;
-import javax.security.auth.login.Configuration;
import javax.security.auth.message.AuthStatus;
import javax.security.auth.message.MessageInfo;
import javax.security.auth.message.config.AuthConfigFactory;
@@ -44,77 +43,77 @@
import org.jboss.security.plugins.JBossSecurityContext;
import org.jboss.test.SecurityActions;
-//$Id$
+// $Id$
/**
- * Test the Server side workflow for JASPI
- * @author Anil.Saldhana at redhat.com
- * @since Jul 16, 2007
- * @version $Revision$
+ * Test the Server side workflow for JASPI
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 16, 2007
+ * @version $Revision$
*/
public class JASPIWorkflowUnitTestCase extends TestCase
{
AuthConfigFactory factory = null;
+
String layer = SecurityConstants.SERVLET_LAYER;
+
String appId = "localhost /petstore";
-
- String configFile="config/jaspi-config.xml";
-
+
+ String configFile = "config/jaspi-config.xml";
+
@Override
protected void setUp() throws Exception
- {
+ {
factory = AuthConfigFactory.getFactory();
- factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()),
- layer, appId, "Test Config Provider");
-
+ factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()), layer, appId, "Test Config Provider");
+
JBossSecurityContext jsc = new JBossSecurityContext("conf-jaspi");
SecurityContextAssociation.setSecurityContext(jsc);
-
- XMLLoginConfigImpl xli = new XMLLoginConfigImpl();
- SecurityActions.setJAASConfiguration((Configuration)xli);
-
+
+ XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
+ SecurityActions.setJAASConfiguration(xli);
+
URL configURL = Thread.currentThread().getContextClassLoader().getResource(configFile);
- assertNotNull("Config URL",configURL);
-
+ assertNotNull("Config URL", configURL);
+
xli.setConfigURL(configURL);
xli.loadConfig();
- }
-
+ }
+
public void testSuccessfulJASPI() throws Exception
{
- AuthConfigProvider provider = factory.getConfigProvider(layer,appId,null);
- ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer,appId,
- new AppCallbackHandler("anil","anilpwd".toCharArray()));
- assertNotNull("ServerAuthConfig is not null", serverConfig);
-
+ AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
+ ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("anil",
+ "anilpwd".toCharArray()));
+ assertNotNull("ServerAuthConfig is not null", serverConfig);
+
MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
String authContextID = serverConfig.getAuthContextID(mi);
- assertNotNull("AuthContext ID != null",authContextID);
- ServerAuthContext sctx = serverConfig.getAuthContext(authContextID,
- new Subject(), new HashMap());
- assertNotNull("ServerAuthContext != null",sctx);
+ assertNotNull("AuthContext ID != null", authContextID);
+ ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
+ assertNotNull("ServerAuthContext != null", sctx);
Subject clientSubject = new Subject();
Subject serviceSubject = new Subject();
AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
- assertEquals(AuthStatus.SUCCESS, status );
+ assertEquals(AuthStatus.SUCCESS, status);
}
-
+
public void testUnSuccessfulJASPI() throws Exception
{
- AuthConfigProvider provider = factory.getConfigProvider(layer,appId,null);
- ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer,appId,
- new AppCallbackHandler("anil","badpwd".toCharArray()));
- assertNotNull("ServerAuthConfig is not null", serverConfig);
-
+ AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
+ ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("anil",
+ "badpwd".toCharArray()));
+ assertNotNull("ServerAuthConfig is not null", serverConfig);
+
MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
String authContextID = serverConfig.getAuthContextID(mi);
- assertNotNull("AuthContext ID != null",authContextID);
- ServerAuthContext sctx = serverConfig.getAuthContext(authContextID,
- new Subject(), new HashMap());
- assertNotNull("ServerAuthContext != null",sctx);
+ assertNotNull("AuthContext ID != null", authContextID);
+ ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
+ assertNotNull("ServerAuthContext != null", sctx);
Subject clientSubject = new Subject();
Subject serviceSubject = new Subject();
AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
- assertEquals(AuthStatus.FAILURE, status );
+ assertEquals(AuthStatus.FAILURE, status);
}
}
Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/security/identitytrust/IdentityTrustUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/security/identitytrust/IdentityTrustUnitTestCase.java 2008-05-09 16:46:02 UTC (rev 73224)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/tests/org/jboss/test/security/identitytrust/IdentityTrustUnitTestCase.java 2008-05-09 16:48:44 UTC (rev 73225)
@@ -1,30 +1,28 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.test.security.identitytrust;
import java.net.URL;
-import javax.security.auth.login.Configuration;
-
import junit.framework.TestCase;
import org.jboss.security.RunAs;
@@ -35,157 +33,159 @@
import org.jboss.security.plugins.JBossSecurityContext;
import org.jboss.test.SecurityActions;
-//$Id$
+// $Id$
/**
- * Test the IdentityTrust framework
- * @author Anil.Saldhana at redhat.com
- * @since Aug 2, 2007
- * @version $Revision$
+ * Test the IdentityTrust framework
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Aug 2, 2007
+ * @version $Revision$
*/
public class IdentityTrustUnitTestCase extends TestCase
-{
- String configFile="config/identitytrust-config.xml";
-
+{
+ String configFile = "config/identitytrust-config.xml";
+
+ @Override
protected void setUp() throws Exception
- {
- XMLLoginConfigImpl xli = new XMLLoginConfigImpl();
- SecurityActions.setJAASConfiguration((Configuration)xli);
+ {
+ XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
+ SecurityActions.setJAASConfiguration(xli);
URL configURL = Thread.currentThread().getContextClassLoader().getResource(configFile);
- assertNotNull("Config URL",configURL);
-
+ assertNotNull("Config URL", configURL);
+
xli.setConfigURL(configURL);
xli.loadConfig();
- }
-
+ }
+
public void testPermit_Permit_Permit() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit-Permit-Permit");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
}
-
+
public void testPermit_Permit_Deny() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit-Permit-Deny");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted Deny",TrustDecision.Deny,itm.isTrusted(sc));
+ assertEquals("Is Trusted Deny", TrustDecision.Deny, itm.isTrusted(sc));
}
-
+
public void testPermit_Deny_Permit() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit-Deny-Permit");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted Deny",TrustDecision.Deny,itm.isTrusted(sc));
+ assertEquals("Is Trusted Deny", TrustDecision.Deny, itm.isTrusted(sc));
}
-
+
public void testDeny_Permit_Permit() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Deny-Permit-Permit");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted Deny",TrustDecision.Deny,itm.isTrusted(sc));
+ assertEquals("Is Trusted Deny", TrustDecision.Deny, itm.isTrusted(sc));
}
-
+
public void testPermit_Permit_NotApplicable() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit-Permit-NotApplicable");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
- }
-
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
+ }
+
public void testNotApplicable_Permit_Permit() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("NotApplicable-Permit-Permit");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
- }
-
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
+ }
+
public void testNotApplicable_Required__Permit_Optional() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("NotApplicable_Required-Permit_Optional");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted not applicable",TrustDecision.NotApplicable,itm.isTrusted(sc));
+ assertEquals("Is Trusted not applicable", TrustDecision.NotApplicable, itm.isTrusted(sc));
}
-
+
public void testPermit_Required__Deny_Optional() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit_Required-Deny_Optional");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
}
-
+
public void testNotApplicable_Required__Deny_Optional() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("NotApplicable_Required-Deny_Optional");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted false",TrustDecision.NotApplicable,itm.isTrusted(sc));
+ assertEquals("Is Trusted false", TrustDecision.NotApplicable, itm.isTrusted(sc));
}
-
+
public void testPermit_Sufficient__Deny_Optional() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("Permit_Sufficient-Deny_Optional");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
}
@SuppressWarnings("unchecked")
public void testJavaEERunAsIdentity() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("conf-javaee");
- sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
+ sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
- assertEquals("Is Trusted",TrustDecision.Permit,itm.isTrusted(sc));
-
+ assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
+
sc.setIncomingRunAs(new RunAs()
- {
+ {
public <T> T getIdentity()
- {
+ {
return (T) "BAD";
}
public <T> T getProof()
- {
+ {
return (T) "BAD";
}
public String getName()
- {
+ {
return "BAD";
}
- });
-
- assertEquals("Is Trusted is false",TrustDecision.NotApplicable,itm.isTrusted(sc));
- }
+ });
+
+ assertEquals("Is Trusted is false", TrustDecision.NotApplicable, itm.isTrusted(sc));
+ }
}
More information about the jboss-cvs-commits
mailing list