26 package com.sun.security.auth; |
26 package com.sun.security.auth; |
27 |
27 |
28 import java.security.Principal; |
28 import java.security.Principal; |
29 |
29 |
30 /** |
30 /** |
31 * <p> This class implements the <code>Principal</code> interface |
31 * This class implements the {@code Principal} interface |
32 * and represents the name of the Windows NT domain into which the |
32 * and represents the name of the Windows NT domain into which the |
33 * user authenticated. This will be a domain name if the user logged |
33 * user authenticated. This will be a domain name if the user logged |
34 * into a Windows NT domain, a workgroup name if the user logged into |
34 * into a Windows NT domain, a workgroup name if the user logged into |
35 * a workgroup, or a machine name if the user logged into a standalone |
35 * a workgroup, or a machine name if the user logged into a standalone |
36 * configuration. |
36 * configuration. |
37 * |
37 * |
38 * <p> Principals such as this <code>NTDomainPrincipal</code> |
38 * <p> Principals such as this {@code NTDomainPrincipal} |
39 * may be associated with a particular <code>Subject</code> |
39 * may be associated with a particular {@code Subject} |
40 * to augment that <code>Subject</code> with an additional |
40 * to augment that {@code Subject} with an additional |
41 * identity. Refer to the <code>Subject</code> class for more information |
41 * identity. Refer to the {@code Subject} class for more information |
42 * on how to achieve this. Authorization decisions can then be based upon |
42 * on how to achieve this. Authorization decisions can then be based upon |
43 * the Principals associated with a <code>Subject</code>. |
43 * the Principals associated with a {@code Subject}. |
44 * |
44 * |
45 * @see java.security.Principal |
45 * @see java.security.Principal |
46 * @see javax.security.auth.Subject |
46 * @see javax.security.auth.Subject |
47 */ |
47 */ |
48 @jdk.Exported |
48 @jdk.Exported |
54 * @serial |
54 * @serial |
55 */ |
55 */ |
56 private String name; |
56 private String name; |
57 |
57 |
58 /** |
58 /** |
59 * Create an <code>NTDomainPrincipal</code> with a Windows NT domain name. |
59 * Create an {@code NTDomainPrincipal} with a Windows NT domain name. |
60 * |
60 * |
61 * <p> |
61 * @param name the Windows NT domain name for this user. |
62 * |
62 * |
63 * @param name the Windows NT domain name for this user. <p> |
63 * @exception NullPointerException if the {@code name} |
64 * |
64 * is {@code null}. |
65 * @exception NullPointerException if the <code>name</code> |
|
66 * is <code>null</code>. |
|
67 */ |
65 */ |
68 public NTDomainPrincipal(String name) { |
66 public NTDomainPrincipal(String name) { |
69 if (name == null) { |
67 if (name == null) { |
70 java.text.MessageFormat form = new java.text.MessageFormat |
68 java.text.MessageFormat form = new java.text.MessageFormat |
71 (sun.security.util.ResourcesMgr.getString |
69 (sun.security.util.ResourcesMgr.getString |
77 this.name = name; |
75 this.name = name; |
78 } |
76 } |
79 |
77 |
80 /** |
78 /** |
81 * Return the Windows NT domain name for this |
79 * Return the Windows NT domain name for this |
82 * <code>NTDomainPrincipal</code>. |
80 * {@code NTDomainPrincipal}. |
83 * |
|
84 * <p> |
|
85 * |
81 * |
86 * @return the Windows NT domain name for this |
82 * @return the Windows NT domain name for this |
87 * <code>NTDomainPrincipal</code> |
83 * {@code NTDomainPrincipal} |
88 */ |
84 */ |
89 public String getName() { |
85 public String getName() { |
90 return name; |
86 return name; |
91 } |
87 } |
92 |
88 |
93 /** |
89 /** |
94 * Return a string representation of this <code>NTDomainPrincipal</code>. |
90 * Return a string representation of this {@code NTDomainPrincipal}. |
95 * |
91 * |
96 * <p> |
92 * @return a string representation of this {@code NTDomainPrincipal}. |
97 * |
|
98 * @return a string representation of this <code>NTDomainPrincipal</code>. |
|
99 */ |
93 */ |
100 public String toString() { |
94 public String toString() { |
101 java.text.MessageFormat form = new java.text.MessageFormat |
95 java.text.MessageFormat form = new java.text.MessageFormat |
102 (sun.security.util.ResourcesMgr.getString |
96 (sun.security.util.ResourcesMgr.getString |
103 ("NTDomainPrincipal.name", |
97 ("NTDomainPrincipal.name", |
105 Object[] source = {name}; |
99 Object[] source = {name}; |
106 return form.format(source); |
100 return form.format(source); |
107 } |
101 } |
108 |
102 |
109 /** |
103 /** |
110 * Compares the specified Object with this <code>NTDomainPrincipal</code> |
104 * Compares the specified Object with this {@code NTDomainPrincipal} |
111 * for equality. Returns true if the given object is also a |
105 * for equality. Returns true if the given object is also a |
112 * <code>NTDomainPrincipal</code> and the two NTDomainPrincipals |
106 * {@code NTDomainPrincipal} and the two NTDomainPrincipals |
113 * have the same name. |
107 * have the same name. |
114 * |
108 * |
115 * <p> |
|
116 * |
|
117 * @param o Object to be compared for equality with this |
109 * @param o Object to be compared for equality with this |
118 * <code>NTDomainPrincipal</code>. |
110 * {@code NTDomainPrincipal}. |
119 * |
111 * |
120 * @return true if the specified Object is equal to this |
112 * @return true if the specified Object is equal to this |
121 * <code>NTDomainPrincipal</code>. |
113 * {@code NTDomainPrincipal}. |
122 */ |
114 */ |
123 public boolean equals(Object o) { |
115 public boolean equals(Object o) { |
124 if (o == null) |
116 if (o == null) |
125 return false; |
117 return false; |
126 |
118 |