Example usage for javax.security.sasl AuthorizeCallback setAuthorized

List of usage examples for javax.security.sasl AuthorizeCallback setAuthorized

Introduction

In this page you can find the example usage for javax.security.sasl AuthorizeCallback setAuthorized.

Prototype

public void setAuthorized(boolean ok) 

Source Link

Document

Sets whether the authorization is allowed.

Usage

From source file:org.apache.hadoop.io.crypto.bee.key.sasl.KeySaslServer.java

public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof RealmCallback) {
            // do your business
        } else if (callback instanceof NameCallback) {
            // do your business
        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback).setPassword(new String(keyToken.getPassword()).toCharArray());
            // logger.debug("set password:" +
            // Hex.encodeHexString(keyToken.getPassword()));
        } else if (callback instanceof AuthorizeCallback) {
            // logger.debug("set authorized to true");
            AuthorizeCallback authCallback = ((AuthorizeCallback) callback);
            authCallback.setAuthorized(true);
        } else {//from w w w .  j  av  a  2s. c  om
            // logger.error(callback.getClass().getName());
            throw new UnsupportedCallbackException(callback, "Unrecognized Callback");
        }
    }
}