1 module hunt.security.AuthPermission;
2 
3 import hunt.security.BasicPermission;
4 
5 /**
6  * This class is for authentication permissions.
7  * An AuthPermission contains a name
8  * (also referred to as a "target name")
9  * but no actions list; you either have the named permission
10  * or you don't.
11  *
12  * <p> The target name is the name of a security configuration parameter
13  * (see below).  Currently the AuthPermission object is used to
14  * guard access to the Policy, Subject, LoginContext,
15  * and Configuration objects.
16  *
17  * <p> The possible target names for an Authentication Permission are:
18  *
19  * <pre>
20  *      doAs -                  allow the caller to invoke the
21  *                              {@code Subject.doAs} methods.
22  *
23  *      doAsPrivileged -        allow the caller to invoke the
24  *                              {@code Subject.doAsPrivileged} methods.
25  *
26  *      getSubject -            allow for the retrieval of the
27  *                              Subject(s) associated with the
28  *                              current Thread.
29  *
30  *      getSubjectFromDomainCombiner -  allow for the retrieval of the
31  *                              Subject associated with the
32  *                              a {@code SubjectDomainCombiner}.
33  *
34  *      setReadOnly -           allow the caller to set a Subject
35  *                              to be read-only.
36  *
37  *      modifyPrincipals -      allow the caller to modify the {@code Set}
38  *                              of Principals associated with a
39  *                              {@code Subject}
40  *
41  *      modifyPublicCredentials - allow the caller to modify the
42  *                              {@code Set} of public credentials
43  *                              associated with a {@code Subject}
44  *
45  *      modifyPrivateCredentials - allow the caller to modify the
46  *                              {@code Set} of private credentials
47  *                              associated with a {@code Subject}
48  *
49  *      refreshCredential -     allow code to invoke the {@code refresh}
50  *                              method on a credential which implements
51  *                              the {@code Refreshable} interface.
52  *
53  *      destroyCredential -     allow code to invoke the {@code destroy}
54  *                              method on a credential {@code object}
55  *                              which implements the {@code Destroyable}
56  *                              interface.
57  *
58  *      createLoginContext.{name} -  allow code to instantiate a
59  *                              {@code LoginContext} with the
60  *                              specified <i>name</i>.  <i>name</i>
61  *                              is used as the index into the installed login
62  *                              {@code Configuration}
63  *                              (that returned by
64  *                              {@code Configuration.getConfiguration()}).
65  *                              <i>name</i> can be wildcarded (set to '*')
66  *                              to allow for any name.
67  *
68  *      getLoginConfiguration - allow for the retrieval of the system-wide
69  *                              login Configuration.
70  *
71  *      createLoginConfiguration.{type} - allow code to obtain a Configuration
72  *                              object via
73  *                              {@code Configuration.getInstance}.
74  *
75  *      setLoginConfiguration - allow for the setting of the system-wide
76  *                              login Configuration.
77  *
78  *      refreshLoginConfiguration - allow for the refreshing of the system-wide
79  *                              login Configuration.
80  * </pre>
81  *
82  * <p> The following target name has been deprecated in favor of
83  * {@code createLoginContext.{name}}.
84  *
85  * <pre>
86  *      createLoginContext -    allow code to instantiate a
87  *                              {@code LoginContext}.
88  * </pre>
89  *
90  * <p> {@code javax.security.auth.Policy} has been
91  * deprecated in favor of {@code java.security.Policy}.
92  * Therefore, the following target names have also been deprecated:
93  *
94  * <pre>
95  *      getPolicy -             allow the caller to retrieve the system-wide
96  *                              Subject-based access control policy.
97  *
98  *      setPolicy -             allow the caller to set the system-wide
99  *                              Subject-based access control policy.
100  *
101  *      refreshPolicy -         allow the caller to refresh the system-wide
102  *                              Subject-based access control policy.
103  * </pre>
104  *
105  */
106 public final class AuthPermission : BasicPermission {
107 
108     private enum long serialVersionUID = 5806031445061587174L;
109 
110     /**
111      * Creates a new AuthPermission with the specified name.
112      * The name is the symbolic name of the AuthPermission.
113      *
114      * <p>
115      *
116      * @param name the name of the AuthPermission
117      *
118      * @throws NullPointerException if {@code name} is {@code null}.
119      * @throws IllegalArgumentException if {@code name} is empty.
120      */
121     public this(string name) {
122         // for backwards compatibility --
123         // createLoginContext is deprecated in favor of createLoginContext.*
124         super("createLoginContext" == name ?
125                 "createLoginContext.*" : name);
126     }
127 
128     /**
129      * Creates a new AuthPermission object with the specified name.
130      * The name is the symbolic name of the AuthPermission, and the
131      * actions string is currently unused and should be null.
132      *
133      * <p>
134      *
135      * @param name the name of the AuthPermission <p>
136      *
137      * @param actions should be null.
138      *
139      * @throws NullPointerException if {@code name} is {@code null}.
140      * @throws IllegalArgumentException if {@code name} is empty.
141      */
142     public this(string name, string actions) {
143         // for backwards compatibility --
144         // createLoginContext is deprecated in favor of createLoginContext.*
145         super("createLoginContext" == name ?
146                 "createLoginContext.*" : name, actions);
147     }
148 }