Top Description Inners Fields Constructors Methods
waffle.windows.auth.impl

public Class WindowsAuthProviderImpl

extends Object
implements IWindowsAuthProvider
Class Inheritance
All Implemented Interfaces
waffle.windows.auth.IWindowsAuthProvider
Imports
com.sun.jna.platform.win32.Advapi32, .Kernel32, .Netapi32Util, .Netapi32Util.DomainTrust, .Secur32, .Sspi, .Sspi.CtxtHandle, .SspiUtil.ManagedSecBufferDesc, .Win32Exception, .WinBase, .WinError, .WinNT.HANDLEByReference, com.sun.jna.ptr.IntByReference, java.net.InetAddress, .UnknownHostException, java.util.ArrayList, .List, waffle.util.cache.Cache, waffle.windows.auth.IWindowsAccount, .IWindowsAuthProvider, .IWindowsComputer, .IWindowsCredentialsHandle, .IWindowsDomain, .IWindowsIdentity, .IWindowsSecurityContext

Windows Auth Provider.
Author
dblock[at]dblock[dot]org

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
WindowsAuthProviderImpl.ContinueContext

The Class ContinueContext.

Field Summary

Modifier and TypeField and Description
public static final int
CONTINUE_CONTEXT_TIMEOUT

The Continue Context Timeout.

private final Cache<String, WindowsAuthProviderImpl.ContinueContext>
continueContexts

The continue contexts.

Constructor Summary

AccessConstructor and Description
public
WindowsAuthProviderImpl()

Instantiates a new windows auth provider impl.

public
WindowsAuthProviderImpl(final int
Timeout for security contexts in seconds.
continueContextsTimeout
)

A Windows authentication provider.

Method Summary

Modifier and TypeMethod and Description
public IWindowsSecurityContext
acceptSecurityToken(final String
A unique connection id.
connectionId
,
final byte[]
The security token generated by the client wishing to logon.
token
,
final String
The name of the security package to use. Can be any security package supported by both the client and the server. This is usually set to "Negotiate" which will use SPNEGO to determine which security package to use. Other common values are "Kerberos" and "NTLM".
securityPackage
)

Implements waffle.windows.auth.IWindowsAuthProvider.acceptSecurityToken.

Attempts to validate the user using an SSPI token.
public int

Returns:

Number of elements in the hash map.
getContinueContextsSize
()

Number of elements in the continue contexts map.

public IWindowsComputer
getCurrentComputer()

Implements waffle.windows.auth.IWindowsAuthProvider.getCurrentComputer.

Retrieve the current computer information.
public IWindowsDomain[]
getDomains()

Implements waffle.windows.auth.IWindowsAuthProvider.getDomains.

Retrieve a list of domains (Active Directory) on the local server.
public IWindowsIdentity
logonDomainUser(final String
A string that specifies the name of the user. This is the name of the user account to log on to. If you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.
username
,
final String
A string that specifies the name of the domain or server whose account database contains the username account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter is ".", the function validates the account by using only the local account database.
domain
,
final String
A string that specifies the plaintext password for the user account specified by username.
password
)

Implements waffle.windows.auth.IWindowsAuthProvider.logonDomainUser.

The LogonDomainUser function attempts to log a user on to the local computer using a network logon type and the default authentication provider.
public IWindowsIdentity
logonDomainUserEx(final String
A string that specifies the name of the user. This is the name of the user account to log on to. If you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.
username
,
final String
A string that specifies the name of the domain or server whose account database contains the username account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter is ".", the function validates the account by using only the local account database.
domain
,
final String
A string that specifies the plaintext password for the user account specified by username.
password
,
final int
The type of logon operation to perform.
logonType
,
final int
Specifies the logon provider.
logonProvider
)

Implements waffle.windows.auth.IWindowsAuthProvider.logonDomainUserEx.

The LogonDomainUserEx function attempts to log a user on to the local computer.
public IWindowsIdentity
logonUser(final String
A string that specifies the name of the user in the UPN format.
username
,
final String
A string that specifies the plaintext password for the user account specified by username.
password
)

Implements waffle.windows.auth.IWindowsAuthProvider.logonUser.

The LogonUser function attempts to log a user on to the local computer using a network logon type and the default authentication provider.
public IWindowsAccount
lookupAccount(final String
Fully qualified or partial username.
username
)

Implements waffle.windows.auth.IWindowsAuthProvider.lookupAccount.

Retrieve a security identifier (SID) for the account and the name of the domain or local computer on which the account was found.
public void
resetSecurityToken(final String
Connection id.
connectionId
)

Implements waffle.windows.auth.IWindowsAuthProvider.resetSecurityToken.

Reset a previously saved continuation security token for a given connection id.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTINUE_CONTEXT_TIMEOUTback to summary
public static final int CONTINUE_CONTEXT_TIMEOUT

The Continue Context Timeout.

continueContextsback to summary
private final Cache<String, WindowsAuthProviderImpl.ContinueContext> continueContexts

The continue contexts.

Constructor Detail

WindowsAuthProviderImplback to summary
public WindowsAuthProviderImpl()

Instantiates a new windows auth provider impl.

WindowsAuthProviderImplback to summary
public WindowsAuthProviderImpl(final int continueContextsTimeout)

A Windows authentication provider.

Parameters
continueContextsTimeout:int

Timeout for security contexts in seconds.

Method Detail

acceptSecurityTokenback to summary
public IWindowsSecurityContext acceptSecurityToken(final String connectionId, final byte[] token, final String securityPackage)

Implements waffle.windows.auth.IWindowsAuthProvider.acceptSecurityToken.

Doc from waffle.windows.auth.IWindowsAuthProvider.acceptSecurityToken.

Attempts to validate the user using an SSPI token. This token is generated by the client via the InitializeSecurityContext(package) method described in https://msdn.microsoft.com/en-us/library/aa375509(VS.85).aspx

Parameters
connectionId:String

A unique connection id.

token:byte[]

The security token generated by the client wishing to logon.

securityPackage:String

The name of the security package to use. Can be any security package supported by both the client and the server. This is usually set to "Negotiate" which will use SPNEGO to determine which security package to use. Other common values are "Kerberos" and "NTLM".

Returns:IWindowsSecurityContext

Windows account.

Annotations
@Override
getContinueContextsSizeback to summary
public int getContinueContextsSize()

Number of elements in the continue contexts map.

Returns:int

Number of elements in the hash map.

getCurrentComputerback to summary
public IWindowsComputer getCurrentComputer()

Implements waffle.windows.auth.IWindowsAuthProvider.getCurrentComputer.

Doc from waffle.windows.auth.IWindowsAuthProvider.getCurrentComputer.

Retrieve the current computer information.

Returns:IWindowsComputer

Current computer information.

Annotations
@Override
getDomainsback to summary
public IWindowsDomain[] getDomains()

Implements waffle.windows.auth.IWindowsAuthProvider.getDomains.

Doc from waffle.windows.auth.IWindowsAuthProvider.getDomains.

Retrieve a list of domains (Active Directory) on the local server.

Returns:IWindowsDomain[]

A list of domains.

Annotations
@Override
logonDomainUserback to summary
public IWindowsIdentity logonDomainUser(final String username, final String domain, final String password)

Implements waffle.windows.auth.IWindowsAuthProvider.logonDomainUser.

Doc from waffle.windows.auth.IWindowsAuthProvider.logonDomainUser.

The LogonDomainUser function attempts to log a user on to the local computer using a network logon type and the default authentication provider.

Parameters
username:String

A string that specifies the name of the user. This is the name of the user account to log on to. If you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.

domain:String

A string that specifies the name of the domain or server whose account database contains the username account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter is ".", the function validates the account by using only the local account database.

password:String

A string that specifies the plaintext password for the user account specified by username.

Returns:IWindowsIdentity

Windows identity.

Annotations
@Override
logonDomainUserExback to summary
public IWindowsIdentity logonDomainUserEx(final String username, final String domain, final String password, final int logonType, final int logonProvider)

Implements waffle.windows.auth.IWindowsAuthProvider.logonDomainUserEx.

Doc from waffle.windows.auth.IWindowsAuthProvider.logonDomainUserEx.

The LogonDomainUserEx function attempts to log a user on to the local computer. The local computer is the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote computer. You specify the user with a user name and domain and authenticate the user with a plaintext password.

Parameters
username:String

A string that specifies the name of the user. This is the name of the user account to log on to. If you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.

domain:String

A string that specifies the name of the domain or server whose account database contains the username account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter is ".", the function validates the account by using only the local account database.

password:String

A string that specifies the plaintext password for the user account specified by username.

logonType:int

The type of logon operation to perform.

logonProvider:int

Specifies the logon provider.

Returns:IWindowsIdentity

Windows identity.

Annotations
@Override
logonUserback to summary
public IWindowsIdentity logonUser(final String username, final String password)

Implements waffle.windows.auth.IWindowsAuthProvider.logonUser.

Doc from waffle.windows.auth.IWindowsAuthProvider.logonUser.

The LogonUser function attempts to log a user on to the local computer using a network logon type and the default authentication provider.

Parameters
username:String

A string that specifies the name of the user in the UPN format.

password:String

A string that specifies the plaintext password for the user account specified by username.

Returns:IWindowsIdentity

Windows identity.

Annotations
@Override
lookupAccountback to summary
public IWindowsAccount lookupAccount(final String username)

Implements waffle.windows.auth.IWindowsAuthProvider.lookupAccount.

Doc from waffle.windows.auth.IWindowsAuthProvider.lookupAccount.

Retrieve a security identifier (SID) for the account and the name of the domain or local computer on which the account was found.

Parameters
username:String

Fully qualified or partial username.

Returns:IWindowsAccount

Windows account.

Annotations
@Override
resetSecurityTokenback to summary
public void resetSecurityToken(final String connectionId)

Implements waffle.windows.auth.IWindowsAuthProvider.resetSecurityToken.

Doc from waffle.windows.auth.IWindowsAuthProvider.resetSecurityToken.

Reset a previously saved continuation security token for a given connection id.

Parameters
connectionId:String

Connection id.

Annotations
@Override
waffle.windows.auth.impl back to summary

private Class WindowsAuthProviderImpl.ContinueContext

extends Object
Class Inheritance
  • java.lang.Object
  • waffle.windows.auth.impl.WindowsAuthProviderImpl.ContinueContext

The Class ContinueContext.

Field Summary

Modifier and TypeField and Description
pack-priv Sspi.CtxtHandle
continueHandle

The continue handle.

pack-priv IWindowsCredentialsHandle
serverCredential

The server credential.

Constructor Summary

AccessConstructor and Description
public
ContinueContext(final Sspi.CtxtHandle
the handle
handle
,
final IWindowsCredentialsHandle
the windows credential
windowsCredential
)

Instantiates a new continue context.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

continueHandleback to summary
pack-priv Sspi.CtxtHandle continueHandle

The continue handle.

serverCredentialback to summary
pack-priv IWindowsCredentialsHandle serverCredential

The server credential.

Constructor Detail

ContinueContextback to summary
public ContinueContext(final Sspi.CtxtHandle handle, final IWindowsCredentialsHandle windowsCredential)

Instantiates a new continue context.

Parameters
handle:Sspi.CtxtHandle

the handle

windowsCredential:IWindowsCredentialsHandle

the windows credential