Package org.apache.giraph.comm.netty

Examples of org.apache.giraph.comm.netty.SaslNettyClient$SaslClientCallbackHandler


    }
    MessageEvent e = (MessageEvent) evt;
    Object originalMessage = e.getMessage();
    Object decodedMessage = decode(ctx, ctx.getChannel(), originalMessage);
    // Generate SASL response to server using Channel-local SASL client.
    SaslNettyClient saslNettyClient = NettyClient.SASL.get(ctx.getChannel());
    if (saslNettyClient == null) {
      throw new Exception("handleUpstream: saslNettyClient was unexpectedly " +
          "null for channel: " + ctx.getChannel());
    }
    if (decodedMessage.getClass() == SaslCompleteRequest.class) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("handleUpstream: Server has sent us the SaslComplete " +
            "message. Allowing normal work to proceed.");
      }
      synchronized (saslNettyClient.getAuthenticated()) {
        saslNettyClient.getAuthenticated().notify();
      }
      if (!saslNettyClient.isComplete()) {
        LOG.error("handleUpstream: Server returned a Sasl-complete message, " +
            "but as far as we can tell, we are not authenticated yet.");
        throw new Exception("handleUpstream: Server returned a " +
            "Sasl-complete message, but as far as " +
            "we can tell, we are not authenticated yet.");
      }
      // Remove SaslClientHandler and replace LengthFieldBasedFrameDecoder
      // from client pipeline.
      ctx.getPipeline().remove(this);
      ctx.getPipeline().replace("length-field-based-frame-decoder",
          "fixed-length-frame-decoder",
          new FixedLengthFrameDecoder(RequestServerHandler.RESPONSE_BYTES));
      return;
    }
    SaslTokenMessageRequest serverToken =
      (SaslTokenMessageRequest) decodedMessage;
    if (LOG.isDebugEnabled()) {
      LOG.debug("handleUpstream: Responding to server's token of length: " +
          serverToken.getSaslToken().length);
    }
    // Generate SASL response (but we only actually send the response if it's
    // non-null.
    byte[] responseToServer = saslNettyClient.saslResponse(serverToken);
    if (responseToServer == null) {
      // If we generate a null response, then authentication has completed (if
      // not, warn), and return without sending a response back to the server.
      if (LOG.isDebugEnabled()) {
        LOG.debug("handleUpstream: Response to server is null: " +
            "authentication should now be complete.");
      }
      if (!saslNettyClient.isComplete()) {
        LOG.warn("handleUpstream: Generated a null response, " +
            "but authentication is not complete.");
      }
      return;
    } else {
View Full Code Here


  @Override
  public void channelRead(ChannelHandlerContext ctx, Object msg)
    throws Exception {
    WritableRequest decodedMessage = decode(ctx, msg);
    // Generate SASL response to server using Channel-local SASL client.
    SaslNettyClient saslNettyClient = ctx.attr(NettyClient.SASL).get();
    if (saslNettyClient == null) {
      throw new Exception("handleUpstream: saslNettyClient was unexpectedly " +
          "null for channel: " + ctx.channel());
    }
    if (decodedMessage.getClass() == SaslCompleteRequest.class) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("handleUpstream: Server has sent us the SaslComplete " +
            "message. Allowing normal work to proceed.");
      }
      synchronized (saslNettyClient.getAuthenticated()) {
        saslNettyClient.getAuthenticated().notify();
      }
      if (!saslNettyClient.isComplete()) {
        LOG.error("handleUpstream: Server returned a Sasl-complete message, " +
            "but as far as we can tell, we are not authenticated yet.");
        throw new Exception("handleUpstream: Server returned a " +
            "Sasl-complete message, but as far as " +
            "we can tell, we are not authenticated yet.");
      }
      // Remove SaslClientHandler and replace LengthFieldBasedFrameDecoder
      // from client pipeline.
      ctx.pipeline().remove(this);
      ctx.pipeline().replace("length-field-based-frame-decoder",
          "fixed-length-frame-decoder",
          new FixedLengthFrameDecoder(RequestServerHandler.RESPONSE_BYTES));
      return;
    }
    SaslTokenMessageRequest serverToken =
      (SaslTokenMessageRequest) decodedMessage;
    if (LOG.isDebugEnabled()) {
      LOG.debug("handleUpstream: Responding to server's token of length: " +
          serverToken.getSaslToken().length);
    }
    // Generate SASL response (but we only actually send the response if it's
    // non-null.
    byte[] responseToServer = saslNettyClient.saslResponse(serverToken);
    if (responseToServer == null) {
      // If we generate a null response, then authentication has completed (if
      // not, warn), and return without sending a response back to the server.
      if (LOG.isDebugEnabled()) {
        LOG.debug("handleUpstream: Response to server is null: " +
            "authentication should now be complete.");
      }
      if (!saslNettyClient.isComplete()) {
        LOG.warn("handleUpstream: Generated a null response, " +
            "but authentication is not complete.");
      }
      return;
    } else {
View Full Code Here

TOP

Related Classes of org.apache.giraph.comm.netty.SaslNettyClient$SaslClientCallbackHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.