Top Description Fields Constructors Methods
waffle.jaas

public Class WindowsLoginModule

extends Object
implements LoginModule
Class Inheritance
All Implemented Interfaces
javax.security.auth.spi.LoginModule
Imports
java.io.IOException, java.security.Principal, java.util.ArrayList, .LinkedHashSet, .List, .Locale, .Map, .Set, javax.security.auth.Subject, javax.security.auth.callback.Callback, .CallbackHandler, .NameCallback, .PasswordCallback, .UnsupportedCallbackException, javax.security.auth.login.LoginException, javax.security.auth.spi.LoginModule, org.slf4j.Logger, .LoggerFactory, waffle.windows.auth.IWindowsAccount, .IWindowsAuthProvider, .IWindowsIdentity, .PrincipalFormat, waffle.windows.auth.impl.WindowsAuthProviderImpl

A Java Security login module for Windows authentication.
Author
dblock[at]dblock[dot]org
See Also
javax.security.auth.spi.LoginModule

Field Summary

Modifier and TypeField and Description
private boolean
allowGuestLogin

The allow guest login.

private IWindowsAuthProvider
auth

The auth.

private CallbackHandler
callbackHandler

The callback handler.

private boolean
debug

The debug.

private static final Logger
LOGGER

The Constant LOGGER.

private PrincipalFormat
principalFormat

The principal format.

private Set<Principal>
principals

The principals.

private PrincipalFormat
roleFormat

The role format.

private Subject
subject

The subject.

private String
username

The username.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true, if successful
abort
()

Implements javax.security.auth.spi.LoginModule.abort.

Abort a login process.
public boolean

Returns:

true, if successful
commit
()

Implements javax.security.auth.spi.LoginModule.commit.

Commit principals to the subject.
public IWindowsAuthProvider

Returns:

IWindowsAuthProvider.
getAuth
()

Windows auth provider.

private static List<Principal>

Returns:

List of role principal objects.
getRolePrincipals
(final IWindowsAccount
Windows group.
group
,
final PrincipalFormat
Principal format.
principalFormat
)

Returns a list of role principal objects.

private static List<Principal>

Returns:

A list of user principal objects.
getUserPrincipals
(final IWindowsIdentity
Windows identity.
windowsIdentity
,
final PrincipalFormat
Principal format.
principalFormat
)

Returns a list of user principal objects.

public void
initialize(final Subject
the Subject to be authenticated.
initSubject
,
final CallbackHandler
a CallbackHandler for communicating with the end user (prompting for usernames and passwords, for example).
initCallbackHandler
,
final Map<String, ?>
state shared with other configured LoginModules.
initSharedState
,
final Map<String, ?>
options specified in the login Configuration for this particular LoginModule.
initOptions
)

Implements javax.security.auth.spi.LoginModule.initialize.

Initialize this LoginModule.
public boolean

Returns:

True if Guest login permitted, false otherwise.
isAllowGuestLogin
()

True if Guest login permitted.

public boolean

Returns:

True or false.
isDebug
()

True if Debug is enabled.

public boolean

Returns:

true, if successful
login
()

Implements javax.security.auth.spi.LoginModule.login.

Use Windows SSPI to authenticate a username with a password.
public boolean

Returns:

true, if successful
logout
()

Implements javax.security.auth.spi.LoginModule.logout.

Logout a user.
public void
setAllowGuestLogin(final boolean
True or false.
value
)

Set whether Guest login is permitted.

public void
setAuth(final IWindowsAuthProvider
Class implements IWindowsAuthProvider.
provider
)

Set Windows auth provider.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowGuestLoginback to summary
private boolean allowGuestLogin

The allow guest login.

authback to summary
private IWindowsAuthProvider auth

The auth.

callbackHandlerback to summary
private CallbackHandler callbackHandler

The callback handler.

debugback to summary
private boolean debug

The debug.

LOGGERback to summary
private static final Logger LOGGER

The Constant LOGGER.

principalFormatback to summary
private PrincipalFormat principalFormat

The principal format.

principalsback to summary
private Set<Principal> principals

The principals.

roleFormatback to summary
private PrincipalFormat roleFormat

The role format.

subjectback to summary
private Subject subject

The subject.

usernameback to summary
private String username

The username.

Constructor Detail

WindowsLoginModuleback to summary
public WindowsLoginModule()

Method Detail

abortback to summary
public boolean abort() throws LoginException

Implements javax.security.auth.spi.LoginModule.abort.

Abort a login process.

Returns:boolean

true, if successful

Annotations
@Override
Exceptions
LoginException:
the login exception
commitback to summary
public boolean commit() throws LoginException

Implements javax.security.auth.spi.LoginModule.commit.

Commit principals to the subject.

Returns:boolean

true, if successful

Annotations
@Override
Exceptions
LoginException:
the login exception
getAuthback to summary
public IWindowsAuthProvider getAuth()

Windows auth provider.

Returns:IWindowsAuthProvider

IWindowsAuthProvider.

getRolePrincipalsback to summary
private static List<Principal> getRolePrincipals(final IWindowsAccount group, final PrincipalFormat principalFormat)

Returns a list of role principal objects.

Parameters
group:IWindowsAccount

Windows group.

principalFormat:PrincipalFormat

Principal format.

Returns:List<Principal>

List of role principal objects.

getUserPrincipalsback to summary
private static List<Principal> getUserPrincipals(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat)

Returns a list of user principal objects.

Parameters
windowsIdentity:IWindowsIdentity

Windows identity.

principalFormat:PrincipalFormat

Principal format.

Returns:List<Principal>

A list of user principal objects.

initializeback to summary
public void initialize(final Subject initSubject, final CallbackHandler initCallbackHandler, final Map<String, ?> initSharedState, final Map<String, ?> initOptions)

Implements javax.security.auth.spi.LoginModule.initialize.

Doc from javax.security.auth.spi.LoginModule.initialize.

Initialize this LoginModule.

This method is called by the LoginContext after this LoginModule has been instantiated. The purpose of this method is to initialize this LoginModule with the relevant information. If this LoginModule does not understand any of the data stored in sharedState or options parameters, they can be ignored.

Parameters
initSubject:Subject

the Subject to be authenticated.

initCallbackHandler:CallbackHandler

a CallbackHandler for communicating with the end user (prompting for usernames and passwords, for example).

initSharedState:Map<String, ?>

state shared with other configured LoginModules.

initOptions:Map<String, ?>

options specified in the login Configuration for this particular LoginModule.

Annotations
@Override
isAllowGuestLoginback to summary
public boolean isAllowGuestLogin()

True if Guest login permitted.

Returns:boolean

True if Guest login permitted, false otherwise.

isDebugback to summary
public boolean isDebug()

True if Debug is enabled.

Returns:boolean

True or false.

loginback to summary
public boolean login() throws LoginException

Implements javax.security.auth.spi.LoginModule.login.

Use Windows SSPI to authenticate a username with a password.

Returns:boolean

true, if successful

Annotations
@Override
Exceptions
LoginException:
the login exception
logoutback to summary
public boolean logout() throws LoginException

Implements javax.security.auth.spi.LoginModule.logout.

Logout a user.

Returns:boolean

true, if successful

Annotations
@Override
Exceptions
LoginException:
the login exception
setAllowGuestLoginback to summary
public void setAllowGuestLogin(final boolean value)

Set whether Guest login is permitted. Default is true, if the Guest account is enabled, an invalid username/password results in a Guest login.

Parameters
value:boolean

True or false.

setAuthback to summary
public void setAuth(final IWindowsAuthProvider provider)

Set Windows auth provider.

Parameters
provider:IWindowsAuthProvider

Class implements IWindowsAuthProvider.