ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-13375. Kerberos: Add option to store credentials for KDC Credentials popup.
Date Fri, 09 Oct 2015 13:53:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 1fcc5ab1e -> 375205079


AMBARI-13375. Kerberos: Add option to store credentials for KDC Credentials popup.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/37520507
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/37520507
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/37520507

Branch: refs/heads/trunk
Commit: 375205079bf198bc16b4cdf8838692486e910ae5
Parents: 1fcc5ab
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Oct 9 16:53:10 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Oct 9 16:53:20 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  1 +
 .../common/kdc_credentials_controller_mixin.js  | 13 ++--
 .../common/modal_popups/invalid_KDC_popup.hbs   | 14 +++++
 ambari-web/app/utils/credentials.js             | 20 ++++++
 .../common/modal_popups/invalid_KDC_popup.js    | 65 ++++++++++++++++++++
 5 files changed, 106 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/37520507/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 79f190a..b4c32dc 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1031,6 +1031,7 @@ Em.I18n.translations = {
 
   'admin.kerberos.credentials.store.hint.supported': 'When checked, Ambari will store the
KDC Admin credentials so they are not required to be re-entered during future changes of services,
hosts, and components.',
   'admin.kerberos.credentials.store.hint.not.supported': 'Ambari is not configured for storing
credentials',
+  'admin.kerberos.credentials.store.label': 'Save Admin Credentials',
   'admin.kerberos.wizard.configuration.note': 'This is the initial configuration created
by Enable Kerberos wizard.',
   'admin.kerberos.wizard.header':'Enable Kerberos Wizard',
   'admin.kerberos.button.enable': 'Enable Kerberos',

http://git-wip-us.apache.org/repos/asf/ambari/blob/37520507/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js b/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
index 7be3056..67f2664 100644
--- a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
+++ b/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
@@ -26,7 +26,7 @@ App.KDCCredentialsControllerMixin = Em.Mixin.create({
    *
    * @type {string}
    */
-  credentialAlias: 'kdc.admin.credential',
+  credentialAlias: credentialsUtils.ALIAS.KDC_CREDENTIALS,
 
   /**
    * Returns <code>true</code> if persisted secure storage available.
@@ -51,7 +51,7 @@ App.KDCCredentialsControllerMixin = Em.Mixin.create({
       recommendedValue: 'false',
       supportsFinal: false,
       recommendedIsFinal: false,
-      displayName: 'Save Admin credentials',
+      displayName: Em.I18n.t('admin.kerberos.credentials.store.label'),
       category: 'Kadmin',
       isRequired: false,
       isRequiredByAgent: false,
@@ -82,11 +82,10 @@ App.KDCCredentialsControllerMixin = Em.Mixin.create({
    */
   createKDCCredentials: function(configs) {
     var self = this;
-    var resource = {
-      type: this._getStorageTypeValue(configs),
-      key: configs.findProperty('name', 'admin_password').get('value'),
-      principal:  configs.findProperty('name', 'admin_principal').get('value')
-    };
+    var resource = credentialsUtils.createCredentialResource(
+      configs.findProperty('name', 'admin_principal').get('value'),
+      configs.findProperty('name', 'admin_password').get('value'),
+      this._getStorageTypeValue(configs));
     return credentialsUtils.createCredentials(App.get('clusterName'), this.get('credentialAlias'),
resource).fail(function() {
       return self.updateKDCCredentials(resource);
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/37520507/ambari-web/app/templates/common/modal_popups/invalid_KDC_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popups/invalid_KDC_popup.hbs b/ambari-web/app/templates/common/modal_popups/invalid_KDC_popup.hbs
index 557088e..8c9142b 100644
--- a/ambari-web/app/templates/common/modal_popups/invalid_KDC_popup.hbs
+++ b/ambari-web/app/templates/common/modal_popups/invalid_KDC_popup.hbs
@@ -32,4 +32,18 @@
       {{view Ember.TextField type="password" valueBinding="view.parentView.password" class="form-control"}}
     </div>
   </div>
+  <div class="control-group">
+    <span class="control-label"></span>
+    <div class="controls ">
+      {{#if App.supports.storeKDCCredentials}}
+        <label>
+          {{view Ember.Checkbox checkedBinding="view.parentView.storeCredentials" disabledBinding="view.parentView.checkboxDisabled"
classNames="pull-left"}}
+          <span {{bindAttr class=":mls view.parentView.checkboxDisabled:muted"}}>
+            {{t admin.kerberos.credentials.store.label}}
+            <a class="icon-question-sign icon-blue" rel="tooltip" href="javascript:void(null);"
data-toggle="tooltip" {{bindAttr data-original-title="view.parentView.hintMessage"}}><a/>
+          </span>
+        </label>
+      {{/if}}
+    </div>
+  </div>
 </form>

http://git-wip-us.apache.org/repos/asf/ambari/blob/37520507/ambari-web/app/utils/credentials.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/credentials.js b/ambari-web/app/utils/credentials.js
index 7a567e9..0639091 100644
--- a/ambari-web/app/utils/credentials.js
+++ b/ambari-web/app/utils/credentials.js
@@ -29,6 +29,10 @@ module.exports = {
     TEMPORARY_PATH: 'storage.temporary'
   },
 
+  ALIAS: {
+    KDC_CREDENTIALS: 'kdc.admin.credential'
+  },
+
   /**
    * Store credentials to server
    *
@@ -221,5 +225,21 @@ module.exports = {
       dfd.reject(error);
     });
     return dfd.promise();
+  },
+
+  /**
+   * Generate payload for storing credential.
+   *
+   * @param {string} principal principal name
+   * @param {string} key secret key
+   * @param {string} type storage type e.g. <b>persisted</b>, <b>temporary</b>
+   * @returns {object} resource template
+   */
+  createCredentialResource: function(principal, key, type) {
+    return {
+      principal: principal,
+      key: key,
+      type: type
+    };
   }
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/37520507/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js b/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
index 3c73ab1..9c63f8f 100644
--- a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
+++ b/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var credentialsUtils = require('utils/credentials');
 
 /**
  * @param {Object} ajaxOpt - callbek funciton when clicking save
@@ -29,24 +30,88 @@ App.showInvalidKDCPopup = function (ajaxOpt, message) {
     header: Em.I18n.t('popup.invalid.KDC.header'),
     principal: "",
     password: "",
+
+    /**
+     * Store Admin credentials checkbox value
+     *
+     * @type {boolean}
+     */
+    storeCredentials: false,
+
+    /**
+     * Status of persistent storage. Returns <code>true</code> if persistent
storage is available.
+     * @type {boolean}
+     */
+    storePersisted: false,
+
+    /**
+     * Disable checkbox if persistent storage not available
+     *
+     * @type {boolean}
+     */
+    checkboxDisabled: Ember.computed.not('storePersisted'),
+
+    /**
+     * Returns storage type used to save credentials e.g. <b>persistent</b>,
<b>temporary</b> (default)
+     *
+     * @type {string}
+     */
+    storageType: function() {
+      return this.get('storeCredentials') ? credentialsUtils.STORE_TYPES.PERSISTENT : credentialsUtils.STORE_TYPES.TEMPORARY;
+    }.property('storeCredentials'),
+
+    /**
+     * Message to display in tooltip regarding persistent storage state.
+     *
+     * @type {string}
+     */
+    hintMessage: function() {
+      return this.get('storePersisted') ?
+        Em.I18n.t('admin.kerberos.credentials.store.hint.supported') :
+        Em.I18n.t('admin.kerberos.credentials.store.hint.not.supported');
+    }.property('storePersisted'),
+
     bodyClass: Em.View.extend({
       warningMsg: message + Em.I18n.t('popup.invalid.KDC.msg'),
       templateName: require('templates/common/modal_popups/invalid_KDC_popup')
     }),
+
+    willInsertElement: function() {
+      if (App.get('supports.storeKDCCredentials')) {
+        var self = this;
+        credentialsUtils.isStorePersisted(App.get('clusterName')).then(function(isPersisted)
{
+          Em.run.next(function() {
+            self.set('storePersisted', isPersisted);
+          });
+        });
+      }
+    },
+
+    didInsertElement: function() {
+      this._super();
+      App.tooltip(this.$('[rel="tooltip"]'));
+    },
+
     onClose: function() {
       this.hide();
       if (ajaxOpt.kdcCancelHandler) {
         ajaxOpt.kdcCancelHandler();
       }
     },
+
     onSecondary: function() {
       this.hide();
       if (ajaxOpt.kdcCancelHandler) {
         ajaxOpt.kdcCancelHandler();
       }
     },
+
     onPrimary: function () {
       this.hide();
+      if (App.get('supports.storeKDCCredentials')) {
+        var resource = credentialsUtils.createCredentialResource(this.get('principal'), this.get('password'),
this.get('storageType'));
+        credentialsUtils.updateCredentials(App.get('clusterName'), credentialsUtils.ALIAS.KDC_CREDENTIALS,
resource);
+      }
       App.get('router.clusterController').createKerberosAdminSession(this.get('principal'),
this.get('password'), ajaxOpt);
     }
   });


Mime
View raw message