kerberos.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('controllers/main/admin/kerberos/step4_controller');
  20. App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
  21. name: 'mainAdminKerberosController',
  22. securityEnabled: false,
  23. dataIsLoaded: false,
  24. isRecommendedLoaded: true,
  25. getAddSecurityWizardStatus: function () {
  26. return App.db.getSecurityWizardStatus();
  27. },
  28. setAddSecurityWizardStatus: function (status) {
  29. App.db.setSecurityWizardStatus(status);
  30. },
  31. setDisableSecurityStatus: function (status) {
  32. App.db.setDisableSecurityStatus(status);
  33. },
  34. getDisableSecurityStatus: function (status) {
  35. return App.db.getDisableSecurityStatus();
  36. },
  37. notifySecurityOff: false,
  38. notifySecurityAdd: false,
  39. notifySecurityOffPopup: function () {
  40. var self = this;
  41. App.ModalPopup.show({
  42. header: Em.I18n.t('popup.confirmation.commonHeader'),
  43. primary: Em.I18n.t('ok'),
  44. onPrimary: function () {
  45. App.db.setSecurityDeployCommands(undefined);
  46. self.setDisableSecurityStatus("RUNNING");
  47. App.router.transitionTo('disableSecurity');
  48. this.hide();
  49. },
  50. bodyClass: Ember.View.extend({
  51. templateName: require('templates/main/admin/security/notify_security_off_popup')
  52. })
  53. });
  54. },
  55. getUpdatedSecurityStatus: function () {
  56. this.setSecurityStatus();
  57. return this.get('securityEnabled');
  58. },
  59. /**
  60. * performes clustere check before kerbefos security
  61. * wizard starts if <code>preKerberizeCheck<code> supports is true
  62. * otherwise runs <code>startKerberosWizard<code>
  63. * @method checkAndStartKerberosWizard
  64. */
  65. checkAndStartKerberosWizard: function() {
  66. if (App.get('supports.preKerberizeCheck')) {
  67. App.ajax.send({
  68. name: "admin.kerberos_security.checks",
  69. sender: this,
  70. success: "runSecurityCheckSuccess"
  71. });
  72. } else {
  73. this.startKerberosWizard();
  74. }
  75. },
  76. /**
  77. * success callback of <code>checkAndStartKerberosWizard()</code>
  78. * if there are some fails - it shows popup else open security wizard
  79. * @param data {object}
  80. * @param opt {object}
  81. * @param params {object}
  82. * @returns {App.ModalPopup|undefined}
  83. */
  84. runSecurityCheckSuccess: function (data, opt, params) {
  85. //TODO correct check
  86. if (data.items.someProperty('UpgradeChecks.status', "FAIL")) {
  87. var header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label);
  88. var title = Em.I18n.t('popup.clusterCheck.Security.title');
  89. var alert = Em.I18n.t('popup.clusterCheck.Security.alert');
  90. App.showClusterCheckPopup(data, header, title, alert);
  91. } else {
  92. this.startKerberosWizard();
  93. }
  94. },
  95. startKerberosWizard: function () {
  96. this.setAddSecurityWizardStatus('RUNNING');
  97. App.router.transitionTo('adminAddKerberos');
  98. },
  99. /**
  100. * Loads the security status from server (security_enabled property in cluster-env configuration)
  101. */
  102. loadSecurityStatusFromServer: function () {
  103. if (App.get('testMode')) {
  104. this.set('securityEnabled', !App.get('testEnableSecurity'));
  105. this.set('dataIsLoaded', true);
  106. } else {
  107. //get Security Status From Server
  108. var self = this;
  109. var tags = [{siteName: 'cluster-env'}];
  110. App.router.get('configurationController').getConfigsByTags(tags).done(function (data) {
  111. var configs = data[0].properties;
  112. if (configs) {
  113. self.set('securityEnabled', configs['security_enabled'] === 'true');
  114. }
  115. self.set('dataIsLoaded', true);
  116. });
  117. }
  118. },
  119. /**
  120. * Override <code>App.KerberosWizardStep4Controller</code>
  121. *
  122. * @returns {$.ajax}
  123. */
  124. loadStackDescriptorConfigs: function () {
  125. return App.ajax.send({
  126. sender: this,
  127. name: 'admin.kerberos.kerberos_descriptor',
  128. data: {
  129. stackName: App.get('currentStackName'),
  130. stackVersionNumber: App.get('currentStackVersionNumber')
  131. }
  132. });
  133. },
  134. /**
  135. * Override <code>App.KerberosWizardStep4Controller</code>
  136. *
  137. * @param {App.ServiceConfigProperty[]} configs
  138. * @returns {App.ServiceConfigProperty[]}
  139. */
  140. prepareConfigProperties: function(configs) {
  141. var configProperties = configs.slice(0);
  142. var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
  143. configProperties = configProperties.filter(function(item) {
  144. return installedServiceNames.contains(item.get('serviceName'));
  145. });
  146. configProperties.forEach(function(item) {
  147. if (item.get('serviceName') == 'Cluster') item.set('category', 'General');
  148. else item.set('category', 'Advanced');
  149. });
  150. configProperties.setEach('isEditable', false);
  151. return configProperties;
  152. }
  153. });