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
50 * @serial
51 */
52 private String name;
53
54 /**
55 * Create a <code>UnixNumericUserPrincipal</code> using a
56 * <code>String</code> representation of the
57 * user's identification number (UID).
58 *
59 * <p>
60 *
61 * @param name the user identification number (UID) for this user.
62 *
63 * @exception NullPointerException if the <code>name</code>
64 * is <code>null</code>.
65 */
66 public UnixNumericUserPrincipal(String name) {
67 if (name == null) {
68 java.text.MessageFormat form = new java.text.MessageFormat
69 (sun.security.util.ResourcesMgr.getString
70 ("invalid null input: value",
71 "sun.security.util.AuthResources"));
72 Object[] source = {"name"};
73 throw new NullPointerException(form.format(source));
74 }
75
76 this.name = name;
77 }
78
79 /**
80 * Create a <code>UnixNumericUserPrincipal</code> using a
81 * long representation of the user's identification number (UID).
82 *
83 * <p>
84 *
85 * @param name the user identification number (UID) for this user
86 * represented as a long.
87 */
88 public UnixNumericUserPrincipal(long name) {
89 this.name = (new Long(name)).toString();
90 }
110 *
111 * @return the user identification number (UID) for this
112 * <code>UnixNumericUserPrincipal</code> as a long.
113 */
114 public long longValue() {
115 return ((new Long(name)).longValue());
116 }
117
118 /**
119 * Return a string representation of this
120 * <code>UnixNumericUserPrincipal</code>.
121 *
122 * <p>
123 *
124 * @return a string representation of this
125 * <code>UnixNumericUserPrincipal</code>.
126 */
127 public String toString() {
128 java.text.MessageFormat form = new java.text.MessageFormat
129 (sun.security.util.ResourcesMgr.getString
130 ("UnixNumericUserPrincipal: name",
131 "sun.security.util.AuthResources"));
132 Object[] source = {name};
133 return form.format(source);
134 }
135
136 /**
137 * Compares the specified Object with this
138 * <code>UnixNumericUserPrincipal</code>
139 * for equality. Returns true if the given object is also a
140 * <code>UnixNumericUserPrincipal</code> and the two
141 * UnixNumericUserPrincipals
142 * have the same user identification number (UID).
143 *
144 * <p>
145 *
146 * @param o Object to be compared for equality with this
147 * <code>UnixNumericUserPrincipal</code>.
148 *
149 * @return true if the specified Object is equal equal to this
150 * <code>UnixNumericUserPrincipal</code>.
|
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
50 * @serial
51 */
52 private String name;
53
54 /**
55 * Create a <code>UnixNumericUserPrincipal</code> using a
56 * <code>String</code> representation of the
57 * user's identification number (UID).
58 *
59 * <p>
60 *
61 * @param name the user identification number (UID) for this user.
62 *
63 * @exception NullPointerException if the <code>name</code>
64 * is <code>null</code>.
65 */
66 public UnixNumericUserPrincipal(String name) {
67 if (name == null) {
68 java.text.MessageFormat form = new java.text.MessageFormat
69 (sun.security.util.ResourcesMgr.getString
70 ("invalid.null.input.value",
71 "sun.security.util.AuthResources"));
72 Object[] source = {"name"};
73 throw new NullPointerException(form.format(source));
74 }
75
76 this.name = name;
77 }
78
79 /**
80 * Create a <code>UnixNumericUserPrincipal</code> using a
81 * long representation of the user's identification number (UID).
82 *
83 * <p>
84 *
85 * @param name the user identification number (UID) for this user
86 * represented as a long.
87 */
88 public UnixNumericUserPrincipal(long name) {
89 this.name = (new Long(name)).toString();
90 }
110 *
111 * @return the user identification number (UID) for this
112 * <code>UnixNumericUserPrincipal</code> as a long.
113 */
114 public long longValue() {
115 return ((new Long(name)).longValue());
116 }
117
118 /**
119 * Return a string representation of this
120 * <code>UnixNumericUserPrincipal</code>.
121 *
122 * <p>
123 *
124 * @return a string representation of this
125 * <code>UnixNumericUserPrincipal</code>.
126 */
127 public String toString() {
128 java.text.MessageFormat form = new java.text.MessageFormat
129 (sun.security.util.ResourcesMgr.getString
130 ("UnixNumericUserPrincipal.name",
131 "sun.security.util.AuthResources"));
132 Object[] source = {name};
133 return form.format(source);
134 }
135
136 /**
137 * Compares the specified Object with this
138 * <code>UnixNumericUserPrincipal</code>
139 * for equality. Returns true if the given object is also a
140 * <code>UnixNumericUserPrincipal</code> and the two
141 * UnixNumericUserPrincipals
142 * have the same user identification number (UID).
143 *
144 * <p>
145 *
146 * @param o Object to be compared for equality with this
147 * <code>UnixNumericUserPrincipal</code>.
148 *
149 * @return true if the specified Object is equal equal to this
150 * <code>UnixNumericUserPrincipal</code>.
|