author | weijun |
Wed, 25 Sep 2019 17:54:21 +0800 | |
changeset 58331 | e4ce29f6094e |
parent 49245 | 6c3054543ede |
permissions | -rw-r--r-- |
2 | 1 |
/* |
58331
e4ce29f6094e
8228659: Record which Java methods are called by native codes in JGSS and JAAS
weijun
parents:
49245
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, 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 |
|
58331
e4ce29f6094e
8228659: Record which Java methods are called by native codes in JGSS and JAAS
weijun
parents:
49245
diff
changeset
|
38 |
// Warning: the next 6 fields are used by nt.c |
2 | 39 |
private String userName; |
40 |
private String domain; |
|
41 |
private String domainSID; |
|
42 |
private String userSID; |
|
31538
0981099a3e54
8130022: Use Java-style array declarations consistently
igerasim
parents:
30044
diff
changeset
|
43 |
private String[] groupIDs; |
2 | 44 |
private String primaryGroupID; |
58331
e4ce29f6094e
8228659: Record which Java methods are called by native codes in JGSS and JAAS
weijun
parents:
49245
diff
changeset
|
45 |
|
2 | 46 |
private long impersonationToken; |
47 |
||
48 |
/** |
|
30044
bab15bbe2ca3
8078528: clean out tidy warnings from security.auth
avstepan
parents:
25859
diff
changeset
|
49 |
* Instantiate an {@code NTSystem} and load |
2 | 50 |
* the native library to access the underlying system information. |
51 |
*/ |
|
52 |
public NTSystem() { |
|
53 |
this(false); |
|
54 |
} |
|
55 |
||
56 |
/** |
|
30044
bab15bbe2ca3
8078528: clean out tidy warnings from security.auth
avstepan
parents:
25859
diff
changeset
|
57 |
* Instantiate an {@code NTSystem} and load |
2 | 58 |
* the native library to access the underlying system information. |
59 |
*/ |
|
60 |
NTSystem(boolean debug) { |
|
61 |
loadNative(); |
|
62 |
getCurrent(debug); |
|
63 |
} |
|
64 |
||
65 |
/** |
|
66 |
* Get the username for the current NT user. |
|
67 |
* |
|
68 |
* @return the username for the current NT user. |
|
69 |
*/ |
|
70 |
public String getName() { |
|
71 |
return userName; |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* Get the domain for the current NT user. |
|
76 |
* |
|
77 |
* @return the domain for the current NT user. |
|
78 |
*/ |
|
79 |
public String getDomain() { |
|
80 |
return domain; |
|
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* Get a printable SID for the current NT user's domain. |
|
85 |
* |
|
86 |
* @return a printable SID for the current NT user's domain. |
|
87 |
*/ |
|
88 |
public String getDomainSID() { |
|
89 |
return domainSID; |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* Get a printable SID for the current NT user. |
|
94 |
* |
|
95 |
* @return a printable SID for the current NT user. |
|
96 |
*/ |
|
97 |
public String getUserSID() { |
|
98 |
return userSID; |
|
99 |
} |
|
100 |
||
101 |
/** |
|
102 |
* Get a printable primary group SID for the current NT user. |
|
103 |
* |
|
104 |
* @return the primary group SID for the current NT user. |
|
105 |
*/ |
|
106 |
public String getPrimaryGroupID() { |
|
107 |
return primaryGroupID; |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* Get the printable group SIDs for the current NT user. |
|
112 |
* |
|
113 |
* @return the group SIDs for the current NT user. |
|
114 |
*/ |
|
115 |
public String[] getGroupIDs() { |
|
7528
aae1ca8d088f
6992964: FindBugs warnings in com.sun.security.auth.module.UnixSystem.java
weijun
parents:
5506
diff
changeset
|
116 |
return groupIDs == null ? null : groupIDs.clone(); |
2 | 117 |
} |
118 |
||
119 |
/** |
|
120 |
* Get an impersonation token for the current NT user. |
|
121 |
* |
|
122 |
* @return an impersonation token for the current NT user. |
|
123 |
*/ |
|
10429 | 124 |
public synchronized long getImpersonationToken() { |
125 |
if (impersonationToken == 0) { |
|
126 |
impersonationToken = getImpersonationToken0(); |
|
127 |
} |
|
2 | 128 |
return impersonationToken; |
129 |
} |
|
130 |
||
10429 | 131 |
|
2 | 132 |
private void loadNative() { |
49245 | 133 |
System.loadLibrary("jaas"); |
2 | 134 |
} |
135 |
} |