From issues-return-65257-archive-asf-public=cust-asf.ponee.io@ambari.apache.org Tue Jan 9 22:09:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 85FB3180718 for ; Tue, 9 Jan 2018 22:09:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 76176160C3F; Tue, 9 Jan 2018 21:09:07 +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 950C7160C17 for ; Tue, 9 Jan 2018 22:09:06 +0100 (CET) Received: (qmail 82446 invoked by uid 500); 9 Jan 2018 21:09:05 -0000 Mailing-List: contact issues-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ambari.apache.org Delivered-To: mailing list issues@ambari.apache.org Received: (qmail 82437 invoked by uid 99); 9 Jan 2018 21:09:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jan 2018 21:09:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4B1A61A027F for ; Tue, 9 Jan 2018 21:09:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.911 X-Spam-Level: X-Spam-Status: No, score=-99.911 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id RKIwDUABg2ZA for ; Tue, 9 Jan 2018 21:09:03 +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 8630B5FB1F for ; Tue, 9 Jan 2018 21:09:03 +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 F389FE0C18 for ; Tue, 9 Jan 2018 21:09:02 +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 485EE24116 for ; Tue, 9 Jan 2018 21:09:02 +0000 (UTC) Date: Tue, 9 Jan 2018 21:09:02 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@ambari.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AMBARI-22667) Use internal LDAP configuration values rather than ambari.properties values when accessing the configured LDAP server MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMBARI-22667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16319178#comment-16319178 ] ASF GitHub Bot commented on AMBARI-22667: ----------------------------------------- rlevas commented on a change in pull request #77: AMBARI-22667: Use internal LDAP configuration values rather than ambari.properties URL: https://github.com/apache/ambari/pull/77#discussion_r160523467 ########## File path: ambari-server/src/main/java/org/apache/ambari/server/utils/PasswordUtils.java ########## @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ambari.server.utils; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.security.encryption.CredentialProvider; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.inject.Inject; + +/** + * Utility class to read passwords from files or the Credential Store + */ +public class PasswordUtils { + + private static final Logger LOG = LoggerFactory.getLogger(PasswordUtils.class); + private static final Lock LOCK = new ReentrantLock(); + private static final PasswordUtils INSTANCE = new PasswordUtils(); + + /** + * The constructor we need for creating a singleton instance + */ + private PasswordUtils() { + } + + @Inject + private static Configuration configuration; + + private volatile CredentialProvider credentialProvider = null; + + public static PasswordUtils getInstance() { + return INSTANCE; + } + + public String readPassword(String passwordProperty, String defaultPassword) { + if (StringUtils.isNotBlank(passwordProperty)) { + if (CredentialProvider.isAliasString(passwordProperty)) { + return readPasswordFromStore(passwordProperty); + } else { + return readPasswordFromFile(passwordProperty, defaultPassword); + } + } + return defaultPassword; + } + + public String readPasswordFromFile(String filePath, String defaultPassword) { Review comment: Missing JavaDoc ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org > Use internal LDAP configuration values rather than ambari.properties values when accessing the configured LDAP server > --------------------------------------------------------------------------------------------------------------------- > > Key: AMBARI-22667 > URL: https://issues.apache.org/jira/browse/AMBARI-22667 > Project: Ambari > Issue Type: Task > Components: ambari-server > Affects Versions: 3.0.0 > Reporter: Sandor Molnar > Assignee: Sandor Molnar > Priority: Critical > Labels: ldap > Fix For: 3.0.0 > > > Use internal LDAP configuration values rather than ambari.properties values when accessing the configured LDAP server for LDAP sync and authentication. > * Deprecate {{setup-ldap}} from the {{ambari-server}} script. > ** Rather then perform any operations, alert user to configure LDAP integration from the Ambari UI > * Lookup LDAP-specific properties from the Ambari configuration data under the "ldap-configuration" category. > * Remove relevant properties from {{org.apache.ambari.server.configuration.Configuration}} > ** ambari.ldap.isConfigured > ** authentication.ldap.useSSL > ** authentication.ldap.primaryUrl > ** authentication.ldap.secondaryUrl > ** authentication.ldap.baseDn > ** authentication.ldap.bindAnonymously > ** authentication.ldap.managerDn > ** authentication.ldap.managerPassword > ** authentication.ldap.dnAttribute > ** authentication.ldap.usernameAttribute > ** authentication.ldap.username.forceLowercase > ** authentication.ldap.userBase > ** authentication.ldap.userObjectClass > ** authentication.ldap.groupBase > ** authentication.ldap.groupObjectClass > ** authentication.ldap.groupNamingAttr > ** authentication.ldap.groupMembershipAttr > ** authorization.ldap.adminGroupMappingRules > ** authentication.ldap.userSearchFilter > ** authentication.ldap.alternateUserSearchEnabled > ** authentication.ldap.alternateUserSearchFilter > ** authorization.ldap.groupSearchFilter > ** authentication.ldap.referral > ** authentication.ldap.pagination.enabled > ** authentication.ldap.sync.userMemberReplacePattern > ** authentication.ldap.sync.groupMemberReplacePattern > ** authentication.ldap.sync.userMemberFilter > ** authentication.ldap.sync.groupMemberFilter > ** ldap.sync.username.collision.behavior > -- This message was sent by Atlassian JIRA (v6.4.14#64029)