Java Code Examples for org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.DataTransferEncryptorMessageProto#Builder

The following examples show how to use org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.DataTransferEncryptorMessageProto#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataTransferSaslUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Send SASL message and negotiated cipher option to client.
 * 
 * @param out stream to receive message
 * @param payload to send
 * @param option negotiated cipher option
 * @throws IOException for any error
 */
public static void sendSaslMessageAndNegotiatedCipherOption(
    OutputStream out, byte[] payload, CipherOption option) 
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(DataTransferEncryptorStatus.SUCCESS);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (option != null) {
    builder.addCipherOption(PBHelper.convert(option));
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 2
Source File: DataTransferSaslUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Send a SASL negotiation message and negotiation cipher options to server.
 * 
 * @param out stream to receive message
 * @param payload to send
 * @param options cipher options to negotiate
 * @throws IOException for any error
 */
public static void sendSaslMessageAndNegotiationCipherOptions(
    OutputStream out, byte[] payload, List<CipherOption> options)
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(DataTransferEncryptorStatus.SUCCESS);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (options != null) {
    builder.addAllCipherOption(PBHelper.convertCipherOptions(options));
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 3
Source File: DataTransferSaslUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a SASL negotiation message.
 *
 * @param out stream to receive message
 * @param status negotiation status
 * @param payload to send
 * @param message to send
 * @throws IOException for any error
 */
public static void sendSaslMessage(OutputStream out,
    DataTransferEncryptorStatus status, byte[] payload, String message)
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(status);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (message != null) {
    builder.setMessage(message);
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 4
Source File: DataTransferSaslUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Send SASL message and negotiated cipher option to client.
 * 
 * @param out stream to receive message
 * @param payload to send
 * @param option negotiated cipher option
 * @throws IOException for any error
 */
public static void sendSaslMessageAndNegotiatedCipherOption(
    OutputStream out, byte[] payload, CipherOption option) 
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(DataTransferEncryptorStatus.SUCCESS);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (option != null) {
    builder.addCipherOption(PBHelper.convert(option));
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 5
Source File: DataTransferSaslUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Send a SASL negotiation message and negotiation cipher options to server.
 * 
 * @param out stream to receive message
 * @param payload to send
 * @param options cipher options to negotiate
 * @throws IOException for any error
 */
public static void sendSaslMessageAndNegotiationCipherOptions(
    OutputStream out, byte[] payload, List<CipherOption> options)
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(DataTransferEncryptorStatus.SUCCESS);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (options != null) {
    builder.addAllCipherOption(PBHelper.convertCipherOptions(options));
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 6
Source File: DataTransferSaslUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a SASL negotiation message.
 *
 * @param out stream to receive message
 * @param status negotiation status
 * @param payload to send
 * @param message to send
 * @throws IOException for any error
 */
public static void sendSaslMessage(OutputStream out,
    DataTransferEncryptorStatus status, byte[] payload, String message)
        throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  
  builder.setStatus(status);
  if (payload != null) {
    builder.setPayload(ByteString.copyFrom(payload));
  }
  if (message != null) {
    builder.setMessage(message);
  }
  
  DataTransferEncryptorMessageProto proto = builder.build();
  proto.writeDelimitedTo(out);
  out.flush();
}
 
Example 7
Source File: FanOutOneBlockAsyncDFSOutputSaslHelper.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void sendSaslMessage(ChannelHandlerContext ctx, byte[] payload,
    List<CipherOption> options) throws IOException {
  DataTransferEncryptorMessageProto.Builder builder =
      DataTransferEncryptorMessageProto.newBuilder();
  builder.setStatus(DataTransferEncryptorStatus.SUCCESS);
  if (payload != null) {
    BuilderPayloadSetter.wrapAndSetPayload(builder, payload);
  }
  if (options != null) {
    builder.addAllCipherOption(PBHelperClient.convertCipherOptions(options));
  }
  DataTransferEncryptorMessageProto proto = builder.build();
  int size = proto.getSerializedSize();
  size += CodedOutputStream.computeRawVarint32Size(size);
  ByteBuf buf = ctx.alloc().buffer(size);
  proto.writeDelimitedTo(new ByteBufOutputStream(buf));
  ctx.write(buf);
}