KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > auth > spi > MemoryUsersRolesLoginModule


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.security.auth.spi;
9
10 import java.io.IOException JavaDoc;
11 import java.util.Properties JavaDoc;
12 import java.util.Map JavaDoc;
13 import javax.security.auth.Subject JavaDoc;
14 import javax.security.auth.callback.CallbackHandler JavaDoc;
15
16 /**
17  * A subclass of UsersRolesLoginModule that uses a singleton instance and
18  * memory based users/roles Properties maps to manage user/password and
19  * user/role mappings. These maps need to be specified via the login module
20  * options.
21  *
22  * @author Scott.Stark@jboss.org
23  * @version $Revision: 1.1 $
24  */

25 public class MemoryUsersRolesLoginModule extends UsersRolesLoginModule
26 {
27    private Properties JavaDoc users;
28    private Properties JavaDoc roles;
29
30    /**
31     * Override the UsersRolesLoginModule initialize to look for a users
32     * and roles options specifying the
33     *
34     * @param subject
35     * @param callbackHandler
36     * @param sharedState
37     * @param options
38     */

39    public void initialize(Subject JavaDoc subject, CallbackHandler JavaDoc callbackHandler,
40       Map JavaDoc sharedState, Map JavaDoc options)
41    {
42       // First extract the users/roles Properties from the options
43
this.users = (Properties JavaDoc) options.get("users");
44       this.roles = (Properties JavaDoc) options.get("roles");
45       // Now initialize the superclass which will invoke createUsers/createRoles
46
super.initialize(subject, callbackHandler, sharedState, options);
47    }
48
49    /**
50     * Provide the users map obtained during initialize
51     * @return the users login module option value
52     */

53    protected Properties JavaDoc createUsers(Map JavaDoc options)
54    {
55       return users;
56    }
57
58    /**
59     * Provide the users map obtained during initialize
60     * @return the users login module option value
61     */

62    protected Properties JavaDoc createRoles(Map JavaDoc options) throws IOException JavaDoc
63    {
64       return roles;
65    }
66 }
67
Popular Tags