KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > security > auth > SolarisPrincipal


1 /*
2  * @(#)SolarisPrincipal.java 1.17 04/05/18
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.security.auth;
9
10 import java.security.Principal JavaDoc;
11
12 /**
13  * <p> This class implements the <code>Principal</code> interface
14  * and represents a Solaris user.
15  *
16  * <p> Principals such as this <code>SolarisPrincipal</code>
17  * may be associated with a particular <code>Subject</code>
18  * to augment that <code>Subject</code> with an additional
19  * identity. Refer to the <code>Subject</code> class for more information
20  * on how to achieve this. Authorization decisions can then be based upon
21  * the Principals associated with a <code>Subject</code>.
22  *
23  * @deprecated As of JDK&nbsp;1.4, replaced by
24  * {@link UnixPrincipal}.
25  * This class is entirely deprecated.
26  * @version 1.17, 05/18/04
27  * @see java.security.Principal
28  * @see javax.security.auth.Subject
29  */

30 @Deprecated JavaDoc
31 public class SolarisPrincipal implements Principal JavaDoc, java.io.Serializable JavaDoc {
32
33     private static final long serialVersionUID = -7840670002439379038L;
34
35     private static final java.util.ResourceBundle JavaDoc rb =
36           (java.util.ResourceBundle JavaDoc)java.security.AccessController.doPrivileged
37           (new java.security.PrivilegedAction JavaDoc() {
38               public Object JavaDoc run() {
39                   return (java.util.ResourceBundle.getBundle
40                                 ("sun.security.util.AuthResources"));
41               }
42           });
43
44
45     /**
46      * @serial
47      */

48     private String JavaDoc name;
49
50     /**
51      * Create a SolarisPrincipal with a Solaris username.
52      *
53      * <p>
54      *
55      * @param name the Unix username for this user.
56      *
57      * @exception NullPointerException if the <code>name</code>
58      * is <code>null</code>.
59      */

60     public SolarisPrincipal(String JavaDoc name) {
61     if (name == null)
62         throw new NullPointerException JavaDoc(rb.getString("provided null name"));
63
64     this.name = name;
65     }
66
67     /**
68      * Return the Unix username for this <code>SolarisPrincipal</code>.
69      *
70      * <p>
71      *
72      * @return the Unix username for this <code>SolarisPrincipal</code>
73      */

74     public String JavaDoc getName() {
75     return name;
76     }
77
78     /**
79      * Return a string representation of this <code>SolarisPrincipal</code>.
80      *
81      * <p>
82      *
83      * @return a string representation of this <code>SolarisPrincipal</code>.
84      */

85     public String JavaDoc toString() {
86     return(rb.getString("SolarisPrincipal: ") + name);
87     }
88
89     /**
90      * Compares the specified Object with this <code>SolarisPrincipal</code>
91      * for equality. Returns true if the given object is also a
92      * <code>SolarisPrincipal</code> and the two SolarisPrincipals
93      * have the same username.
94      *
95      * <p>
96      *
97      * @param o Object to be compared for equality with this
98      * <code>SolarisPrincipal</code>.
99      *
100      * @return true if the specified Object is equal equal to this
101      * <code>SolarisPrincipal</code>.
102      */

103     public boolean equals(Object JavaDoc o) {
104     if (o == null)
105         return false;
106
107         if (this == o)
108             return true;
109  
110         if (!(o instanceof SolarisPrincipal))
111             return false;
112         SolarisPrincipal that = (SolarisPrincipal)o;
113
114     if (this.getName().equals(that.getName()))
115         return true;
116     return false;
117     }
118  
119     /**
120      * Return a hash code for this <code>SolarisPrincipal</code>.
121      *
122      * <p>
123      *
124      * @return a hash code for this <code>SolarisPrincipal</code>.
125      */

126     public int hashCode() {
127     return name.hashCode();
128     }
129 }
130
Popular Tags