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 0BEAD200C6A for ; Wed, 19 Apr 2017 20:51:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0A7E0160B9C; Wed, 19 Apr 2017 18:51:47 +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 50AFA160B94 for ; Wed, 19 Apr 2017 20:51:46 +0200 (CEST) Received: (qmail 12961 invoked by uid 500); 19 Apr 2017 18:51:45 -0000 Mailing-List: contact common-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-dev@hadoop.apache.org Received: (qmail 12950 invoked by uid 99); 19 Apr 2017 18:51:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Apr 2017 18:51:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 8DC8CCD5B9 for ; Wed, 19 Apr 2017 18:51:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id dXk5CckolwEb for ; Wed, 19 Apr 2017 18:51:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 7EB645FC62 for ; Wed, 19 Apr 2017 18:51:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E16B6E06C5 for ; Wed, 19 Apr 2017 18:51:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 449B321B46 for ; Wed, 19 Apr 2017 18:51:42 +0000 (UTC) Date: Wed, 19 Apr 2017 18:51:42 +0000 (UTC) From: "Wei-Chiu Chuang (JIRA)" To: common-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HADOOP-14327) KerberosAuthenticationHandler#authenticate throws meaningless exception with empty server principals MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 19 Apr 2017 18:51:47 -0000 Wei-Chiu Chuang created HADOOP-14327: ---------------------------------------- Summary: KerberosAuthenticationHandler#authenticate throws meaningless exception with empty server principals Key: HADOOP-14327 URL: https://issues.apache.org/jira/browse/HADOOP-14327 Project: Hadoop Common Issue Type: Bug Components: security Affects Versions: 3.0.0-alpha2 Reporter: Wei-Chiu Chuang Priority: Minor If somehow KerberosAuthenticationHandler#authenticate gets an empty service principal set, it throws a useless exception like the following: {noformat} 2017-04-19 10:11:39,812 DEBUG org.apache.hadoop.security.authentication.server.AuthenticationFilter: Authentication exception: org.apache.hadoop.security.authentication.client.AuthenticationExceptio n org.apache.hadoop.security.authentication.client.AuthenticationException: org.apache.hadoop.security.authentication.client.AuthenticationException at org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler.authenticate(KerberosAuthenticationHandler.java:452) at org.apache.hadoop.security.authentication.server.MultiSchemeAuthenticationHandler.authenticate(MultiSchemeAuthenticationHandler.java:193) at org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationHandler.authenticate(DelegationTokenAuthenticationHandler.java:400) at org.apache.hadoop.security.token.delegation.web.MultiSchemeDelegationTokenAuthenticationHandler.authenticate(MultiSchemeDelegationTokenAuthenticationHandler.java:180) at org.apache.solr.security.RequestContinuesRecorderAuthenticationHandler.authenticate(RequestContinuesRecorderAuthenticationHandler.java:69) at org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:532) {noformat} The following code has a logic error. If serverPrincipals is empty, token remains null in the end, but lastException is also null too, so throwing it is meaningless. It should throw with a more meaningful message. {code:title=KerberosAuthenticationHandler#authenticate} AuthenticationToken token = null; Exception lastException = null; for (String serverPrincipal : serverPrincipals) { try { token = runWithPrincipal(serverPrincipal, clientToken, base64, response); } catch (Exception ex) { lastException = ex; LOG.trace("Auth {} failed with {}", serverPrincipal, ex); } finally { if (token != null) { LOG.trace("Auth {} successfully", serverPrincipal); break; } } } if (token != null) { return token; } else { throw new AuthenticationException(lastException); } {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-dev-help@hadoop.apache.org