Java 8 SaslException - 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 SaslException class.

This code example shows how to use the following methods:
                evaluateOutcome(challenge);
                response = new byte[0];
                _state = State.COMPLETE;
                break; 
            default: 
                throw new SaslException("No challenge expected in state " + _state);
        } 
        return response;
    } 
 
    private void evaluateOutcome(final byte[] challenge) throws SaslExceptionString serverFinalMessage = new String(challenge, ASCII);
        String[] parts = serverFinalMessage.split(",");
        if(!parts[0].startsWith("v="))
        { 
            throw new SaslException("Server final message did not contain verifier");
        } 
        byte[] serverSignature = DatatypeConverter.parseBase64Binary(parts[0].substring(2));
        if(!Arrays.equals(_serverSignature, serverSignature))
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
            //simply delegate to the built in CRAM-MD5 SaslServer 
            return new CRAMMD5HashedSaslServer(mechanism, "AMQP", localFQDN, null, new MD5Callbackhandler(true));
        } 
        else 
        { 
            throw new SaslException("Unsupported mechanism: " + mechanism);
        } 
    } 
 
    @Override 
    public AuthenticationResult authenticate(final String username, final String password)
    { 
        ManagedUser user = getUser(username);
        AuthenticationResult result;
        if(user != null && user.getPassword().equals(createStoredPassword(password)))
        { 
            result = new AuthenticationResult(new UsernamePrincipal(username));
        } 
        else 
        { 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        { 
            return Sasl.createSaslServer(mechanism, "AMQP", localFQDN, null, new SimpleCramMd5CallbackHandler());
        } 
        else 
        { 
            throw new SaslException("Unknown mechanism: " + mechanism);
        } 
    } 
 
    @Override 
    public AuthenticationResult authenticate(SaslServer server, byte[] response)
    { 
        try 
        { 
            // Process response from the client 
            byte[] challenge = server.evaluateResponse(response != null ? response : new byte[0]);
 
            if (server.isComplete())
            { 
                String authorizationID = server.getAuthorizationID();
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    public SaslServer createSaslServer(String mechanism, String localFQDN, Principal externalPrincipal) throws SaslExceptionCallbackHandler callbackHandler = _callbackHandlerMap.get(mechanism);
        if(callbackHandler == null)
        { 
            throw new SaslException("Unsupported mechanism: " + mechanism);
        } 
 
        if(CRAMMD5Initialiser.MECHANISM.equals(mechanism))
        { 
            //simply delegate to the built in CRAM-MD5 SaslServer 
            return Sasl.createSaslServer(mechanism, "AMQP", localFQDN, null, callbackHandler);
        } 
        else if(PlainSaslServer.MECHANISM.equals(mechanism))
        { 
            return new PlainSaslServer(callbackHandler);
        } 
 
        throw new SaslException("Unsupported mechanism: " + mechanism);
    } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMessage
        { 
            byte[] resp = this.server.evaluateResponse(wrongResponse);
        } 
        catch (SaslException e)
        { 
            assertTrue(e.getMessage().contains("Authentication failed"));
            exceptionCaught = true;
        } 
        if (!exceptionCaught)
        { 
            fail("Should have thrown SaslException");
        } 
    } 
     
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        { 
            return new AnonymousSaslServer(); 
        } 
        else 
        { 
            throw new SaslException("Unknown mechanism: " + mechanism);
        } 
    } 
 
    @Override 
    public AuthenticationResult authenticate(SaslServer server, byte[] response)
    { 
        try 
        { 
            // Process response from the client 
            byte[] challenge = server.evaluateResponse(response != null ? response : new byte[0]);
 
            if (server.isComplete())
            { 
                return ANONYMOUS_AUTHENTICATION;
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     * if the key already has a value.  
     */ 
    private static void extractDirective(HashMap<String, String> map,
            String key, String value) throws SaslException {
        if (map.get(key) != null) {
            throw new SaslException("Peer sent more than one " + key
                    + " directive"); 
        } 
 
        map.put(key, value);
    } 
 
    /** 
     * Is character a linear white space ? 
     * LWS            = [CRLF] 1*( SP | HT ) 
     * Note that we're checking individual bytes instead of CRLF 
     *  
     * @param b the byte to check 
     * @return <code>true</code> if it's a linear white space 
     */ 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        return _authorizationId;
    } 
 
    public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException
    { 
        throw new SaslException("Unsupported operation");
    } 
 
    public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException
    { 
        throw new SaslException("Unsupported operation");
    } 
 
    public Object getNegotiatedProperty(String propName)
    { 
        return null; 
    } 
 
    public void dispose() throws SaslException
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        { 
            return new ExternalSaslServer(externalPrincipal, _useFullDN);
        } 
        else 
        { 
            throw new SaslException("Unknown mechanism: " + mechanism);
        } 
    } 
 
    @Override 
    public AuthenticationResult authenticate(SaslServer server, byte[] response)
    { 
        // Process response from the client 
        try 
        { 
            server.evaluateResponse(response != null ? response : new byte[0]);
 
            Principal principal = ((ExternalSaslServer)server).getAuthenticatedPrincipal();
 
            if(principal != null)
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                        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 
                if( counter++ > 1 ) {
                    throw new SaslException("PLAIN expects a response");
                } 
                return null; 
            } 
        } catch (UnsupportedEncodingException e) {
            aborted = true;
            throw new SaslException("UTF8 not available on platform", e);
        } catch (UnsupportedCallbackException e) {
            aborted = true;
            throw new SaslException("PLAIN authentication failed for: "+username, e);
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 SaslException Methods: