Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java
38924 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.security.auth;2627import java.security.Principal;2829/**30* <p> This class implements the <code>Principal</code> interface31* and represents a user's Solaris identification number (UID).32*33* <p> Principals such as this <code>SolarisNumericUserPrincipal</code>34* may be associated with a particular <code>Subject</code>35* to augment that <code>Subject</code> with an additional36* identity. Refer to the <code>Subject</code> class for more information37* on how to achieve this. Authorization decisions can then be based upon38* the Principals associated with a <code>Subject</code>.39* @deprecated As of JDK 1.4, replaced by40* {@link UnixNumericUserPrincipal}.41* This class is entirely deprecated.42*43* @see java.security.Principal44* @see javax.security.auth.Subject45*/46@jdk.Exported(false)47@Deprecated48public class SolarisNumericUserPrincipal implements49Principal,50java.io.Serializable {5152private static final long serialVersionUID = -3178578484679887104L;5354private static final java.util.ResourceBundle rb =55java.security.AccessController.doPrivileged56(new java.security.PrivilegedAction<java.util.ResourceBundle>() {57public java.util.ResourceBundle run() {58return (java.util.ResourceBundle.getBundle59("sun.security.util.AuthResources"));60}61});626364/**65* @serial66*/67private String name;6869/**70* Create a <code>SolarisNumericUserPrincipal</code> using a71* <code>String</code> representation of the72* user's identification number (UID).73*74* <p>75*76* @param name the user identification number (UID) for this user.77*78* @exception NullPointerException if the <code>name</code>79* is <code>null</code>.80*/81public SolarisNumericUserPrincipal(String name) {82if (name == null)83throw new NullPointerException(rb.getString("provided.null.name"));8485this.name = name;86}8788/**89* Create a <code>SolarisNumericUserPrincipal</code> using a90* long representation of the user's identification number (UID).91*92* <p>93*94* @param name the user identification number (UID) for this user95* represented as a long.96*/97public SolarisNumericUserPrincipal(long name) {98this.name = (new Long(name)).toString();99}100101/**102* Return the user identification number (UID) for this103* <code>SolarisNumericUserPrincipal</code>.104*105* <p>106*107* @return the user identification number (UID) for this108* <code>SolarisNumericUserPrincipal</code>109*/110public String getName() {111return name;112}113114/**115* Return the user identification number (UID) for this116* <code>SolarisNumericUserPrincipal</code> as a long.117*118* <p>119*120* @return the user identification number (UID) for this121* <code>SolarisNumericUserPrincipal</code> as a long.122*/123public long longValue() {124return ((new Long(name)).longValue());125}126127/**128* Return a string representation of this129* <code>SolarisNumericUserPrincipal</code>.130*131* <p>132*133* @return a string representation of this134* <code>SolarisNumericUserPrincipal</code>.135*/136public String toString() {137return(rb.getString("SolarisNumericUserPrincipal.") + name);138}139140/**141* Compares the specified Object with this142* <code>SolarisNumericUserPrincipal</code>143* for equality. Returns true if the given object is also a144* <code>SolarisNumericUserPrincipal</code> and the two145* SolarisNumericUserPrincipals146* have the same user identification number (UID).147*148* <p>149*150* @param o Object to be compared for equality with this151* <code>SolarisNumericUserPrincipal</code>.152*153* @return true if the specified Object is equal equal to this154* <code>SolarisNumericUserPrincipal</code>.155*/156public boolean equals(Object o) {157if (o == null)158return false;159160if (this == o)161return true;162163if (!(o instanceof SolarisNumericUserPrincipal))164return false;165SolarisNumericUserPrincipal that = (SolarisNumericUserPrincipal)o;166167if (this.getName().equals(that.getName()))168return true;169return false;170}171172/**173* Return a hash code for this <code>SolarisNumericUserPrincipal</code>.174*175* <p>176*177* @return a hash code for this <code>SolarisNumericUserPrincipal</code>.178*/179public int hashCode() {180return name.hashCode();181}182}183184185