Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jacorb.demo.sas;
 
 
public class JaasTxtCalbackHandler implements CallbackHandler {
    private String myUsername = "";
    private char[] myPassword = null;

    

Creates a callback handler that prompts and reads from the command line for answers to authentication questions. This can be used by JAAS applications to instantiate a CallbackHandler.

    public JaasTxtCalbackHandler() {
    }
    public void setMyUsername(String username) {
         = username;
    }
    public void setMyPassword(char[] password) {
         = password;
    }

    
Handles the specified set of callbacks.

Parameters:
callbacks the callbacks to handle
Throws:
IOException if an input or output error occurs.
javax.security.auth.callback.UnsupportedCallbackException if the callback is not an instance of NameCallback or PasswordCallback
    public void handle(Callback[] callbacksthrows UnsupportedCallbackException {
        for (int i = 0; i < callbacks.lengthi++) {
            if (callbacks[iinstanceof TextOutputCallback) {
                TextOutputCallback tc = (TextOutputCallbackcallbacks[i];
                String text;
                switch (tc.getMessageType()) {
                    case . :
                    text = "";
                    break;
                    case . :
                    text = "Warning: ";
                    break;
                    case . :
                    text = "Error: ";
                    break;
                    default :
                    throw new UnsupportedCallbackException(
                        callbacks[i],
                        "Unrecognized message type");
                }
                String message = tc.getMessage();
                if (message != null) {
                    text += message;
                }
                if (text != null) {
                    ..println(text);
                }
            } else if (callbacks[iinstanceof NameCallback) {
                NameCallback nc = (NameCallbackcallbacks[i];
                nc.setName();
            } else if (callbacks[iinstanceof PasswordCallback) {
                PasswordCallback pc = (PasswordCallbackcallbacks[i];
                pc.setPassword();
            } else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
            }
        }
    }
New to GrepCode? Check out our FAQ X