User: starksm Date: 02/02/06 12:01:31 Modified: src/main/org/jboss/security/auth/spi Tag: Branch_2_4 UsersRolesLoginModule.java Log: Add new login module options: usersProperties: The name of the properties resource containing user/passwords. The default is "users.properties" rolesProperties: The name of the properties resource containing user/roles The default is "roles.properties". Revision Changes Path No revision No revision 1.6.4.3 +29 -20 jbosssx/src/main/org/jboss/security/auth/spi/UsersRolesLoginModule.java Index: UsersRolesLoginModule.java =================================================================== RCS file: /cvsroot/jboss/jbosssx/src/main/org/jboss/security/auth/spi/UsersRolesLoginModule.java,v retrieving revision 1.6.4.2 retrieving revision 1.6.4.3 diff -u -r1.6.4.2 -r1.6.4.3 --- UsersRolesLoginModule.java 2002/02/05 18:59:04 1.6.4.2 +++ UsersRolesLoginModule.java 2002/02/06 20:01:31 1.6.4.3 @@ -32,10 +32,11 @@ /** A simple properties file based login module that consults two Java Properties formatted text files for username to password("users.properties") and -username to roles("roles.properties") mapping. The properties files are loaded -during initialization using the thread context class loader. This means that -these files can be placed into the J2EE deployment jar or the JBoss config -directory. +username to roles("roles.properties") mapping. The names of the properties +files may be overriden by the usersProperties and rolesProperties options. +The properties files are loaded during initialization using the thread context +class loader. This means that these files can be placed into the J2EE +deployment jar or the JBoss config directory. The users.properties file uses a format: username1=password1 @@ -62,19 +63,34 @@ */ public class UsersRolesLoginModule extends UsernamePasswordLoginModule { + /** The name of the properties resource containing user/passwords */ + private String usersRsrcName = "users.properties"; + /** The name of the properties resource containing user/roles */ + private String rolesRsrcName = "roles.properties"; /** The users.properties values */ private Properties users; /** The roles.properties values */ private Properties roles; - /** - * Initialize this LoginModule. + /** Initialize this LoginModule. + *@param options, the login module option map. Supported options include: + *usersProperties: The name of the properties resource containing + user/passwords. The default is "users.properties" + *rolesProperties: The name of the properties resource containing user/roles + The default is "roles.properties". */ public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { super.initialize(subject, callbackHandler, sharedState, options); try { + // Check for usersProperties & rolesProperties + String option = (String) options.get("usersProperties"); + if( option != null ) + usersRsrcName = option; + option = (String) options.get("rolesProperties"); + if( option != null ) + rolesRsrcName = option; // Load the properties file that contains the list of users and passwords loadUsers(); loadRoles(); @@ -87,17 +103,11 @@ } } - /** - * Method to authenticate a Subject (phase 1). - * - * Most of the changes from the original SimpleServerLoginModule - * are made in this method. They are: - * users and passwords read from users.properties file - * users and roles read from roles.properties file - * - * I've also removed the notion of a guest login. If you want to provide 'guest' - * access to your beans then simply disable security on them. - * + /** Method to authenticate a Subject (phase 1). This validates that the + *users and roles properties files were loaded and then calls + *super.login to perform the validation of the password. + *@exception LoginException, thrown if the users or roles properties files + *were not found or the super.login method fails. */ public boolean login() throws LoginException { @@ -180,12 +190,12 @@ private void loadUsers() throws IOException { - users = loadProperties("users.properties"); + users = loadProperties(usersRsrcName); } private void loadRoles() throws IOException { - roles = loadProperties("roles.properties"); + roles = loadProperties(rolesRsrcName); } /** @@ -214,4 +224,3 @@ return bundle; } } -
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development