001: /*
002: * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.security.auth.module;
027:
028: import javax.security.auth.login.LoginException;
029:
030: /**
031: * <p> This class implementation retrieves and makes available NT
032: * security information for the current user.
033: *
034: * @version 1.17, 05/05/07
035: */
036: public class NTSystem {
037:
038: private native void getCurrent(boolean debug);
039:
040: private String userName;
041: private String domain;
042: private String domainSID;
043: private String userSID;
044: private String groupIDs[];
045: private String primaryGroupID;
046: private long impersonationToken;
047:
048: /**
049: * Instantiate an <code>NTSystem</code> and load
050: * the native library to access the underlying system information.
051: */
052: public NTSystem() {
053: this (false);
054: }
055:
056: /**
057: * Instantiate an <code>NTSystem</code> and load
058: * the native library to access the underlying system information.
059: */
060: NTSystem(boolean debug) {
061: loadNative();
062: getCurrent(debug);
063: }
064:
065: /**
066: * Get the username for the current NT user.
067: *
068: * <p>
069: *
070: * @return the username for the current NT user.
071: */
072: public String getName() {
073: return userName;
074: }
075:
076: /**
077: * Get the domain for the current NT user.
078: *
079: * <p>
080: *
081: * @return the domain for the current NT user.
082: */
083: public String getDomain() {
084: return domain;
085: }
086:
087: /**
088: * Get a printable SID for the current NT user's domain.
089: *
090: * <p>
091: *
092: * @return a printable SID for the current NT user's domain.
093: */
094: public String getDomainSID() {
095: return domainSID;
096: }
097:
098: /**
099: * Get a printable SID for the current NT user.
100: *
101: * <p>
102: *
103: * @return a printable SID for the current NT user.
104: */
105: public String getUserSID() {
106: return userSID;
107: }
108:
109: /**
110: * Get a printable primary group SID for the current NT user.
111: *
112: * <p>
113: *
114: * @return the primary group SID for the current NT user.
115: */
116: public String getPrimaryGroupID() {
117: return primaryGroupID;
118: }
119:
120: /**
121: * Get the printable group SIDs for the current NT user.
122: *
123: * <p>
124: *
125: * @return the group SIDs for the current NT user.
126: */
127: public String[] getGroupIDs() {
128: return groupIDs;
129: }
130:
131: /**
132: * Get an impersonation token for the current NT user.
133: *
134: * <p>
135: *
136: * @return an impersonation token for the current NT user.
137: */
138: public long getImpersonationToken() {
139: return impersonationToken;
140: }
141:
142: private void loadNative() {
143: System.loadLibrary("jaas_nt");
144: }
145: }
|