@Override public <CC extends ClientConnection> SaslMessage process(SaslChallengeContext<CC> context) throws Exception { final SaslClient saslClient = context.connection.getSaslClient(); if (saslClient.isComplete()) { handleSuccess(context); return null; } else { // server completed before client; so try once, fail otherwise evaluateChallenge(context.ugi, saslClient, context.challenge.getData().toByteArray()); // discard response if (saslClient.isComplete()) { handleSuccess(context); return null; } else { throw new SaslException("Server allegedly succeeded authentication, but client did not. Suspicious?"); } } } }
@Override public void success(SaslMessage value, ByteBuf buffer) { logger.trace("Server responded with message of type: {}", value.getStatus()); final SaslChallengeProcessor processor = CHALLENGE_PROCESSORS.get(value.getStatus()); if (processor == null) { completionListener.failed(RpcException.mapException(
public void initiate(final String mechanismName) { logger.trace("Initiating SASL exchange."); try { final ByteString responseData; final SaslClient saslClient = connection.getSaslClient(); if (saslClient.hasInitialResponse()) { responseData = ByteString.copyFrom(evaluateChallenge(ugi, saslClient, new byte[0])); } else { responseData = ByteString.EMPTY; } client.send(new AuthenticationOutcomeListener<>(client, connection, saslRpcType, ugi, completionListener), connection, saslRpcType, SaslMessage.newBuilder() .setMechanism(mechanismName) .setStatus(SaslStatus.SASL_START) .setData(responseData) .build(), SaslMessage.class, true /* the connection will not be backed up at this point */); logger.trace("Initiated SASL exchange."); } catch (final Exception e) { completionListener.failed(RpcException.mapException(e)); } }
logger.trace("Received SASL message {} from {}", saslResponse.getStatus(), remoteAddress); final SaslResponseProcessor processor = RESPONSE_PROCESSORS.get(saslResponse.getStatus()); if (processor == null) { logger.info("Unknown message type from client from {}. Will stop authentication.", remoteAddress);
return CreatePreparedStatementResp.getDefaultInstance(); case RpcType.SASL_MESSAGE_VALUE: return SaslMessage.getDefaultInstance(); case RpcType.SERVER_META_VALUE: return GetServerMetaResp.getDefaultInstance();
public static MessageLite getResponseDefaultInstance(int rpcType) throws RpcException { switch (rpcType) { case RpcType.ACK_VALUE: return Ack.getDefaultInstance(); case RpcType.HANDSHAKE_VALUE: return BitControlHandshake.getDefaultInstance(); case RpcType.RESP_FRAGMENT_HANDLE_VALUE: return FragmentHandle.getDefaultInstance(); case RpcType.RESP_FRAGMENT_STATUS_VALUE: return FragmentStatus.getDefaultInstance(); case RpcType.RESP_BIT_STATUS_VALUE: return BitStatus.getDefaultInstance(); case RpcType.RESP_QUERY_STATUS_VALUE: return QueryProfile.getDefaultInstance(); case RpcType.RESP_CUSTOM_VALUE: return CustomMessage.getDefaultInstance(); case RpcType.SASL_MESSAGE_VALUE: return SaslMessage.getDefaultInstance(); default: throw new UnsupportedOperationException(); } } }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(1, getMechanismBytes()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, data_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(3, status_.getNumber()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
@Override public <S extends ServerConnection<S>, T extends EnumLite> void process(SaslResponseContext<S, T> context) throws Exception { // at this point, #isComplete must be false; so try once, fail otherwise final SaslServer saslServer = context.connection.getSaslServer(); evaluateResponse(saslServer, context.saslResponse.getData().toByteArray()); // discard challenge if (saslServer.isComplete()) { final SaslMessage.Builder challenge = SaslMessage.newBuilder(); challenge.setStatus(SaslStatus.SASL_SUCCESS); handleSuccess(context, challenge, saslServer); } else { final S connection = context.connection; logger.info("Failed to authenticate client from {} with encryption context:{}", connection.getRemoteAddress().toString(), connection.getEncryptionCtxtString()); throw new SaslException(String.format("Client allegedly succeeded authentication but server did not. " + "Suspicious? [Details: %s]", connection.getEncryptionCtxtString())); } } }
@Override public <S extends ServerConnection<S>, T extends EnumLite> void process(SaslResponseContext<S, T> context) throws Exception { final SaslMessage.Builder challenge = SaslMessage.newBuilder(); final SaslServer saslServer = context.connection.getSaslServer(); final byte[] challengeBytes = evaluateResponse(saslServer, context.saslResponse.getData().toByteArray()); if (saslServer.isComplete()) { challenge.setStatus(SaslStatus.SASL_SUCCESS); if (challengeBytes != null) { challenge.setData(ByteString.copyFrom(challengeBytes)); } handleSuccess(context, challenge, saslServer); } else { challenge.setStatus(SaslStatus.SASL_IN_PROGRESS) .setData(ByteString.copyFrom(challengeBytes)); context.sender.send(new Response(context.saslResponseType, challenge.build())); } } }
public org.apache.drill.exec.proto.UserBitShared.SaslMessage buildPartial() { org.apache.drill.exec.proto.UserBitShared.SaslMessage result = new org.apache.drill.exec.proto.UserBitShared.SaslMessage(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.mechanism_ = mechanism_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } result.data_ = data_; if (((from_bitField0_ & 0x00000004) == 0x00000004)) { to_bitField0_ |= 0x00000004; } result.status_ = status_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public Builder mergeFrom(org.apache.drill.exec.proto.UserBitShared.SaslMessage other) { if (other == org.apache.drill.exec.proto.UserBitShared.SaslMessage.getDefaultInstance()) return this; if (other.hasMechanism()) { bitField0_ |= 0x00000001; mechanism_ = other.mechanism_; onChanged(); } if (other.hasData()) { setData(other.getData()); } if (other.hasStatus()) { setStatus(other.getStatus()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public Builder toBuilder() { return newBuilder(this); }
public static MessageLite getResponseDefaultInstanceServer(int rpcType) throws RpcException { switch (rpcType) { case RpcType.ACK_VALUE: return Ack.getDefaultInstance(); case RpcType.HANDSHAKE_VALUE: return BitClientHandshake.getDefaultInstance(); case RpcType.REQ_RECORD_BATCH_VALUE: return FragmentRecordBatch.getDefaultInstance(); case RpcType.SASL_MESSAGE_VALUE: return SaslMessage.getDefaultInstance(); default: throw new UnsupportedOperationException(); } } }
public org.apache.drill.exec.proto.UserBitShared.SaslMessage getDefaultInstanceForType() { return org.apache.drill.exec.proto.UserBitShared.SaslMessage.getDefaultInstance(); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.drill.exec.proto.UserBitShared.SaslMessage prototype) {
public static Builder newBuilder(org.apache.drill.exec.proto.UserBitShared.SaslMessage prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public org.apache.drill.exec.proto.UserBitShared.SaslMessage.Builder newMessage() { return org.apache.drill.exec.proto.UserBitShared.SaslMessage.newBuilder(); } public java.lang.String getFieldName(int number)
public static MessageLite getResponseDefaultInstanceClient(int rpcType) throws RpcException { switch (rpcType) { case RpcType.ACK_VALUE: return Ack.getDefaultInstance(); case RpcType.HANDSHAKE_VALUE: return BitServerHandshake.getDefaultInstance(); case RpcType.SASL_MESSAGE_VALUE: return SaslMessage.getDefaultInstance(); default: throw new UnsupportedOperationException(); } }
@Override public <S extends ServerConnection<S>, T extends EnumLite> void process(SaslResponseContext<S, T> context) throws Exception { context.connection.initSaslServer(context.saslResponse.getMechanism()); // assume #evaluateResponse must be called at least once RESPONSE_PROCESSORS.get(SaslStatus.SASL_IN_PROGRESS).process(context); } }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeBytes(1, getMechanismBytes()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeBytes(2, data_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeEnum(3, status_.getNumber()); } getUnknownFields().writeTo(output); }