Java 8 AuthorizeCallback - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AuthorizeCallback class.

This code example shows how to use the following methods:getAuthenticationID, getAuthorizationID, setAuthorized
        LOG.debug("client supplied realm: " + rc.getDefaultText());
        rc.setText(rc.getDefaultText());
    } 
 
    private void handleAuthorizeCallback(AuthorizeCallback ac) {
        String authenticationID = ac.getAuthenticationID();
        String authorizationID = ac.getAuthorizationID();
 
        LOG.info("Successfully authenticated client: authenticationID=" + authenticationID
                + ";  authorizationID=" + authorizationID + ".");
        ac.setAuthorized(true);
 
        // canonicalize authorization id according to system properties: 
        // zookeeper.kerberos.removeRealmFromPrincipal(={true,false}) 
        // zookeeper.kerberos.removeHostFromPrincipal(={true,false}) 
        KerberosName kerberosName = new KerberosName(authenticationID);
        try { 
            StringBuilder userNameBuilder = new StringBuilder(kerberosName.getShortName());
            if (shouldAppendHost(kerberosName)) {
                userNameBuilder.append("/").append(kerberosName.getHostName());
7
CodeRank
This code example shows how to use the following methods:getAuthenticationID, setAuthorized, setAuthorizedID
		LOG.debug("handleRealmCallback: " + rc.getDefaultText());
		rc.setText(rc.getDefaultText());
	} 
 
	private void handleAuthorizeCallback(AuthorizeCallback ac) {
		String authenticationID = ac.getAuthenticationID();
		LOG.debug("Successfully authenticated client: authenticationID=" 
				+ authenticationID);
		ac.setAuthorizedID(authenticationID);
		ac.setAuthorized(true);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getAuthenticationID, setAuthorized, setAuthorizedID
        LOG.debug("handleRealmCallback: "+ rc.getDefaultText());
        rc.setText(rc.getDefaultText());
    } 
 
    private void handleAuthorizeCallback(AuthorizeCallback ac) {
        String authenticationID = ac.getAuthenticationID();
        LOG.debug("Successfully authenticated client: authenticationID=" + authenticationID);
        ac.setAuthorizedID(authenticationID);
        ac.setAuthorized(true);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getAuthorizedID, isAuthorized
            throw new SaslException("Cannot convert user name from UTF-8", e);
        } 
        if (userName.length() == 0) {
            userName = peerPrincipal.getName();
        } 
        final AuthorizeCallback authorizeCallback = new AuthorizeCallback(peerPrincipal.getName(), userName);
        handleCallback(callbackHandler, authorizeCallback);
        if (authorizeCallback.isAuthorized()) {
            authorizationID = authorizeCallback.getAuthorizedID();
        } else { 
            throw new SaslException("EXTERNAL: " + peerPrincipal.getName() + " is not authorized to act as " + userName);
        } 
 
        return EMPTY;
    } 
 
    private static void handleCallback(CallbackHandler handler, Callback callback) throws SaslException {
        try { 
            handler.handle(new Callback[] {
                    callback,
4
CodeRank
This code example shows how to use the following methods:getAuthorizedID, isAuthorized
                VerifyPasswordCallback vpcb = new VerifyPasswordCallback(password.toCharArray());
                cbh.handle(new Callback[]{ncb,vpcb});
 
                if (vpcb.getVerified()) {
                    vpcb.clearPassword();
                    AuthorizeCallback acb = new AuthorizeCallback(principal,username);
                    cbh.handle(new Callback[]{acb});
                    if(acb.isAuthorized()) {
                        username = acb.getAuthorizedID();
                        completed = true;
                    } else { 
                        completed = true;
                        username = null;
                        throw new SaslException("PLAIN: user not authorized: "+principal);
                    } 
                } else { 
                    throw new SaslException("PLAIN: user not authorized: "+principal);
                } 
            } else { 
                //Client gave no initial response 
4
CodeRank
This code example shows how to use the following methods:setAuthorized, setAuthorizedID
            LOG.debug( "Converted username " + getUsername() + " to Dn " + bindDn );
        } 
 
        ldapSession.putSaslProperty( Context.SECURITY_PRINCIPAL, bindDn );
 
        authorizeCB.setAuthorizedID( bindDn );
        authorizeCB.setAuthorized( true );
    } 
} 
4
CodeRank
This code example shows how to use the following methods:setAuthorized, setAuthorizedID
            LOG.debug( "Converted username " + getUsername() + " to Dn " + bindDn );
        } 
 
        ldapSession.putSaslProperty( Context.SECURITY_PRINCIPAL, bindDn );
 
        authorizeCB.setAuthorizedID( bindDn );
        authorizeCB.setAuthorized( true );
    } 
} 
4
CodeRank
See Code Examples for Java 8 AuthorizeCallback Methods: