Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2015 JBoss Inc
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
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