org.apache.catalina.realm
public class: JAASCallbackHandler [javadoc |
source]
java.lang.Object
org.apache.catalina.realm.JAASCallbackHandler
All Implemented Interfaces:
CallbackHandler
Implementation of the JAAS CallbackHandler interface,
used to negotiate delivery of the username and credentials that were
specified to our constructor. No interaction with the user is required
(or possible).
This CallbackHandler will pre-digest the supplied
password, if required by the <Realm> element in
server.xml.
At present, JAASCallbackHandler knows how to handle callbacks of
type javax.security.auth.callback.NameCallback and
javax.security.auth.callback.PasswordCallback.
- author:
Craig - R. McClanahan
- author:
Andrew - R. Jaquith
- version:
$ - Revision: 543691 $ $Date: 2007-06-02 03:37:08 +0200 (sam., 02 juin 2007) $
| Field Summary |
|---|
| protected static final StringManager | sm | The string manager for this package. |
| protected String | password | The password to be authenticated with. |
| protected JAASRealm | realm | The associated JAASRealm instance. |
| protected String | username | The username to be authenticated with. |
| Constructor: |
public JAASCallbackHandler(JAASRealm realm,
String username,
String password) {
super();
this.realm = realm;
this.username = username;
if (realm.hasMessageDigest()) {
this.password = realm.digest(password);
}
else {
this.password = password;
}
}
Construct a callback handler configured with the specified values.
Note that if the JAASRealm instance specifies digested passwords,
the password parameter will be pre-digested here. Parameters:
realm - Our associated JAASRealm instance
username - Username to be authenticated with
password - Password to be authenticated with
|
| Method from org.apache.catalina.realm.JAASCallbackHandler Summary: |
|---|
|
handle |
| Method from org.apache.catalina.realm.JAASCallbackHandler Detail: |
public void handle(Callback[] callbacks) throws UnsupportedCallbackException, IOException {
// --------------------------------------------------------- Public Methods
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
if (realm.getContainer().getLogger().isTraceEnabled())
realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username));
((NameCallback) callbacks[i]).setName(username);
} else if (callbacks[i] instanceof PasswordCallback) {
final char[] passwordcontents;
if (password != null) {
passwordcontents = password.toCharArray();
} else {
passwordcontents = new char[0];
}
((PasswordCallback) callbacks[i]).setPassword
(passwordcontents);
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
Retrieve the information requested in the provided Callbacks.
This implementation only recognizes NameCallback and
PasswordCallback instances. |