Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/security/auth/SolarisPrincipal.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 Solaris user.32*33* <p> Principals such as this <code>SolarisPrincipal</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*40* @deprecated As of JDK 1.4, replaced by41* {@link UnixPrincipal}.42* This class is entirely deprecated.43* @see java.security.Principal44* @see javax.security.auth.Subject45*/46@jdk.Exported(false)47@Deprecated48public class SolarisPrincipal implements Principal, java.io.Serializable {4950private static final long serialVersionUID = -7840670002439379038L;5152private static final java.util.ResourceBundle rb =53java.security.AccessController.doPrivileged54(new java.security.PrivilegedAction<java.util.ResourceBundle>() {55public java.util.ResourceBundle run() {56return (java.util.ResourceBundle.getBundle57("sun.security.util.AuthResources"));58}59});606162/**63* @serial64*/65private String name;6667/**68* Create a SolarisPrincipal with a Solaris username.69*70* <p>71*72* @param name the Unix username for this user.73*74* @exception NullPointerException if the <code>name</code>75* is <code>null</code>.76*/77public SolarisPrincipal(String name) {78if (name == null)79throw new NullPointerException(rb.getString("provided.null.name"));8081this.name = name;82}8384/**85* Return the Unix username for this <code>SolarisPrincipal</code>.86*87* <p>88*89* @return the Unix username for this <code>SolarisPrincipal</code>90*/91public String getName() {92return name;93}9495/**96* Return a string representation of this <code>SolarisPrincipal</code>.97*98* <p>99*100* @return a string representation of this <code>SolarisPrincipal</code>.101*/102public String toString() {103return(rb.getString("SolarisPrincipal.") + name);104}105106/**107* Compares the specified Object with this <code>SolarisPrincipal</code>108* for equality. Returns true if the given object is also a109* <code>SolarisPrincipal</code> and the two SolarisPrincipals110* have the same username.111*112* <p>113*114* @param o Object to be compared for equality with this115* <code>SolarisPrincipal</code>.116*117* @return true if the specified Object is equal equal to this118* <code>SolarisPrincipal</code>.119*/120public boolean equals(Object o) {121if (o == null)122return false;123124if (this == o)125return true;126127if (!(o instanceof SolarisPrincipal))128return false;129SolarisPrincipal that = (SolarisPrincipal)o;130131if (this.getName().equals(that.getName()))132return true;133return false;134}135136/**137* Return a hash code for this <code>SolarisPrincipal</code>.138*139* <p>140*141* @return a hash code for this <code>SolarisPrincipal</code>.142*/143public int hashCode() {144return name.hashCode();145}146}147148149