1 /*
2 * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
60 /**
61 * Create a <code>UnixNumericGroupPrincipal</code> using a
62 * <code>String</code> representation of the user's
63 * group identification number (GID).
64 *
65 * <p>
66 *
67 * @param name the user's group identification number (GID)
68 * for this user. <p>
69 *
70 * @param primaryGroup true if the specified GID represents the
71 * primary group to which this user belongs.
72 *
73 * @exception NullPointerException if the <code>name</code>
74 * is <code>null</code>.
75 */
76 public UnixNumericGroupPrincipal(String name, boolean primaryGroup) {
77 if (name == null) {
78 java.text.MessageFormat form = new java.text.MessageFormat
79 (sun.security.util.ResourcesMgr.getString
80 ("invalid null input: value",
81 "sun.security.util.AuthResources"));
82 Object[] source = {"name"};
83 throw new NullPointerException(form.format(source));
84 }
85
86 this.name = name;
87 this.primaryGroup = primaryGroup;
88 }
89
90 /**
91 * Create a <code>UnixNumericGroupPrincipal</code> using a
92 * long representation of the user's group identification number (GID).
93 *
94 * <p>
95 *
96 * @param name the user's group identification number (GID) for this user
97 * represented as a long. <p>
98 *
99 * @param primaryGroup true if the specified GID represents the
100 * primary group to which this user belongs.
142 * or false otherwise.
143 */
144 public boolean isPrimaryGroup() {
145 return primaryGroup;
146 }
147
148 /**
149 * Return a string representation of this
150 * <code>UnixNumericGroupPrincipal</code>.
151 *
152 * <p>
153 *
154 * @return a string representation of this
155 * <code>UnixNumericGroupPrincipal</code>.
156 */
157 public String toString() {
158
159 if (primaryGroup) {
160 java.text.MessageFormat form = new java.text.MessageFormat
161 (sun.security.util.ResourcesMgr.getString
162 ("UnixNumericGroupPrincipal [Primary Group]: name",
163 "sun.security.util.AuthResources"));
164 Object[] source = {name};
165 return form.format(source);
166 } else {
167 java.text.MessageFormat form = new java.text.MessageFormat
168 (sun.security.util.ResourcesMgr.getString
169 ("UnixNumericGroupPrincipal [Supplementary Group]: name",
170 "sun.security.util.AuthResources"));
171 Object[] source = {name};
172 return form.format(source);
173 }
174 }
175
176 /**
177 * Compares the specified Object with this
178 * <code>UnixNumericGroupPrincipal</code>
179 * for equality. Returns true if the given object is also a
180 * <code>UnixNumericGroupPrincipal</code> and the two
181 * UnixNumericGroupPrincipals
182 * have the same group identification number (GID).
183 *
184 * <p>
185 *
186 * @param o Object to be compared for equality with this
187 * <code>UnixNumericGroupPrincipal</code>.
188 *
189 * @return true if the specified Object is equal equal to this
|
1 /*
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
60 /**
61 * Create a <code>UnixNumericGroupPrincipal</code> using a
62 * <code>String</code> representation of the user's
63 * group identification number (GID).
64 *
65 * <p>
66 *
67 * @param name the user's group identification number (GID)
68 * for this user. <p>
69 *
70 * @param primaryGroup true if the specified GID represents the
71 * primary group to which this user belongs.
72 *
73 * @exception NullPointerException if the <code>name</code>
74 * is <code>null</code>.
75 */
76 public UnixNumericGroupPrincipal(String name, boolean primaryGroup) {
77 if (name == null) {
78 java.text.MessageFormat form = new java.text.MessageFormat
79 (sun.security.util.ResourcesMgr.getString
80 ("invalid.null.input.value",
81 "sun.security.util.AuthResources"));
82 Object[] source = {"name"};
83 throw new NullPointerException(form.format(source));
84 }
85
86 this.name = name;
87 this.primaryGroup = primaryGroup;
88 }
89
90 /**
91 * Create a <code>UnixNumericGroupPrincipal</code> using a
92 * long representation of the user's group identification number (GID).
93 *
94 * <p>
95 *
96 * @param name the user's group identification number (GID) for this user
97 * represented as a long. <p>
98 *
99 * @param primaryGroup true if the specified GID represents the
100 * primary group to which this user belongs.
142 * or false otherwise.
143 */
144 public boolean isPrimaryGroup() {
145 return primaryGroup;
146 }
147
148 /**
149 * Return a string representation of this
150 * <code>UnixNumericGroupPrincipal</code>.
151 *
152 * <p>
153 *
154 * @return a string representation of this
155 * <code>UnixNumericGroupPrincipal</code>.
156 */
157 public String toString() {
158
159 if (primaryGroup) {
160 java.text.MessageFormat form = new java.text.MessageFormat
161 (sun.security.util.ResourcesMgr.getString
162 ("UnixNumericGroupPrincipal.Primary.Group.name",
163 "sun.security.util.AuthResources"));
164 Object[] source = {name};
165 return form.format(source);
166 } else {
167 java.text.MessageFormat form = new java.text.MessageFormat
168 (sun.security.util.ResourcesMgr.getString
169 ("UnixNumericGroupPrincipal.Supplementary.Group.name",
170 "sun.security.util.AuthResources"));
171 Object[] source = {name};
172 return form.format(source);
173 }
174 }
175
176 /**
177 * Compares the specified Object with this
178 * <code>UnixNumericGroupPrincipal</code>
179 * for equality. Returns true if the given object is also a
180 * <code>UnixNumericGroupPrincipal</code> and the two
181 * UnixNumericGroupPrincipals
182 * have the same group identification number (GID).
183 *
184 * <p>
185 *
186 * @param o Object to be compared for equality with this
187 * <code>UnixNumericGroupPrincipal</code>.
188 *
189 * @return true if the specified Object is equal equal to this
|