KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > security > auth > module > NTSystem


1 /*
2  * @(#)NTSystem.java 1.10 06/06/23
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.security.auth.module;
9
10 import javax.security.auth.login.LoginException JavaDoc;
11
12 /**
13  * <p> This class implementation retrieves and makes available NT
14  * security information for the current user.
15  *
16  * @version 1.10, 06/23/06
17  */

18 public class NTSystem {
19     
20     private native void getCurrent(boolean debug);
21     
22     private String JavaDoc userName;
23     private String JavaDoc domain;
24     private String JavaDoc domainSID;
25     private String JavaDoc userSID;
26     private String JavaDoc groupIDs[];
27     private String JavaDoc primaryGroupID;
28     private long impersonationToken;
29     
30     /**
31      * Instantiate an <code>NTSystem</code> and load
32      * the native library to access the underlying system information.
33      */

34     public NTSystem() {
35     this(false);
36     }
37
38     /**
39      * Instantiate an <code>NTSystem</code> and load
40      * the native library to access the underlying system information.
41      */

42     NTSystem(boolean debug) {
43     loadNative();
44     getCurrent(debug);
45     }
46     
47     /**
48      * Get the username for the current NT user.
49      *
50      * <p>
51      *
52      * @return the username for the current NT user.
53      */

54     public String JavaDoc getName() {
55         return userName;
56     }
57     
58     /**
59      * Get the domain for the current NT user.
60      *
61      * <p>
62      *
63      * @return the domain for the current NT user.
64      */

65     public String JavaDoc getDomain() {
66         return domain;
67     }
68     
69     /**
70      * Get a printable SID for the current NT user's domain.
71      *
72      * <p>
73      *
74      * @return a printable SID for the current NT user's domain.
75      */

76     public String JavaDoc getDomainSID() {
77         return domainSID;
78     }
79         
80     /**
81      * Get a printable SID for the current NT user.
82      *
83      * <p>
84      *
85      * @return a printable SID for the current NT user.
86      */

87     public String JavaDoc getUserSID() {
88         return userSID;
89     }
90     
91     /**
92      * Get a printable primary group SID for the current NT user.
93      *
94      * <p>
95      *
96      * @return the primary group SID for the current NT user.
97      */

98     public String JavaDoc getPrimaryGroupID() {
99         return primaryGroupID;
100     }
101     
102     /**
103      * Get the printable group SIDs for the current NT user.
104      *
105      * <p>
106      *
107      * @return the group SIDs for the current NT user.
108      */

109     public String JavaDoc[] getGroupIDs() {
110         return groupIDs;
111     }
112     
113     /**
114      * Get an impersonation token for the current NT user.
115      *
116      * <p>
117      *
118      * @return an impersonation token for the current NT user.
119      */

120     public long getImpersonationToken() {
121         return impersonationToken;
122     }
123     
124     private void loadNative() {
125     System.loadLibrary("jaas_nt");
126     }
127 }
128
Popular Tags