Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This is the basic, default implementation of a User/Pass callback handler for a JAAS login. This class is used by the JMS in order to retrieve the subject for the user/pass info stored in a message (the Bean itself runs as an anonymous user).
public class UserPassCallbackHandler implements CallbackHandler {
    private final String[] credentials;
    public UserPassCallbackHandler(String[] credentials) {
        this. = credentials;
    public void handle(Callback[] callbacksthrows IOExceptionUnsupportedCallbackException {
        for (Callback current : callbacks) {
            if (current instanceof NameCallback) {
                NameCallback ncb = (NameCallbackcurrent;
            } else if (current instanceof PasswordCallback) {
                PasswordCallback pcb = (PasswordCallbackcurrent;
            } else if (current instanceof RealmCallback) {
                RealmCallback realmCallback = (RealmCallbackcurrent;
            } else {
                throw new UnsupportedCallbackException(current);
New to GrepCode? Check out our FAQ X