KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > security > auth > login > AppConfigurationEntry


1 /*
2  * @(#)AppConfigurationEntry.java 1.34 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package javax.security.auth.login;
9
10 import java.util.Map JavaDoc;
11 import java.util.Collections JavaDoc;
12
13 /**
14  * This class represents a single <code>LoginModule</code> entry
15  * configured for the application specified in the
16  * <code>getAppConfigurationEntry(String appName)</code>
17  * method in the <code>Configuration</code> class. Each respective
18  * <code>AppConfigurationEntry</code> contains a <code>LoginModule</code> name,
19  * a control flag (specifying whether this <code>LoginModule</code> is
20  * REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL), and LoginModule-specific
21  * options. Please refer to the <code>Configuration</code> class for
22  * more information on the different control flags and their semantics.
23  *
24  * @version 1.34, 05/05/04
25  * @see javax.security.auth.login.Configuration
26  */

27 public class AppConfigurationEntry {
28
29     private String JavaDoc loginModuleName;
30     private LoginModuleControlFlag controlFlag;
31     private Map JavaDoc options;
32
33     /**
34      * Default constructor for this class.
35      *
36      * <p> This entry represents a single <code>LoginModule</code>
37      * entry configured for the application specified in the
38      * <code>getAppConfigurationEntry(String appName)</code>
39      * method from the <code>Configuration</code> class.
40      *
41      * @param loginModuleName String representing the class name of the
42      * <code>LoginModule</code> configured for the
43      * specified application. <p>
44      *
45      * @param controlFlag either REQUIRED, REQUISITE, SUFFICIENT,
46      * or OPTIONAL. <p>
47      *
48      * @param options the options configured for this <code>LoginModule</code>.
49      *
50      * @exception IllegalArgumentException if <code>loginModuleName</code>
51      * is null, if <code>LoginModuleName</code>
52      * has a length of 0, if <code>controlFlag</code>
53      * is not either REQUIRED, REQUISITE, SUFFICIENT
54      * or OPTIONAL, or if <code>options</code> is null.
55      */

56     public AppConfigurationEntry(String JavaDoc loginModuleName,
57                 LoginModuleControlFlag controlFlag,
58                 Map JavaDoc<String JavaDoc,?> options)
59     {
60     if (loginModuleName == null || loginModuleName.length() == 0 ||
61         (controlFlag != LoginModuleControlFlag.REQUIRED &&
62         controlFlag != LoginModuleControlFlag.REQUISITE &&
63         controlFlag != LoginModuleControlFlag.SUFFICIENT &&
64         controlFlag != LoginModuleControlFlag.OPTIONAL) ||
65         options == null)
66         throw new IllegalArgumentException JavaDoc();
67         
68     this.loginModuleName = loginModuleName;
69     this.controlFlag = controlFlag;
70     this.options = Collections.unmodifiableMap(options);
71     }
72
73     /**
74      * Get the class name of the configured <code>LoginModule</code>.
75      *
76      * @return the class name of the configured <code>LoginModule</code> as
77      * a String.
78      */

79     public String JavaDoc getLoginModuleName() {
80     return loginModuleName;
81     }
82
83     /**
84      * Return the controlFlag
85      * (either REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL)
86      * for this <code>LoginModule</code>.
87      *
88      * @return the controlFlag
89      * (either REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL)
90      * for this <code>LoginModule</code>.
91      */

92     public LoginModuleControlFlag getControlFlag() {
93     return controlFlag;
94     }
95
96     /**
97      * Get the options configured for this <code>LoginModule</code>.
98      *
99      * @return the options configured for this <code>LoginModule</code>
100      * as an unmodifiable <code>Map</code>.
101      */

102     public Map JavaDoc<String JavaDoc,?> getOptions() {
103     return options;
104     }
105
106     /**
107      * This class represents whether or not a <code>LoginModule</code>
108      * is REQUIRED, REQUISITE, SUFFICIENT or OPTIONAL.
109      */

110     public static class LoginModuleControlFlag {
111
112     private String JavaDoc controlFlag;
113
114     /**
115      * Required <code>LoginModule</code>.
116      */

117     public static final LoginModuleControlFlag REQUIRED =
118                 new LoginModuleControlFlag("required");
119
120     /**
121      * Requisite <code>LoginModule</code>.
122      */

123     public static final LoginModuleControlFlag REQUISITE =
124                 new LoginModuleControlFlag("requisite");
125
126     /**
127      * Sufficient <code>LoginModule</code>.
128      */

129     public static final LoginModuleControlFlag SUFFICIENT =
130                 new LoginModuleControlFlag("sufficient");
131
132     /**
133      * Optional <code>LoginModule</code>.
134      */

135     public static final LoginModuleControlFlag OPTIONAL =
136                 new LoginModuleControlFlag("optional");
137
138     private LoginModuleControlFlag(String JavaDoc controlFlag) {
139         this.controlFlag = controlFlag;
140     }
141
142     /**
143      * Return a String representation of this controlFlag.
144      *
145      * @return a String representation of this controlFlag.
146      */

147     public String JavaDoc toString() {
148         return (sun.security.util.ResourcesMgr.getString
149         ("LoginModuleControlFlag: ") + controlFlag);
150     }
151     }
152 }
153
Popular Tags