KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)NTSidUserPrincipal.java 1.15 03/12/19
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 /**
11  * <p> This class extends <code>NTSid</code>
12  * and represents a Windows NT user's SID.
13  *
14  * <p> Principals such as this <code>NTSidUserPrincipal</code>
15  * may be associated with a particular <code>Subject</code>
16  * to augment that <code>Subject</code> with an additional
17  * identity. Refer to the <code>Subject</code> class for more information
18  * on how to achieve this. Authorization decisions can then be based upon
19  * the Principals associated with a <code>Subject</code>.
20  *
21  * @version 1.15, 12/19/03
22  * @see java.security.Principal
23  * @see javax.security.auth.Subject
24  */

25 public class NTSidUserPrincipal extends NTSid {
26
27     private static final long serialVersionUID = -5573239889517749525L;
28
29     /**
30      * Create an <code>NTSidUserPrincipal</code> with a Windows NT SID.
31      *
32      * <p>
33      *
34      * @param name a string version of the Windows NT SID for this user.<p>
35      *
36      * @exception NullPointerException if the <code>name</code>
37      * is <code>null</code>.
38      */

39     public NTSidUserPrincipal(String JavaDoc name) {
40         super(name);
41     }
42     
43     /**
44      * Return a string representation of this <code>NTSidUserPrincipal</code>.
45      *
46      * <p>
47      *
48      * @return a string representation of this <code>NTSidUserPrincipal</code>.
49      */

50     public String JavaDoc toString() {
51         java.text.MessageFormat JavaDoc form = new java.text.MessageFormat JavaDoc
52                 (sun.security.util.ResourcesMgr.getString
53                     ("NTSidUserPrincipal: name",
54             "sun.security.util.AuthResources"));
55         Object JavaDoc[] source = {getName()};
56         return form.format(source);
57     }
58     
59     /**
60      * Compares the specified Object with this <code>NTSidUserPrincipal</code>
61      * for equality. Returns true if the given object is also a
62      * <code>NTSidUserPrincipal</code> and the two NTSidUserPrincipals
63      * have the same SID.
64      *
65      * <p>
66      *
67      * @param o Object to be compared for equality with this
68      * <code>NTSidUserPrincipal</code>.
69      *
70      * @return true if the specified Object is equal equal to this
71      * <code>NTSidUserPrincipal</code>.
72      */

73     public boolean equals(Object JavaDoc o) {
74         if (o == null)
75             return false;
76
77         if (this == o)
78             return true;
79  
80         if (!(o instanceof NTSidUserPrincipal))
81             return false;
82             
83         return super.equals(o);
84     }
85 }
86
Popular Tags