com.cenqua.shaj
Class Win32Authenticator

java.lang.Object
  extended bycom.cenqua.shaj.Authenticator
      extended bycom.cenqua.shaj.Win32Authenticator

public class Win32Authenticator
extends Authenticator

Checks user passwords and group-memebership with a Windows domain or computer.

Note: For the domain argument, it is best to use the full DNS name of the domain. For example, corp.example.com. Using the short version (e.g. corp) may work for checkWin32Password(String, String, String, com.cenqua.shaj.log.Log) but not for checkWin32GroupMembership(String, String, String, com.cenqua.shaj.log.Log).

This class contains some static methods that can be used if you wish to call to Windows directly.


Constructor Summary
Win32Authenticator()
           
 
Method Summary
 boolean checkGroupMembership(java.lang.String domain, java.lang.String username, java.lang.String group, Log log)
          Tests if a user is a member of a specific group.
 boolean checkPassword(java.lang.String domain, java.lang.String username, java.lang.String password, Log log)
          Checks a user's password.
static boolean checkWin32GroupMembership(java.lang.String domain, java.lang.String username, java.lang.String group, Log log)
          Checks if a user is a member of a group.
static boolean checkWin32Password(java.lang.String domain, java.lang.String username, java.lang.String password, Log log)
          Verify a users password against a domain.
static boolean isSupported()
          Determines if this Authenticator can be used on the underlying platform.
 
Methods inherited from class com.cenqua.shaj.Authenticator
getDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Win32Authenticator

public Win32Authenticator()
Method Detail

isSupported

public static boolean isSupported()
Determines if this Authenticator can be used on the underlying platform.

Returns:
true if this platform supports win32 authentication.

checkPassword

public boolean checkPassword(java.lang.String domain,
                             java.lang.String username,
                             java.lang.String password,
                             Log log)
Description copied from class: Authenticator
Checks a user's password.

Specified by:
checkPassword in class Authenticator
Parameters:
domain - the (platform-specific) domain/service to used to perform the check. May be null (which has a platform-specific meaning).
username - the username
password - the password to verify
log - where to log errors/debugging
Returns:
true if the password matches the username

checkGroupMembership

public boolean checkGroupMembership(java.lang.String domain,
                                    java.lang.String username,
                                    java.lang.String group,
                                    Log log)
Description copied from class: Authenticator
Tests if a user is a member of a specific group.

Specified by:
checkGroupMembership in class Authenticator
Parameters:
domain - the (platform-specific) domain/service to used to perform the check. May be null (which has a platform-specific meaning).
username - the username to test for membership
group - the group to look in
log - where to log errors/debugging
Returns:
true if the user is a member of the group

checkWin32Password

public static boolean checkWin32Password(java.lang.String domain,
                                         java.lang.String username,
                                         java.lang.String password,
                                         Log log)
Verify a users password against a domain.

Note: Windows appears to ignore domain if the computer is not part of a domain

Parameters:
domain - the windows domain to check against. If domain is null, then the local computer (or the domain it is attached to) is checked.
username - the username
password - the password to verify
log - where to log errors/debugging
Returns:
true if the password matches the username
Throws:
java.lang.IllegalArgumentException - if username or password are null.
java.lang.IllegalStateException - if Shaj did not load correctly (if Shaj.init() returns false).

checkWin32GroupMembership

public static boolean checkWin32GroupMembership(java.lang.String domain,
                                                java.lang.String username,
                                                java.lang.String group,
                                                Log log)
Checks if a user is a member of a group. Domain groups are searched first, then local groups (including indirect membership). Groups are matched by name (as opposed to a SSID).

Note: the domain argument should be the fully qualifyied DNS name of the domain.

Parameters:
domain - the windows domain to check against. If domain is null, then the local computer (or the domain it is attached to) is checked.
username - the username to test for membership
group - the group to look in
log - where to log errors/debugging
Returns:
true if the user is a member of the group
Throws:
java.lang.IllegalArgumentException - if username or password are null.
java.lang.IllegalStateException - if Shaj did not load correctly (if Shaj.init() returns false).


Copyright © 2005 Cenqua. All Rights Reserved.