public class AccessToken extends Handle
Modifier and Type | Class and Description |
---|---|
static class |
AccessToken.TokenInformationClass
This class is the wrapper for the TOKEN_INFORMATION_CLASS enumeration, which contains values
that specify the type of information being assigned to or retrieved from the
AccessToken class. |
Modifier and Type | Field and Description |
---|---|
static int |
TOKEN_ADJUST_DEFAULT
Changes the default owner, primary group, or DACL of access token
|
static int |
TOKEN_ADJUST_GROUPS
Adjusts the attributes of the groups in access token
|
static int |
TOKEN_ADJUST_PRIVILEGES
Enables or disables the privileges in access token
|
static int |
TOKEN_ADJUST_SESSIONID
Adjusts the session ID of access token
|
static int |
TOKEN_ASSIGN_PRIMARY
Attaches a primary token to a process.
|
static int |
TOKEN_DUPLICATE
Duplicates access token.
|
static int |
TOKEN_IMPERSONATE
Attaches impersonation access token to a process
|
static int |
TOKEN_QUERY
Queries access token
|
static int |
TOKEN_QUERY_SOURCE
Queries the source of access token
|
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
Constructor and Description |
---|
AccessToken()
Creates a process token for the current process with ADJUST_PRIVILEGES, QUERY access.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkTokenMembership(AccessToken accessToken,
Sid sidToCheck)
Determines whether a specified security identifier (SID) is enabled in an access token.
|
boolean |
enablePrivelege(java.lang.String name)
Enables the specified privilege.
|
TokenGroups |
getTokenGroups()
Get groups from the token.
|
static boolean |
getTokenInformation(Handle tokenHandle,
AccessToken.TokenInformationClass tokenInformationClass,
com.jniwrapper.Parameter tokenUserPtrVoid,
com.jniwrapper.UInt32 tokenInformationLength,
com.jniwrapper.Pointer returnLength)
Retrieves a specified type of information about an access token
|
static boolean |
openProcessToken(Handle processHandle,
int desiredAcces,
Handle resultToken)
Opens the access token associated with a process.
|
clone, closeHandle, equals, waitFor, waitFor
asFunction, asFunction, asTypedPointer, castTo, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
public static final int TOKEN_ASSIGN_PRIMARY
public static final int TOKEN_DUPLICATE
public static final int TOKEN_IMPERSONATE
public static final int TOKEN_QUERY
public static final int TOKEN_QUERY_SOURCE
public static final int TOKEN_ADJUST_PRIVILEGES
public static final int TOKEN_ADJUST_GROUPS
public static final int TOKEN_ADJUST_DEFAULT
public static final int TOKEN_ADJUST_SESSIONID
public AccessToken()
public static boolean openProcessToken(Handle processHandle, int desiredAcces, Handle resultToken)
processHandle
- - Handle to the process whose access token is opened.desiredAcces
- - Specifies an access mask that specifies the requested types of access to the access token.resultToken
- - Pointer to a handle that identifies the newly opened access token.public static boolean getTokenInformation(Handle tokenHandle, AccessToken.TokenInformationClass tokenInformationClass, com.jniwrapper.Parameter tokenUserPtrVoid, com.jniwrapper.UInt32 tokenInformationLength, com.jniwrapper.Pointer returnLength)
tokenHandle
- - Handle to access token.tokenInformationClass
- - Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type to identify the type of information the function retrieves.tokenUserPtrVoid
- - Pointer to a buffer the function fills with the requested information.tokenInformationLength
- - Specifies the size, in bytes, of the buffer pointed to by the TokenInformation parameter.returnLength
- - Pointer to a variable that receives the number of bytes needed for the buffer.public boolean enablePrivelege(java.lang.String name)
name
- name of the privilegepublic TokenGroups getTokenGroups()
public static boolean checkTokenMembership(AccessToken accessToken, Sid sidToCheck)
accessToken
- Handle to an access token. The handle must have TOKEN_QUERY access to the token. If TokenHandle is NULL, CheckTokenMembership uses the impersonation token of the calling thread. If the thread is not impersonating, the function duplicates the thread's primary token to create an impersonation token.sidToCheck
- SID structure. The CheckTokenMembership function checks for the presence of this SID in the user and group SIDs of the access token.