KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)NTSidDomainPrincipal.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 domain SID.
13  *
14  * <p> An NT user only has a domain SID if in fact they are logged
15  * into an NT domain. If the user is logged into a workgroup or
16  * just a standalone configuration, they will NOT have a domain SID.
17  *
18  * <p> Principals such as this <code>NTSidDomainPrincipal</code>
19  * may be associated with a particular <code>Subject</code>
20  * to augment that <code>Subject</code> with an additional
21  * identity. Refer to the <code>Subject</code> class for more information
22  * on how to achieve this. Authorization decisions can then be based upon
23  * the Principals associated with a <code>Subject</code>.
24  *
25  * @version 1.15, 12/19/03
26  * @see java.security.Principal
27  * @see javax.security.auth.Subject
28  */

29 public class NTSidDomainPrincipal extends NTSid {
30
31     private static final long serialVersionUID = 5247810785821650912L;
32
33     /**
34      * Create an <code>NTSidDomainPrincipal</code> with a Windows NT SID.
35      *
36      * <p>
37      *
38      * @param name a string version of the Windows NT SID for this
39      * user's domain.<p>
40      *
41      * @exception NullPointerException if the <code>name</code>
42      * is <code>null</code>.
43      */

44     public NTSidDomainPrincipal(String JavaDoc name) {
45         super(name);
46     }
47     
48     /**
49      * Return a string representation of this <code>NTSidDomainPrincipal</code>.
50      *
51      * <p>
52      *
53      * @return a string representation of this
54      * <code>NTSidDomainPrincipal</code>.
55      */

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

79     public boolean equals(Object JavaDoc o) {
80         if (o == null)
81             return false;
82
83         if (this == o)
84             return true;
85  
86         if (!(o instanceof NTSidDomainPrincipal))
87             return false;
88
89         return super.equals(o);
90     }
91 }
92
Popular Tags