0N/A/*
4377N/A * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.security.auth.module;
0N/A
0N/A/**
0N/A * <p> This class implementation retrieves and makes available NT
0N/A * security information for the current user.
0N/A *
0N/A */
0N/Apublic class NTSystem {
0N/A
0N/A private native void getCurrent(boolean debug);
4377N/A private native long getImpersonationToken0();
0N/A
0N/A private String userName;
0N/A private String domain;
0N/A private String domainSID;
0N/A private String userSID;
0N/A private String groupIDs[];
0N/A private String primaryGroupID;
0N/A private long impersonationToken;
0N/A
0N/A /**
0N/A * Instantiate an <code>NTSystem</code> and load
0N/A * the native library to access the underlying system information.
0N/A */
0N/A public NTSystem() {
0N/A this(false);
0N/A }
0N/A
0N/A /**
0N/A * Instantiate an <code>NTSystem</code> and load
0N/A * the native library to access the underlying system information.
0N/A */
0N/A NTSystem(boolean debug) {
0N/A loadNative();
0N/A getCurrent(debug);
0N/A }
0N/A
0N/A /**
0N/A * Get the username for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the username for the current NT user.
0N/A */
0N/A public String getName() {
0N/A return userName;
0N/A }
0N/A
0N/A /**
0N/A * Get the domain for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the domain for the current NT user.
0N/A */
0N/A public String getDomain() {
0N/A return domain;
0N/A }
0N/A
0N/A /**
0N/A * Get a printable SID for the current NT user's domain.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return a printable SID for the current NT user's domain.
0N/A */
0N/A public String getDomainSID() {
0N/A return domainSID;
0N/A }
0N/A
0N/A /**
0N/A * Get a printable SID for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return a printable SID for the current NT user.
0N/A */
0N/A public String getUserSID() {
0N/A return userSID;
0N/A }
0N/A
0N/A /**
0N/A * Get a printable primary group SID for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the primary group SID for the current NT user.
0N/A */
0N/A public String getPrimaryGroupID() {
0N/A return primaryGroupID;
0N/A }
0N/A
0N/A /**
0N/A * Get the printable group SIDs for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the group SIDs for the current NT user.
0N/A */
0N/A public String[] getGroupIDs() {
3213N/A return groupIDs == null ? null : groupIDs.clone();
0N/A }
0N/A
0N/A /**
0N/A * Get an impersonation token for the current NT user.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return an impersonation token for the current NT user.
0N/A */
4377N/A public synchronized long getImpersonationToken() {
4377N/A if (impersonationToken == 0) {
4377N/A impersonationToken = getImpersonationToken0();
4377N/A }
0N/A return impersonationToken;
0N/A }
0N/A
4377N/A
0N/A private void loadNative() {
0N/A System.loadLibrary("jaas_nt");
0N/A }
0N/A}