Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 448F6200C73 for ; Wed, 26 Apr 2017 04:36:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 432C8160BB8; Wed, 26 Apr 2017 02:36:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8987D160BB6 for ; Wed, 26 Apr 2017 04:36:44 +0200 (CEST) Received: (qmail 51538 invoked by uid 500); 26 Apr 2017 02:36:41 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 50383 invoked by uid 99); 26 Apr 2017 02:36:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2017 02:36:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 25F26DFF66; Wed, 26 Apr 2017 02:36:40 +0000 (UTC) From: sudheeshkatkam To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #773: DRILL-4335: Apache Drill should support network enc... Content-Type: text/plain Message-Id: <20170426023640.25F26DFF66@git1-us-west.apache.org> Date: Wed, 26 Apr 2017 02:36:40 +0000 (UTC) archived-at: Wed, 26 Apr 2017 02:36:45 -0000 Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/773#discussion_r113324280 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/security/ServerAuthenticationHandler.java --- @@ -251,25 +255,67 @@ void process(SaslResponseContext context) throws Exception { private static , T extends EnumLite> void handleSuccess(final SaslResponseContext context, final SaslMessage.Builder challenge, final SaslServer saslServer) throws IOException { - context.connection.changeHandlerTo(context.requestHandler); - context.connection.finalizeSaslSession(); - context.sender.send(new Response(context.saslResponseType, challenge.build())); - // setup security layers here.. + final S connection = context.connection; + connection.changeHandlerTo(context.requestHandler); + connection.finalizeSaslSession(); + + // Check the negotiated property before sending the response back to client + try { + final String negotiatedQOP = saslServer.getNegotiatedProperty(Sasl.QOP).toString(); + final String expectedQOP = (connection.isEncryptionEnabled()) + ? SaslProperties.QualityOfProtection.PRIVACY.getSaslQop() + : SaslProperties.QualityOfProtection.AUTHENTICATION.getSaslQop(); + + if (!(negotiatedQOP.equals(expectedQOP))) { + throw new SaslException(String.format("Mismatch in negotiated QOP value: %s and Expected QOP value: %s", + negotiatedQOP, expectedQOP)); + } + + // Update the rawWrapSendSize with the negotiated rawSendSize since we cannot call encode with more than the + // negotiated size of buffer + if (connection.isEncryptionEnabled()) { + final int negotiatedRawSendSize = Integer.parseInt( + saslServer.getNegotiatedProperty(Sasl.RAW_SEND_SIZE).toString()); + if (negotiatedRawSendSize <= 0) { + throw new SaslException(String.format("Negotiated rawSendSize: %d is invalid. Please check the configured " + + "value of encryption.sasl.max_wrapped_size. It might be configured to a very small value.", + negotiatedRawSendSize)); + } + connection.setWrapSizeLimit(negotiatedRawSendSize); --- End diff -- On the server side, there is only one EncryptionContext per connection type. This will have unintended consequences when there are multiple connections! Since rawSendSize is negotiated, EncryptionContext objects need to live and die with a connection. Correct? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---