Code example for Subject

Methods: getPrivateCredentials, getPublicCredentials

0
    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options) {
        if (options.containsKey("username")) {
            // Zookeeper client: get username and password from JAAS conf (only used if using DIGEST-MD5). 
            this.subject = subject;
            String username = (String)options.get("username");
            this.subject.getPublicCredentials().add((Object)username);
            String password = (String)options.get("password");
            this.subject.getPrivateCredentials().add((Object)password);
        } 
        return; 
    } 
 
    public boolean logout() { 
        return true; 
    } 
 
    public boolean login() { 
        // Unlike with Krb5LoginModule, we don't do any actual login or credential passing here: authentication to Zookeeper 
        // is done later, through the SASLClient object. 
        return true; 
    }