Listing 1: DbSample AuthenticationProviderImpl.java
public void initialize(ProviderMBean providermbean, SecurityServices securityservices)
{
:
myMBean = (DbSampleAuthenticatorMBean)providermbean;
:
}
public AppConfigurationEntry getLoginModuleConfiguration()
{
HashMap hashmap = new HashMap();
return getConfiguration(hashmap);
}
private AppConfigurationEntry getConfiguration(HashMap hashmap)
{
sLogger.debug("Requesting login module configurations");
hashmap.put("myMBean", myMBean);
return new AppConfigurationEntry("examples.db.security.providers.authentication.
DbSampleLoginModuleImpl", controlFlag, hashmap);
}
Listing 2: DbSampleLoginModuleImpl.java
public void initialize(Subject subject1, CallbackHandler callbackhandler, Map map, Map
map1) {
:
DbSampleAuthenticatorMBean dbsampleauthenticatormbean =
(DbSampleAuthenticatorMBean)map1.get("myMBean");
:
String databaseURL = dbsampleauthenticatormbean.getDatabaseURL();
String databaseUser = dbsampleauthenticatormbean.getDatabaseUser();
String databaseUserPassword = dbsampleauthenticatormbean.getDatabaseUserPassword();
String databaseJDBCDriver =
dbsampleauthenticatormbean.getDatabaseJDBCDriver();
String DataSourceName = dbsampleauthenticatormbean.getDataSourceName();
DbSampleAuthenticatorDatabase database = new
DbSampleAuthenticatorDatabase(databaseURL, databaseUser, databaseUserPassword,
databaseJDBCDriver, DataSourceName);
:
}
Listing 3: Write the Console Extension class used to return the JSP page the
console will render
public final class DbSampleConsoleExtension extends Extension
implements SecurityExtensionV2
{
public DbSampleConsoleExtension()
{
}
public String getExtensionForProvider(ObjectName objectname, String s, ObjectName
objectname1)
{
sLogger.debug("DbSampleConsoleExtension.getExtensionForProvider");
if(s.equals("examples.db.security.providers.authentication.DbSampleAuthenticatorMBean"))
{
return "DbSampleConsolePage.jsp";
// This jsp must be in this web-app or a 404 will be returned
} else
{
return null;
// for all other Providers, have the console use default behavior
}
}