123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- /**
- * 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.
- */
- var App = require('app');
- require('controllers/main/admin/kerberos/step4_controller');
- App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
- name: 'mainAdminKerberosController',
- securityEnabled: false,
- dataIsLoaded: false,
- isRecommendedLoaded: true,
- getAddSecurityWizardStatus: function () {
- return App.db.getSecurityWizardStatus();
- },
- setAddSecurityWizardStatus: function (status) {
- App.db.setSecurityWizardStatus(status);
- },
- setDisableSecurityStatus: function (status) {
- App.db.setDisableSecurityStatus(status);
- },
- getDisableSecurityStatus: function (status) {
- return App.db.getDisableSecurityStatus();
- },
- notifySecurityOff: false,
- notifySecurityAdd: false,
- notifySecurityOffPopup: function () {
- var self = this;
- App.ModalPopup.show({
- header: Em.I18n.t('popup.confirmation.commonHeader'),
- primary: Em.I18n.t('ok'),
- onPrimary: function () {
- App.db.setSecurityDeployCommands(undefined);
- self.setDisableSecurityStatus("RUNNING");
- App.router.transitionTo('disableSecurity');
- this.hide();
- },
- bodyClass: Ember.View.extend({
- templateName: require('templates/main/admin/security/notify_security_off_popup')
- })
- });
- },
- /**
- * Show confirmation popup and after confirmation send request to regenerate keytabs
- * @method regenerateKeytabs
- * @return {App.ModalPopup}
- */
- regenerateKeytabs: function () {
- var self = this;
- return App.ModalPopup.show({
- /**
- * True - regenerate keytabs only for missing hosts and components, false - regenerate for all hosts and components
- * @type {boolean}
- */
- regenerateKeytabsOnlyForMissing: false,
- header: Em.I18n.t('admin.kerberos.button.regenerateKeytabs'),
- bodyClass: Em.View.extend({
- templateName: require('templates/main/admin/kerberos/regenerate_keytabs_popup_body')
- }),
- onPrimary: function () {
- this._super();
- self.regenerateKeytabsRequest(this.get('regenerateKeytabsOnlyForMissing'));
- }
- });
- },
- /**
- * Send request to regenerate keytabs
- * @param {boolean} missingOnly determines type of regeneration - missing|all
- * @returns {$.ajax}
- */
- regenerateKeytabsRequest: function (missingOnly) {
- return App.ajax.send({
- name: "admin.kerberos_security.regenerate_keytabs",
- sender: this,
- data: {
- type: missingOnly ? 'missing' : 'all'
- },
- success: "regenerateKeytabsSuccess"
- });
- },
- /**
- * Success callback of <code>regenerateKeytabs</code>
- * show background operations popup if appropriate option is set
- */
- regenerateKeytabsSuccess: function () {
- App.router.get('applicationController').dataLoading().done(function (initValue) {
- if (initValue) {
- App.router.get('backgroundOperationsController').showPopup();
- }
- });
- },
- getUpdatedSecurityStatus: function () {
- this.getSecurityStatus();
- return this.get('securityEnabled');
- },
- /**
- * performs cluster check before kerbefos security
- * wizard starts if <code>preKerberizeCheck<code> supports is true
- * otherwise runs <code>startKerberosWizard<code>
- * @method checkAndStartKerberosWizard
- */
- checkAndStartKerberosWizard: function() {
- if (App.get('supports.preKerberizeCheck')) {
- App.ajax.send({
- name: "admin.kerberos_security.checks",
- sender: this,
- success: "runSecurityCheckSuccess"
- });
- } else {
- this.startKerberosWizard();
- }
- },
- /**
- * success callback of <code>checkAndStartKerberosWizard()</code>
- * if there are some fails - it shows popup else open security wizard
- * @param data {object}
- * @param opt {object}
- * @param params {object}
- * @returns {App.ModalPopup|undefined}
- */
- runSecurityCheckSuccess: function (data, opt, params) {
- //TODO correct check
- if (data.items.someProperty('UpgradeChecks.status', "FAIL")) {
- var header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label);
- var title = Em.I18n.t('popup.clusterCheck.Security.title');
- var alert = Em.I18n.t('popup.clusterCheck.Security.alert');
- App.showClusterCheckPopup(data, header, title, alert);
- } else {
- this.startKerberosWizard();
- }
- },
- startKerberosWizard: function () {
- this.setAddSecurityWizardStatus('RUNNING');
- App.router.transitionTo('adminKerberos.adminAddKerberos');
- },
- /**
- * Loads the security status from server (security_enabled property in cluster-env configuration)
- */
- loadSecurityStatusFromServer: function () {
- if (App.get('testMode')) {
- this.set('securityEnabled', !App.get('testEnableSecurity'));
- this.set('dataIsLoaded', true);
- } else {
- //get Security Status From Server
- return this.getSecurityStatus();
- }
- },
- /**
- * Load security status from server.
- * @returns {$.Deferred}
- */
- getSecurityStatus: function () {
- if (App.get('testMode')) {
- this.set('securityEnabled', !App.get('testEnableSecurity'));
- this.set('dataIsLoaded', true);
- } else {
- //get Security Status From Server
- return App.ajax.send({
- name: 'admin.security_status',
- sender: this,
- success: 'getSecurityStatusSuccessCallback',
- error: 'errorCallback'
- });
- }
- },
- getSecurityStatusSuccessCallback: function(data) {
- this.set('dataIsLoaded', true);
- var securityType = data.Clusters.security_type;
- this.set('securityEnabled', securityType === 'KERBEROS');
- },
- errorCallback: function (jqXHR) {
- this.set('dataIsLoaded', true);
- // Show the error popup if the API call received a response from the server.
- // jqXHR.status will be empty when browser cancels the request. Refer to AMBARI-5921 for more info
- if (!!jqXHR.status) {
- this.showSecurityErrorPopup();
- }
- },
- showSecurityErrorPopup: function () {
- App.ModalPopup.show({
- header: Em.I18n.t('common.error'),
- secondary: false,
- bodyClass: Ember.View.extend({
- template: Ember.Handlebars.compile('<p>{{t admin.security.status.error}}</p>')
- })
- });
- },
- /**
- * Override <code>App.KerberosWizardStep4Controller</code>
- *
- * @param {App.ServiceConfigProperty[]} properties
- */
- setStepConfigs: function (properties) {
- this.get('stepConfigs').clear();
- this._super(properties);
- },
-
- /**
- * Override <code>App.KerberosWizardStep4Controller</code>
- *
- * @param {App.ServiceConfigProperty[]} configs
- * @returns {App.ServiceConfigProperty[]}
- */
- prepareConfigProperties: function(configs) {
- var configProperties = configs.slice(0);
- var siteProperties = App.config.get('preDefinedSiteProperties');
- var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
- configProperties = configProperties.filter(function(item) {
- return installedServiceNames.contains(item.get('serviceName'));
- });
- configProperties.setEach('isSecureConfig', false);
- configProperties.forEach(function(property, item, allConfigs) {
- if (property.get('observesValueFrom')) {
- var observedValue = allConfigs.findProperty('name', property.get('observesValueFrom')).get('value');
- property.set('value', observedValue);
- property.set('defaultValue', observedValue);
- }
- if (property.get('serviceName') == 'Cluster') {
- property.set('category', 'Global');
- } else {
- property.set('category', property.get('serviceName'));
- }
- // All user identity should be grouped under "Ambari Principals" category
- if (property.get('identityType') == 'user') property.set('category', 'Ambari Principals');
- var siteProperty = siteProperties.findProperty('name', property.get('name'));
- if (siteProperty) {
- if (siteProperty.category === property.get('category')) {
- property.set('displayName',siteProperty.displayName);
- if (siteProperty.index) {
- property.set('index', siteProperty.index);
- }
- }
- }
- });
- configProperties.setEach('isEditable', false);
- return configProperties;
- }
-
- });
|