From dev-return-75254-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Mon Oct 29 16:20:49 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id EFD4B18077A for ; Mon, 29 Oct 2018 16:20:48 +0100 (CET) Received: (qmail 91841 invoked by uid 500); 29 Oct 2018 15:20:48 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 90601 invoked by uid 99); 29 Oct 2018 15:20:47 -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; Mon, 29 Oct 2018 15:20:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BC474E048B; Mon, 29 Oct 2018 15:20:46 +0000 (UTC) From: anmolnar To: dev@zookeeper.apache.org Reply-To: dev@zookeeper.apache.org References: In-Reply-To: Subject: [GitHub] zookeeper pull request #678: ZOOKEEPER-3173: Quorum TLS - support PEM trust/... Content-Type: text/plain Message-Id: <20181029152046.BC474E048B@git1-us-west.apache.org> Date: Mon, 29 Oct 2018 15:20:46 +0000 (UTC) Github user anmolnar commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/678#discussion_r228961395 --- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/common/X509Util.java --- @@ -360,4 +476,26 @@ private void configureSSLServerSocket(SSLServerSocket sslServerSocket) { LOG.debug("Using Java8-optimized cipher suites for Java version {}", javaVersion); return DEFAULT_CIPHERS_JAVA8; } + + /** + * Detects the type of KeyStore / TrustStore file from the file extension. If the file name ends with + * ".jks", returns StoreFileType.JKS. If the file name ends with ".pem", returns + * StoreFileType.PEM. Otherwise, throws an IOException. + * @param filename the filename of the key store or trust store file. + * @return a StoreFileType. + * @throws IOException if the filename does not end with ".jks" or ".pem". + */ + public static StoreFileType detectStoreFileTypeFromFileExtension(File filename) throws IOException { --- End diff -- nit: this can be private nit: Apache Commons IO library has `FileNameUtils.getExtensions(String filename)` doing pretty much the same This file type detection logic is good. Additionally, given that you're refactoring this to Factory pattern anyway, you could also do probing with the concrete implementations if file type cannot be detected from extension. ---