com.cenqua.shaj
Class Shaj

java.lang.Object
  extended bycom.cenqua.shaj.Shaj

public class Shaj
extends java.lang.Object

A simple way of verifying username/passwords (authentication) and checking group membership. Passwords and group membership is checked with the underlying operating system (see below for a discussion on platform-specific behavior).

The checkPassword(String, String, String) and checkGroupMembership(String, String, String) methods both require a "domain" parameter. The exact meaning of this parameter is platform-specific. These static methods simply call through to the corresponding methods in the default Authenticator.

This class is multi-thread safe.

Note: Shaj needs to load the "shaj" native library (e.g. "libshaj.so" on Linux, "shaj.dll" on win32, etc.). If this process fails for any reason, an error is logged and most of the methods will throw IllegalStateException. The init() method can be called to determine if Shaj was sucessfully initialized.

When necessary, Shaj performs logging using the Log class.

Platform specific notes: For further information, see the specific implementation classes Win32Authenticator and PAMAuthenticator.


Constructor Summary
Shaj()
           
 
Method Summary
static boolean checkGroupMembership(java.lang.String domain, java.lang.String username, java.lang.String group)
          Tests if a user is a member of a specific group.
static boolean checkPassword(java.lang.String domain, java.lang.String username, java.lang.String password)
          Checks a user's password.
static boolean init()
          Forces Shaj to load its required resources (native libraries, etc).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shaj

public Shaj()
Method Detail

init

public static boolean init()
Forces Shaj to load its required resources (native libraries, etc). It is never necessary to call this method (Shaj will call this method itself when needed), but calling this method early in your program gives you a chance to determine Shaj's status at a convenient time. This method may be called multiple times.

Returns:
true if Shaj was able to successfully initialize its platform-specific components.

checkPassword

public static boolean checkPassword(java.lang.String domain,
                                    java.lang.String username,
                                    java.lang.String password)
Checks a user's password.

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
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 init() returns false).

checkGroupMembership

public static boolean checkGroupMembership(java.lang.String domain,
                                           java.lang.String username,
                                           java.lang.String group)
Tests if a user is a member of a specific group.

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
Returns:
true if the user is a member of the group
Throws:
java.lang.IllegalArgumentException - if username or group are null.
java.lang.IllegalStateException - if Shaj did not load correctly (if init() returns false).


Copyright © 2005 Cenqua. All Rights Reserved.