Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/security/auth/SolarisPrincipal.java
38924 views
1
/*
2
* Copyright (c) 1999, 2013, 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
23
* questions.
24
*/
25
26
package com.sun.security.auth;
27
28
import java.security.Principal;
29
30
/**
31
* <p> This class implements the <code>Principal</code> interface
32
* and represents a Solaris user.
33
*
34
* <p> Principals such as this <code>SolarisPrincipal</code>
35
* may be associated with a particular <code>Subject</code>
36
* to augment that <code>Subject</code> with an additional
37
* identity. Refer to the <code>Subject</code> class for more information
38
* on how to achieve this. Authorization decisions can then be based upon
39
* the Principals associated with a <code>Subject</code>.
40
*
41
* @deprecated As of JDK&nbsp;1.4, replaced by
42
* {@link UnixPrincipal}.
43
* This class is entirely deprecated.
44
* @see java.security.Principal
45
* @see javax.security.auth.Subject
46
*/
47
@jdk.Exported(false)
48
@Deprecated
49
public class SolarisPrincipal implements Principal, java.io.Serializable {
50
51
private static final long serialVersionUID = -7840670002439379038L;
52
53
private static final java.util.ResourceBundle rb =
54
java.security.AccessController.doPrivileged
55
(new java.security.PrivilegedAction<java.util.ResourceBundle>() {
56
public java.util.ResourceBundle run() {
57
return (java.util.ResourceBundle.getBundle
58
("sun.security.util.AuthResources"));
59
}
60
});
61
62
63
/**
64
* @serial
65
*/
66
private String name;
67
68
/**
69
* Create a SolarisPrincipal with a Solaris username.
70
*
71
* <p>
72
*
73
* @param name the Unix username for this user.
74
*
75
* @exception NullPointerException if the <code>name</code>
76
* is <code>null</code>.
77
*/
78
public SolarisPrincipal(String name) {
79
if (name == null)
80
throw new NullPointerException(rb.getString("provided.null.name"));
81
82
this.name = name;
83
}
84
85
/**
86
* Return the Unix username for this <code>SolarisPrincipal</code>.
87
*
88
* <p>
89
*
90
* @return the Unix username for this <code>SolarisPrincipal</code>
91
*/
92
public String getName() {
93
return name;
94
}
95
96
/**
97
* Return a string representation of this <code>SolarisPrincipal</code>.
98
*
99
* <p>
100
*
101
* @return a string representation of this <code>SolarisPrincipal</code>.
102
*/
103
public String toString() {
104
return(rb.getString("SolarisPrincipal.") + name);
105
}
106
107
/**
108
* Compares the specified Object with this <code>SolarisPrincipal</code>
109
* for equality. Returns true if the given object is also a
110
* <code>SolarisPrincipal</code> and the two SolarisPrincipals
111
* have the same username.
112
*
113
* <p>
114
*
115
* @param o Object to be compared for equality with this
116
* <code>SolarisPrincipal</code>.
117
*
118
* @return true if the specified Object is equal equal to this
119
* <code>SolarisPrincipal</code>.
120
*/
121
public boolean equals(Object o) {
122
if (o == null)
123
return false;
124
125
if (this == o)
126
return true;
127
128
if (!(o instanceof SolarisPrincipal))
129
return false;
130
SolarisPrincipal that = (SolarisPrincipal)o;
131
132
if (this.getName().equals(that.getName()))
133
return true;
134
return false;
135
}
136
137
/**
138
* Return a hash code for this <code>SolarisPrincipal</code>.
139
*
140
* <p>
141
*
142
* @return a hash code for this <code>SolarisPrincipal</code>.
143
*/
144
public int hashCode() {
145
return name.hashCode();
146
}
147
}
148
149