SK.gnome.dwarf.auth.login
Class BasicCallbackHandler

java.lang.Object
  extended bySK.gnome.dwarf.auth.login.BasicCallbackHandler
All Implemented Interfaces:
javax.security.auth.callback.CallbackHandler

public class BasicCallbackHandler
extends java.lang.Object
implements javax.security.auth.callback.CallbackHandler

Provides the basic username/password callback handler.

It can be used to provide username and password which are already known in the moment of creating the handler.

This handler accepts an username without a password to support the identification feature of the GenericLoginModule class. In that case, the password returned by the PasswordCallback will be null.

Sample usage:

 // instantiate the subject
 Subject subject = new Subject();

 // authenticate the user "joe" with the "public" password
 AuthId id = login("MyConfiguration", subject, new BasicCallbackHandler("joe", "public"));
 

See Also:
GenericLoginModule

Constructor Summary
BasicCallbackHandler(java.lang.String username)
          Creates a new BasicCallbackHandler with the given user name.
BasicCallbackHandler(java.lang.String username, char[] password)
          Creates a new BasicCallbackHandler with the given user name and password.
 
Method Summary
 void handle(javax.security.auth.callback.Callback[] callbacks)
          Handles the given callbacks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicCallbackHandler

public BasicCallbackHandler(java.lang.String username)
Creates a new BasicCallbackHandler with the given user name.

Use this contructor only to enable the identification feature of the GenericLoginModule class.

Parameters:
username - the user name
Throws:
java.lang.NullPointerException - if the username is null

BasicCallbackHandler

public BasicCallbackHandler(java.lang.String username,
                            char[] password)
Creates a new BasicCallbackHandler with the given user name and password.

Parameters:
username - the user name
password - the password
Throws:
java.lang.NullPointerException - if the username or password is null
Method Detail

handle

public void handle(javax.security.auth.callback.Callback[] callbacks)
            throws java.io.IOException,
                   javax.security.auth.callback.UnsupportedCallbackException
Handles the given callbacks.

The supported callbacks are NameCallback for the username and PasswordCallback for the user password.

Specified by:
handle in interface javax.security.auth.callback.CallbackHandler
Parameters:
callbacks - the array of callbacks
Throws:
java.io.IOException - in the case of IO error
javax.security.auth.callback.UnsupportedCallbackException - if a callback is not supported


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.