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

This code example shows how to use the following methods:evaluateResponse, getAuthorizationID, isComplete
    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();
                _logger.debug("Authenticated as " + authorizationID);
 
                return new AuthenticationResult(new UsernamePrincipal(authorizationID));
            } 
            else 
            { 
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            } 
        } 
        catch (SaslException e)
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getNegotiatedProperty
     private final int maxSendBufferSize;
     private int packetLength = -1;
 
     public SaslQopHandler(SaslServer server) {
         this.server = server;
         String maxBuf = (String) server.getNegotiatedProperty(Sasl.MAX_BUFFER);
         if (maxBuf != null) {
             maxBufferSize = Integer.parseInt(maxBuf);
         } else { 
             maxBufferSize = -1;
         } 
         String maxSendBuf = (String) server.getNegotiatedProperty(Sasl.RAW_SEND_SIZE);
         if (maxSendBuf != null) {
             maxSendBufferSize = Integer.parseInt(maxSendBuf);
         } else { 
             maxSendBufferSize = -1;
         } 
     } 
 
     private static byte[] readBytes(ByteBuf buffer) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:dispose, wrap
  private void disposeSasl() throws SaslException {
    if (saslClient != null) {
      saslClient.dispose();
    } 
    if (saslServer != null) {
      saslServer.dispose();
    } 
  } 
 
  /** 
   * Writes the specified byte to this output stream. 
   *  
   * @param b 
   *          the <code>byte</code>. 
   * @exception IOException 
   *              if an I/O error occurs. 
   */ 
  @Override 
  public void write(int b) throws IOException {
    if (!useWrap) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isComplete
 
    private void testUnsuccessfulAuthenticationWithSaslServer(AuthenticationStatus expectedStatus)
    { 
        AuthenticationResult failedAuthenticationResult = new AuthenticationResult(expectedStatus);
 
        when(_authenticationProvider.authenticate(_testSaslServer, _saslResponseBytes)).thenReturn(
                failedAuthenticationResult);
        when(_testSaslServer.isComplete()).thenReturn(false);
 
        SubjectAuthenticationResult subjectAuthenticationResult = _subjectCreator.authenticate(_testSaslServer, _saslResponseBytes);
 
        assertSame(expectedStatus, subjectAuthenticationResult.getStatus());
        assertNull(subjectAuthenticationResult.getSubject());
    } 
 
    public void testGetGroupPrincipals() 
    { 
        getAndAssertGroupPrincipals(_group1, _group2);
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:dispose, evaluateResponse, isComplete
 
    protected void secure(final SaslServer ss, final Connection conn, final byte[] response)
    { 
        try 
        { 
            byte[] challenge = ss.evaluateResponse(response);
            if (ss.isComplete())
            { 
                ss.dispose();
                tuneAuthorizedConnection(conn);
            } 
            else 
            { 
                connectionAuthContinue(conn, challenge);
            } 
        } 
        catch (SaslException e)
        { 
            connectionAuthFailed(conn, e);
        } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:evaluateResponse, isComplete
    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;
            } 
            else 
            { 
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            } 
        } 
        catch (SaslException e)
        { 
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:evaluateResponse
  public byte[] evaluateChallengeOrResponse(byte[] challengeOrResponse)
      throws SaslException {
    if (saslClient != null) {
      return saslClient.evaluateChallenge(challengeOrResponse);
    } else { 
      return saslServer.evaluateResponse(challengeOrResponse);
    } 
  } 
 
  /** 
   * After successful SASL negotation, returns the negotiated quality of 
   * protection. 
   * 
   * @return negotiated quality of protection 
   */ 
  public String getNegotiatedQop() {
    if (saslClient != null) {
      return (String) saslClient.getNegotiatedProperty(Sasl.QOP);
    } else { 
      return (String) saslServer.getNegotiatedProperty(Sasl.QOP);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:dispose
  private void disposeSasl() throws SaslException {
    if (saslClient != null) {
      saslClient.dispose();
    } 
    if (saslServer != null) {
      saslServer.dispose();
    } 
  } 
 
  /** 
   * Constructs a SASLInputStream from an InputStream and a SaslServer <br> 
   * Note: if the specified InputStream or SaslServer is null, a 
   * NullPointerException may be thrown later when they are used. 
   *  
   * @param inStream 
   *          the InputStream to be processed 
   * @param saslServer 
   *          an initialized SaslServer object 
   */ 
  public SaslInputStream(InputStream inStream, SaslServer saslServer) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:dispose
        return _realServer.getNegotiatedProperty(propName);
    } 
 
    public void dispose() throws SaslException_realServer.dispose();
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:evaluateResponse, isComplete
        return saslServer;
    } 
 
    public byte[] evaluate(byte[] response) throws SaslException {
 
      if (saslServer.isComplete()) {
         throw new SaslException ("Server is already complete");
      } 
 
      return saslServer.evaluateResponse(response);
   } 
} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 SaslServer Methods: