Methods Summary |
---|
public static com.sun.appserv.management.config.AuthRealmConfig | createInstance(com.sun.appserv.management.config.SecurityServiceConfig securityServiceConfig, java.lang.String name, java.lang.String classname, java.lang.String keyFile)
final Map<String,String> options = new HashMap<String,String>();
options.put( KEY_FILE_PROPERTY_KEY, keyFile );
options.put( JAAS_CONTEXT_PROPERTY_KEY, "dummy-jaas-context-value" );
return securityServiceConfig.createAuthRealmConfig( name, classname, options);
|
protected final com.sun.appserv.management.config.AMXConfig | createProgeny(java.lang.String name, java.util.Map options)
if ( name.indexOf( "Illegal" ) >= 0 )
{
// MBean doesn't detect illegal parameters; anything is allowed
// for the realm.
throw new IllegalArgumentException();
}
return createInstance( getConfigConfig().getSecurityServiceConfig(),
name, DEFAULT_REALM_CLASSNAME, name + "-keyfile" );
|
public static com.sun.appserv.management.config.AuthRealmConfig | ensureDefaultInstance(com.sun.appserv.management.config.SecurityServiceConfig securityServiceConfig)
AuthRealmConfig result =
securityServiceConfig.getAuthRealmConfigMap().get( getDefaultInstanceName() );
if ( result == null )
{
result = createInstance( securityServiceConfig,
getDefaultInstanceName(),
DEFAULT_REALM_CLASSNAME,
KEY_FILE_PREFIX + "default-instance-test" );
}
return result;
|
public static java.lang.String | getDefaultInstanceName()
return getDefaultInstanceName( "AuthRealmConfig" );
|
protected com.sun.appserv.management.base.Container | getProgenyContainer()
return getConfigConfig().getSecurityServiceConfig();
|
protected java.lang.String | getProgenyJ2EEType()
return XTypes.AUTH_REALM_CONFIG;
|
private synchronized java.util.Map | getTestableAuthRealms()
final Map<String,AuthRealmConfig> m =
getConfigConfig().getSecurityServiceConfig().getAuthRealmConfigMap();
final Map<String,AuthRealmConfig> std = new HashMap<String,AuthRealmConfig>();
final List<String> warnings = new ArrayList<String>();
for( final String name : m.keySet() )
{
final AuthRealmConfig c = m.get( name );
if ( AuthRealmConfig.DEFAULT_REALM_CLASSNAME.equals( c.getClassname() ) )
{
try
{
final String file = c.getPropertyValue( "file" );
if ( file == null )
{
warnings.add( "Realm " + name +
" does not have a 'file' property (test skipped)" );
}
else if ( file.indexOf( TEMPLATE_PREFIX ) >= 0 )
{
warnings.add( "Realm " + name +
" uses a ${...} name, not yet supported (test skipped)" );
}
else
{
std.put( c.getName(), c );
}
}
catch( Exception e )
{
}
}
}
if ( ! WARNED_TESTABLE )
{
WARNED_TESTABLE = true;
warning( NEWLINE + CollectionUtil.toString( warnings, NEWLINE ) + NEWLINE +
"Realms which WILL be tested: {" + CollectionUtil.toString( m.keySet() ) + "}");
}
return std;
|
protected void | removeProgeny(java.lang.String name)
getConfigConfig().getSecurityServiceConfig().removeAuthRealmConfig( name );
|
public synchronized void | testAddRemoveUpdateUser()
final Map<String,AuthRealmConfig> arcMap = getTestableAuthRealms();
final String USER = "test";
final Set<AuthRealmConfig> failures = new HashSet<AuthRealmConfig>();
for( final AuthRealmConfig ar : arcMap.values() )
{
//printVerbose( "TESTING: " + ar.getName() );
try
{
ar.getUserNames();
if ( userExists( ar, USER ) )
{
ar.removeUser( USER );
}
ar.addUser( USER, "foo-pwd", null );
assert( userExists( ar, USER ) );
ar.updateUser( USER, "foo-pwd2", null );
assert( userExists( ar, USER ) );
ar.removeUser( USER );
assert( ! userExists( ar, USER ) );
//printVerbose( "SUCCESS testing: " + ar.getName() );
}
catch( Exception e )
{
trace( "" );
trace( "" );
trace( "FAILURE FOR: " + ar.getName() );
//e.printStackTrace();
failures.add( ar );
}
}
if ( failures.size() != 0 )
{
final Set<String> names = Util.getNames( failures );
warning( "testAddRemoveUpdateUser failed on the following realms: " +
CollectionUtil.toString( names ) );
assert( false );
}
|
public synchronized void | testGetGroupNames()
final Map<String,AuthRealmConfig> arcMap = getTestableAuthRealms();
for( final AuthRealmConfig ar : arcMap.values() )
{
ar.getGroupNames();
}
|
public synchronized void | testGetUserGroupNames()
final Map<String,AuthRealmConfig> arcMap = getTestableAuthRealms();
for( final AuthRealmConfig ar : arcMap.values() )
{
final String[] users = ar.getUserNames();
for( final String user : users )
{
ar.getUserGroupNames( user );
}
}
|
public synchronized void | testGetters()
final Map<String,AuthRealmConfig> arcMap = getTestableAuthRealms();
for( final AuthRealmConfig ar : arcMap.values() )
{
ar.getName();
final String classname = ar.getClassname();
if ( classname != null )
{
ar.setClassname( classname );
}
}
|
private boolean | userExists(com.sun.appserv.management.config.AuthRealmConfig config, java.lang.String user)
return GSetUtil.newStringSet( (String[])config.getUserNames() ).contains( user );
|