step4_controller.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs, {
  19. name: 'kerberosWizardStep4Controller',
  20. clearStep: function() {
  21. this.set('isRecommendedLoaded', false);
  22. this.set('selectedService', null);
  23. this.set('stepConfigs', []);
  24. },
  25. loadStep: function() {
  26. var self = this;
  27. this.clearStep();
  28. this.getStackDescriptorConfigs().then(function(properties) {
  29. self.setStepConfigs(properties);
  30. self.set('isRecommendedLoaded', true);
  31. });
  32. },
  33. /**
  34. * Create service config object for Kerberos service.
  35. *
  36. * @param {Em.Object[]} configCategories
  37. * @param {App.ServiceConfigProperty[]} configs
  38. * @returns {Em.Object}
  39. */
  40. createServiceConfig: function(configCategories, configs) {
  41. return App.ServiceConfig.create({
  42. displayName: 'Kerberos Descriptor',
  43. name: 'KERBEROS',
  44. serviceName: 'KERBEROS',
  45. configCategories: configCategories,
  46. configs: configs,
  47. showConfig: true,
  48. selected: true
  49. });
  50. },
  51. /**
  52. * Prepare step configs using stack descriptor properties.
  53. *
  54. * @param {App.ServiceConfigProperty[]} configs
  55. */
  56. setStepConfigs: function(configs) {
  57. var selectedService = App.StackService.find().findProperty('serviceName', 'KERBEROS');
  58. var configCategories = selectedService.get('configCategories');
  59. this.prepareConfigProperties(configs);
  60. this.get('stepConfigs').pushObject(this.createServiceConfig(configCategories, configs));
  61. this.set('selectedService', this.get('stepConfigs')[0]);
  62. },
  63. /**
  64. *
  65. * @param {} configs
  66. */
  67. prepareConfigProperties: function(configs) {
  68. var self = this;
  69. var realmValue = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'realm').value;
  70. configs.findProperty('name', 'realm').set('value', realmValue);
  71. configs.findProperty('name', 'realm').set('defaultValue', realmValue);
  72. configs.setEach('isSecureConfig', false);
  73. configs.forEach(function(property, item, allConfigs) {
  74. if (['spnego_keytab', 'spnego_principal'].contains(property.get('name'))) {
  75. property.addObserver('value', self, 'spnegoPropertiesObserver');
  76. }
  77. if (property.get('observesValueFrom')) {
  78. var observedValue = allConfigs.findProperty('name', property.get('observesValueFrom')).get('value');
  79. property.set('value', observedValue);
  80. property.set('defaultValue', observedValue);
  81. }
  82. if (property.get('serviceName') == 'Cluster') property.set('category', 'General');
  83. else property.set('category', 'Advanced');
  84. });
  85. },
  86. spnegoPropertiesObserver: function(configProperty) {
  87. var self = this;
  88. this.get('stepConfigs')[0].get('configs').forEach(function(config) {
  89. if (config.get('observesValueFrom') == configProperty.get('name')) {
  90. Em.run.once(self, function() {
  91. config.set('value', configProperty.get('value'));
  92. config.set('defaultValue', configProperty.get('value'));
  93. });
  94. }
  95. });
  96. },
  97. submit: function() {
  98. this.saveConfigurations();
  99. App.router.send('next');
  100. },
  101. saveConfigurations: function() {
  102. var configs = this.get('stepConfigs')[0].get('configs');
  103. this.get('wizardController').setDBProperty('kerberosDescriptorConfigs', configs);
  104. this.set('wizardController.content.kerberosDescriptorConfigs', configs);
  105. }
  106. });