Showing the changes to java/pkg/com/sun/security/auth/module/NTSystem.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,142 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package com.sun.security.auth.module; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * <p> This class implementation retrieves and makes available NT | ||
| 30 | * security information for the current user. | ||
| 31 | * | ||
| 32 | */ | ||
| 33 | public class NTSystem { | ||
| 34 | |||
| 35 | private native void getCurrent(boolean debug); | ||
| 36 | |||
| 37 | private String userName; | ||
| 38 | private String domain; | ||
| 39 | private String domainSID; | ||
| 40 | private String userSID; | ||
| 41 | private String groupIDs[]; | ||
| 42 | private String primaryGroupID; | ||
| 43 | private long impersonationToken; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Instantiate an <code>NTSystem</code> and load | ||
| 47 | * the native library to access the underlying system information. | ||
| 48 | */ | ||
| 49 | public NTSystem() { | ||
| 50 | this(false); | ||
| 51 | } | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Instantiate an <code>NTSystem</code> and load | ||
| 55 | * the native library to access the underlying system information. | ||
| 56 | */ | ||
| 57 | NTSystem(boolean debug) { | ||
| 58 | loadNative(); | ||
| 59 | getCurrent(debug); | ||
| 60 | } | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Get the username for the current NT user. | ||
| 64 | * | ||
| 65 | * <p> | ||
| 66 | * | ||
| 67 | * @return the username for the current NT user. | ||
| 68 | */ | ||
| 69 | public String getName() { | ||
| 70 | return userName; | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Get the domain for the current NT user. | ||
| 75 | * | ||
| 76 | * <p> | ||
| 77 | * | ||
| 78 | * @return the domain for the current NT user. | ||
| 79 | */ | ||
| 80 | public String getDomain() { | ||
| 81 | return domain; | ||
| 82 | } | ||
| 83 | |||
| 84 | /** | ||
| 85 | * Get a printable SID for the current NT user's domain. | ||
| 86 | * | ||
| 87 | * <p> | ||
| 88 | * | ||
| 89 | * @return a printable SID for the current NT user's domain. | ||
| 90 | */ | ||
| 91 | public String getDomainSID() { | ||
| 92 | return domainSID; | ||
| 93 | } | ||
| 94 | |||
| 95 | /** | ||
| 96 | * Get a printable SID for the current NT user. | ||
| 97 | * | ||
| 98 | * <p> | ||
| 99 | * | ||
| 100 | * @return a printable SID for the current NT user. | ||
| 101 | */ | ||
| 102 | public String getUserSID() { | ||
| 103 | return userSID; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Get a printable primary group SID for the current NT user. | ||
| 108 | * | ||
| 109 | * <p> | ||
| 110 | * | ||
| 111 | * @return the primary group SID for the current NT user. | ||
| 112 | */ | ||
| 113 | public String getPrimaryGroupID() { | ||
| 114 | return primaryGroupID; | ||
| 115 | } | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Get the printable group SIDs for the current NT user. | ||
| 119 | * | ||
| 120 | * <p> | ||
| 121 | * | ||
| 122 | * @return the group SIDs for the current NT user. | ||
| 123 | */ | ||
| 124 | public String[] getGroupIDs() { | ||
| 125 | return groupIDs == null ? null : groupIDs.clone(); | ||
| 126 | } | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Get an impersonation token for the current NT user. | ||
| 130 | * | ||
| 131 | * <p> | ||
| 132 | * | ||
| 133 | * @return an impersonation token for the current NT user. | ||
| 134 | */ | ||
| 135 | public long getImpersonationToken() { | ||
| 136 | return impersonationToken; | ||
| 137 | } | ||
| 138 | |||
| 139 | private void loadNative() { | ||
| 140 | System.loadLibrary("jaas_nt"); | ||
| 141 | } | ||
| 142 | } | ||