if( config != null )
{
log.debug("Using embedded config");
Set names = config.getConfigNames();
Iterator iter = names.iterator();
MBeanServer server = super.getServer();
while( iter.hasNext() )
{
String name = (String) iter.next();
ApplicationPolicy aPolicy = config.get(name);
if(aPolicy == null)
throw new IllegalStateException("Application Policy is null for "+name);
AuthenticationInfo info = (AuthenticationInfo)aPolicy.getAuthenticationInfo();
if(info == null)
throw new IllegalStateException("Authentication Info is null for " + name);
AppConfigurationEntry[] entry = info.getAppConfigurationEntry();
// addAppConfig(String, AppConfigurationEntry[]);
//Object[] args = {name, entry};
//String[] sig = {String.class.getName(), entry.getClass().getName()};
Object[] args = {name, aPolicy};
String[] sig = {String.class.getName(), aPolicy.getClass().getName()};
//server.invoke(loginConfigService, "addAppConfig", args, sig);
server.invoke(loginConfigService, "addApplicationPolicy", args, sig);
}
configNames = new String[names.size()];
names.toArray(configNames);
}
else
{
//JBAS-3422: Ensure that the AuthConf is neither null nor default login-config.xml
if( authConf== null || authConf.length() == 0)
throw new IllegalStateException("AuthConf is null. Please " +
"configure an appropriate config resource");
// Look for the authConf as resource
ClassLoader loader = Thread.currentThread().getContextClassLoader();
URL loginConfig = loader.getResource(authConf);
if(loginConfig == null)
{
try
{
//JBAS-3210: Allow an absolute url
loginConfig = new URL(authConf);
}
catch(Exception e)
{
loginConfig = null;
}
}
if( loginConfig != null )
{
validateAuthConfigURL(loginConfig);
log.debug("Using JAAS AuthConfig: "+loginConfig.toExternalForm());
MBeanServer server = super.getServer();
Object[] args = {loginConfig};
String[] sig = {URL.class.getName()};
configNames = (String[]) server.invoke(loginConfigService,
"loadConfig", args, sig);
int count = configNames == null ? 0 : configNames.length;
for(int n = 0; n < count; n ++)
{
log.debug("Loaded config: "+configNames[n]);