Example usage for javax.security.auth.callback TextOutputCallback getMessageType

List of usage examples for javax.security.auth.callback TextOutputCallback getMessageType

Introduction

In this page you can find the example usage for javax.security.auth.callback TextOutputCallback getMessageType.

Prototype

public int getMessageType() 

Source Link

Document

Get the message type.

Usage

From source file:org.hyperic.hq.plugin.weblogic.WeblogicAuth.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof TextOutputCallback) {

            TextOutputCallback toc = (TextOutputCallback) callbacks[i];

            switch (toc.getMessageType()) {
            case TextOutputCallback.INFORMATION:
                log.info(toc.getMessage());
                break;

            case TextOutputCallback.ERROR:
                log.error(toc.getMessage());
                break;

            case TextOutputCallback.WARNING:
                log.warn(toc.getMessage());
                break;

            default:
                throw new IOException("Unsupported message type: " + toc.getMessageType());
            }//  www  . ja  va2s  . c o m
        } else if (callbacks[i] instanceof NameCallback) {
            NameCallback nc = (NameCallback) callbacks[i];
            nc.setName(this.username);
        } else if (callbacks[i] instanceof URLCallback) {
            URLCallback uc = (URLCallback) callbacks[i];
            uc.setURL(this.url);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks[i];
            pc.setPassword(this.passwordArray);
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}