Example usage for javax.security.sasl AuthorizeCallback AuthorizeCallback

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

Introduction

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

Prototype

public AuthorizeCallback(String authnID, String authzID) 

Source Link

Document

Constructs an instance of AuthorizeCallback .

Usage

From source file:com.delphix.session.impl.sasl.PlainSaslServer.java

@Override
protected byte[] evaluate(byte[] message) throws SaslException {
    // Parse the SASL message
    String[] userInfo = parse(message);

    // Perform authentication
    String prompt = getMechanismName() + " authentication ID: ";
    NameCallback nc = new NameCallback(prompt, userInfo[1]);
    AuthenticateCallback ac = new AuthenticateCallback(userInfo[2]);

    invokeCallbacks(nc, ac);/*from   w  w  w  .  j  a v  a 2  s  .c  o  m*/

    if (!ac.isAuthenticated()) {
        throw new SaslException("sasl authentication failed");
    }

    // Perform authorization
    AuthorizeCallback az = new AuthorizeCallback(userInfo[1], userInfo[0]);

    invokeCallbacks(az);

    if (az.isAuthorized()) {
        authorizationId = az.getAuthorizedID();
    } else {
        throw new SaslException();
    }

    // Mark the SASL server completed
    setComplete();

    return null;
}