@Override public <CC extends ClientConnection> SaslMessage process(SaslChallengeContext<CC> context) throws Exception { final SaslMessage.Builder response = SaslMessage.newBuilder(); final SaslClient saslClient = context.connection.getSaslClient(); final byte[] responseBytes = evaluateChallenge(context.ugi, saslClient, context.challenge.getData().toByteArray()); final boolean isComplete = saslClient.isComplete(); logger.trace("Evaluated challenge. Completed? {}.", isComplete); response.setData(responseBytes != null ? ByteString.copyFrom(responseBytes) : ByteString.EMPTY); // if isComplete, the client will get one more response from server response.setStatus(isComplete ? SaslStatus.SASL_SUCCESS : SaslStatus.SASL_IN_PROGRESS); return response.build(); } }
@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?"); } } } }
public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.UserBitShared.SaslMessage message) throws java.io.IOException { if(message.hasMechanism()) output.writeString(1, message.getMechanism(), false); if(message.hasData()) output.writeByteArray(2, message.getData().toByteArray(), false); if(message.hasStatus()) output.writeEnum(3, message.getStatus().getNumber(), false); } public boolean isInitialized(org.apache.drill.exec.proto.UserBitShared.SaslMessage message)
@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 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 void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.UserBitShared.SaslMessage message) throws java.io.IOException { if(message.hasMechanism()) output.writeString(1, message.getMechanism(), false); if(message.hasData()) output.writeByteArray(2, message.getData().toByteArray(), false); if(message.hasStatus()) output.writeEnum(3, message.getStatus().getNumber(), false); } public boolean isInitialized(org.apache.drill.exec.proto.UserBitShared.SaslMessage message)
/** * <code>optional bytes data = 2;</code> */ public Builder clearData() { bitField0_ = (bitField0_ & ~0x00000002); data_ = getDefaultInstance().getData(); onChanged(); return this; }
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; }
/** * <code>optional bytes data = 2;</code> */ public Builder clearData() { bitField0_ = (bitField0_ & ~0x00000002); data_ = getDefaultInstance().getData(); onChanged(); return this; }