26 package com.sun.security.auth; |
26 package com.sun.security.auth; |
27 |
27 |
28 import java.security.Principal; |
28 import java.security.Principal; |
29 |
29 |
30 /** |
30 /** |
31 * <p> This class implements the <code>Principal</code> interface |
31 * This class implements the {@code Principal} interface |
32 * and represents a user's Solaris group identification number (GID). |
32 * and represents a user's Solaris group identification number (GID). |
33 * |
33 * |
34 * <p> Principals such as this <code>SolarisNumericGroupPrincipal</code> |
34 * <p> Principals such as this {@code SolarisNumericGroupPrincipal} |
35 * may be associated with a particular <code>Subject</code> |
35 * may be associated with a particular {@code Subject} |
36 * to augment that <code>Subject</code> with an additional |
36 * to augment that {@code Subject} with an additional |
37 * identity. Refer to the <code>Subject</code> class for more information |
37 * identity. Refer to the {@code Subject} class for more information |
38 * on how to achieve this. Authorization decisions can then be based upon |
38 * on how to achieve this. Authorization decisions can then be based upon |
39 * the Principals associated with a <code>Subject</code>. |
39 * the Principals associated with a {@code Subject}. |
40 |
40 |
41 * @deprecated As of JDK 1.4, replaced by |
41 * @deprecated As of JDK 1.4, replaced by |
42 * {@link UnixNumericGroupPrincipal}. |
42 * {@link UnixNumericGroupPrincipal}. |
43 * This class is entirely deprecated. |
43 * This class is entirely deprecated. |
44 * |
44 * |
71 * @serial |
71 * @serial |
72 */ |
72 */ |
73 private boolean primaryGroup; |
73 private boolean primaryGroup; |
74 |
74 |
75 /** |
75 /** |
76 * Create a <code>SolarisNumericGroupPrincipal</code> using a |
76 * Create a {@code SolarisNumericGroupPrincipal} using a |
77 * <code>String</code> representation of the user's |
77 * {@code String} representation of the user's |
78 * group identification number (GID). |
78 * group identification number (GID). |
79 * |
79 * |
80 * <p> |
|
81 * |
|
82 * @param name the user's group identification number (GID) |
80 * @param name the user's group identification number (GID) |
83 * for this user. <p> |
81 * for this user. |
84 * |
82 * |
85 * @param primaryGroup true if the specified GID represents the |
83 * @param primaryGroup true if the specified GID represents the |
86 * primary group to which this user belongs. |
84 * primary group to which this user belongs. |
87 * |
85 * |
88 * @exception NullPointerException if the <code>name</code> |
86 * @exception NullPointerException if the {@code name} |
89 * is <code>null</code>. |
87 * is {@code null}. |
90 */ |
88 */ |
91 public SolarisNumericGroupPrincipal(String name, boolean primaryGroup) { |
89 public SolarisNumericGroupPrincipal(String name, boolean primaryGroup) { |
92 if (name == null) |
90 if (name == null) |
93 throw new NullPointerException(rb.getString("provided.null.name")); |
91 throw new NullPointerException(rb.getString("provided.null.name")); |
94 |
92 |
95 this.name = name; |
93 this.name = name; |
96 this.primaryGroup = primaryGroup; |
94 this.primaryGroup = primaryGroup; |
97 } |
95 } |
98 |
96 |
99 /** |
97 /** |
100 * Create a <code>SolarisNumericGroupPrincipal</code> using a |
98 * Create a {@code SolarisNumericGroupPrincipal} using a |
101 * long representation of the user's group identification number (GID). |
99 * long representation of the user's group identification number (GID). |
102 * |
100 * |
103 * <p> |
|
104 * |
|
105 * @param name the user's group identification number (GID) for this user |
101 * @param name the user's group identification number (GID) for this user |
106 * represented as a long. <p> |
102 * represented as a long. |
107 * |
103 * |
108 * @param primaryGroup true if the specified GID represents the |
104 * @param primaryGroup true if the specified GID represents the |
109 * primary group to which this user belongs. |
105 * primary group to which this user belongs. |
110 * |
106 * |
111 */ |
107 */ |
114 this.primaryGroup = primaryGroup; |
110 this.primaryGroup = primaryGroup; |
115 } |
111 } |
116 |
112 |
117 /** |
113 /** |
118 * Return the user's group identification number (GID) for this |
114 * Return the user's group identification number (GID) for this |
119 * <code>SolarisNumericGroupPrincipal</code>. |
115 * {@code SolarisNumericGroupPrincipal}. |
120 * |
|
121 * <p> |
|
122 * |
116 * |
123 * @return the user's group identification number (GID) for this |
117 * @return the user's group identification number (GID) for this |
124 * <code>SolarisNumericGroupPrincipal</code> |
118 * {@code SolarisNumericGroupPrincipal} |
125 */ |
119 */ |
126 public String getName() { |
120 public String getName() { |
127 return name; |
121 return name; |
128 } |
122 } |
129 |
123 |
130 /** |
124 /** |
131 * Return the user's group identification number (GID) for this |
125 * Return the user's group identification number (GID) for this |
132 * <code>SolarisNumericGroupPrincipal</code> as a long. |
126 * {@code SolarisNumericGroupPrincipal} as a long. |
133 * |
|
134 * <p> |
|
135 * |
127 * |
136 * @return the user's group identification number (GID) for this |
128 * @return the user's group identification number (GID) for this |
137 * <code>SolarisNumericGroupPrincipal</code> as a long. |
129 * {@code SolarisNumericGroupPrincipal} as a long. |
138 */ |
130 */ |
139 public long longValue() { |
131 public long longValue() { |
140 return Long.parseLong(name); |
132 return Long.parseLong(name); |
141 } |
133 } |
142 |
134 |
143 /** |
135 /** |
144 * Return whether this group identification number (GID) represents |
136 * Return whether this group identification number (GID) represents |
145 * the primary group to which this user belongs. |
137 * the primary group to which this user belongs. |
146 * |
|
147 * <p> |
|
148 * |
138 * |
149 * @return true if this group identification number (GID) represents |
139 * @return true if this group identification number (GID) represents |
150 * the primary group to which this user belongs, |
140 * the primary group to which this user belongs, |
151 * or false otherwise. |
141 * or false otherwise. |
152 */ |
142 */ |
154 return primaryGroup; |
144 return primaryGroup; |
155 } |
145 } |
156 |
146 |
157 /** |
147 /** |
158 * Return a string representation of this |
148 * Return a string representation of this |
159 * <code>SolarisNumericGroupPrincipal</code>. |
149 * {@code SolarisNumericGroupPrincipal}. |
160 * |
|
161 * <p> |
|
162 * |
150 * |
163 * @return a string representation of this |
151 * @return a string representation of this |
164 * <code>SolarisNumericGroupPrincipal</code>. |
152 * {@code SolarisNumericGroupPrincipal}. |
165 */ |
153 */ |
166 public String toString() { |
154 public String toString() { |
167 return((primaryGroup ? |
155 return((primaryGroup ? |
168 rb.getString |
156 rb.getString |
169 ("SolarisNumericGroupPrincipal.Primary.Group.") + name : |
157 ("SolarisNumericGroupPrincipal.Primary.Group.") + name : |
171 ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name)); |
159 ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name)); |
172 } |
160 } |
173 |
161 |
174 /** |
162 /** |
175 * Compares the specified Object with this |
163 * Compares the specified Object with this |
176 * <code>SolarisNumericGroupPrincipal</code> |
164 * {@code SolarisNumericGroupPrincipal} |
177 * for equality. Returns true if the given object is also a |
165 * for equality. Returns true if the given object is also a |
178 * <code>SolarisNumericGroupPrincipal</code> and the two |
166 * {@code SolarisNumericGroupPrincipal} and the two |
179 * SolarisNumericGroupPrincipals |
167 * SolarisNumericGroupPrincipals |
180 * have the same group identification number (GID). |
168 * have the same group identification number (GID). |
181 * |
169 * |
182 * <p> |
|
183 * |
|
184 * @param o Object to be compared for equality with this |
170 * @param o Object to be compared for equality with this |
185 * <code>SolarisNumericGroupPrincipal</code>. |
171 * {@code SolarisNumericGroupPrincipal}. |
186 * |
172 * |
187 * @return true if the specified Object is equal to this |
173 * @return true if the specified Object is equal to this |
188 * <code>SolarisNumericGroupPrincipal</code>. |
174 * {@code SolarisNumericGroupPrincipal}. |
189 */ |
175 */ |
190 public boolean equals(Object o) { |
176 public boolean equals(Object o) { |
191 if (o == null) |
177 if (o == null) |
192 return false; |
178 return false; |
193 |
179 |