author | weijun |
Fri, 17 Jun 2016 09:46:34 +0800 | |
changeset 39047 | cf08ea56b4de |
parent 34894 | 3248b89d1921 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
20742
diff
changeset
|
2 |
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.security.auth.module; |
|
27 |
||
28 |
/** |
|
30044
bab15bbe2ca3
8078528: clean out tidy warnings from security.auth
avstepan
parents:
25859
diff
changeset
|
29 |
* This class implementation retrieves and makes available NT |
2 | 30 |
* security information for the current user. |
31 |
* |
|
32 |
*/ |
|
33 |
public class NTSystem { |
|
34 |
||
35 |
private native void getCurrent(boolean debug); |
|
10429 | 36 |
private native long getImpersonationToken0(); |
2 | 37 |
|
38 |
private String userName; |
|
39 |
private String domain; |
|
40 |
private String domainSID; |
|
41 |
private String userSID; |
|
31538
0981099a3e54
8130022: Use Java-style array declarations consistently
igerasim
parents:
30044
diff
changeset
|
42 |
private String[] groupIDs; |
2 | 43 |
private String primaryGroupID; |
44 |
private long impersonationToken; |
|
45 |
||
46 |
/** |
|
30044
bab15bbe2ca3
8078528: clean out tidy warnings from security.auth
avstepan
parents:
25859
diff
changeset
|
47 |
* Instantiate an {@code NTSystem} and load |
2 | 48 |
* the native library to access the underlying system information. |
49 |
*/ |
|
50 |
public NTSystem() { |
|
51 |
this(false); |
|
52 |
} |
|
53 |
||
54 |
/** |
|
30044
bab15bbe2ca3
8078528: clean out tidy warnings from security.auth
avstepan
parents:
25859
diff
changeset
|
55 |
* Instantiate an {@code NTSystem} and load |
2 | 56 |
* the native library to access the underlying system information. |
57 |
*/ |
|
58 |
NTSystem(boolean debug) { |
|
59 |
loadNative(); |
|
60 |
getCurrent(debug); |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
* Get the username for the current NT user. |
|
65 |
* |
|
66 |
* @return the username for the current NT user. |
|
67 |
*/ |
|
68 |
public String getName() { |
|
69 |
return userName; |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Get the domain for the current NT user. |
|
74 |
* |
|
75 |
* @return the domain for the current NT user. |
|
76 |
*/ |
|
77 |
public String getDomain() { |
|
78 |
return domain; |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Get a printable SID for the current NT user's domain. |
|
83 |
* |
|
84 |
* @return a printable SID for the current NT user's domain. |
|
85 |
*/ |
|
86 |
public String getDomainSID() { |
|
87 |
return domainSID; |
|
88 |
} |
|
89 |
||
90 |
/** |
|
91 |
* Get a printable SID for the current NT user. |
|
92 |
* |
|
93 |
* @return a printable SID for the current NT user. |
|
94 |
*/ |
|
95 |
public String getUserSID() { |
|
96 |
return userSID; |
|
97 |
} |
|
98 |
||
99 |
/** |
|
100 |
* Get a printable primary group SID for the current NT user. |
|
101 |
* |
|
102 |
* @return the primary group SID for the current NT user. |
|
103 |
*/ |
|
104 |
public String getPrimaryGroupID() { |
|
105 |
return primaryGroupID; |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* Get the printable group SIDs for the current NT user. |
|
110 |
* |
|
111 |
* @return the group SIDs for the current NT user. |
|
112 |
*/ |
|
113 |
public String[] getGroupIDs() { |
|
7528
aae1ca8d088f
6992964: FindBugs warnings in com.sun.security.auth.module.UnixSystem.java
weijun
parents:
5506
diff
changeset
|
114 |
return groupIDs == null ? null : groupIDs.clone(); |
2 | 115 |
} |
116 |
||
117 |
/** |
|
118 |
* Get an impersonation token for the current NT user. |
|
119 |
* |
|
120 |
* @return an impersonation token for the current NT user. |
|
121 |
*/ |
|
10429 | 122 |
public synchronized long getImpersonationToken() { |
123 |
if (impersonationToken == 0) { |
|
124 |
impersonationToken = getImpersonationToken0(); |
|
125 |
} |
|
2 | 126 |
return impersonationToken; |
127 |
} |
|
128 |
||
10429 | 129 |
|
2 | 130 |
private void loadNative() { |
131 |
System.loadLibrary("jaas_nt"); |
|
132 |
} |
|
133 |
} |