step4_controller.js 3.9 KB

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