authentication.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.Authentication = DS.Model.extend({
  19. method:DS.attr('boolean'), // use LDAP
  20. primaryServer:DS.attr('string'),
  21. secondaryServer:DS.attr('string'),
  22. useSsl:DS.attr('boolean'),
  23. bindMethod:DS.attr('boolean'), // use credentials
  24. bindUser:DS.attr('string'),
  25. password:DS.attr('string'),
  26. retypePassword:DS.attr('string'),
  27. searchBaseDn:DS.attr('string'),
  28. usernameAttribute:DS.attr('string')
  29. });
  30. App.Authentication.FIXTURES = [
  31. {
  32. id:1,
  33. method:false,
  34. primary_server:"1.2.3.4:78",
  35. secondary_server:"225.225.255.255:12",
  36. use_ssl:false,
  37. bind_method:false,
  38. bind_user:"hadoop\Administrator",
  39. password:"1234",
  40. retype_password:"1234",
  41. search_base_dn:"DC=hadoop,DC=abc,DC=com",
  42. username_attribute:"sAMAccountName"
  43. }
  44. ]
  45. App.AuthenticationForm = App.Form.extend({
  46. testResult:false,
  47. isObjectNew:false,
  48. fieldsOptions:[
  49. { name:"method", displayName:"", isRequired:false, displayType:"select",
  50. values:[
  51. {value:0, label:Em.I18n.t("admin.authentication.form.method.database")},
  52. {value:1, label:Em.I18n.t("admin.authentication.form.method.ldap")}
  53. ]
  54. },
  55. { name:"primaryServer", displayName:Em.I18n.t("admin.authentication.form.primaryServer"), validator:'ipaddress'},
  56. { name:"secondaryServer", displayName:Em.I18n.t("admin.authentication.form.secondaryServer"), validator:'ipaddress'},
  57. { name:"useSsl", displayName:Em.I18n.t("admin.authentication.form.useSsl"), displayType:"checkbox", isRequired:false },
  58. { name:"bindMethod", displayName:'', displayType:"select", isRequired:false,
  59. values:[
  60. {value:0, label:Em.I18n.t("admin.authentication.form.bind.anonymously")},
  61. {value:1, label:Em.I18n.t("admin.authentication.form.bind.useCrenedtials")}
  62. ]},
  63. { name:"bindUser", displayName:Em.I18n.t('admin.authentication.form.bindUserDN')},
  64. { name:"password", displayName:Em.I18n.t('form.password'), displayType:"password" },
  65. { name:"passwordRetype", displayName:Em.I18n.t('form.passwordRetype'), displayType:"passwordRetype"},
  66. { name:"searchBaseDn", displayName:Em.I18n.t('admin.authentication.form.searchBaseDN')},
  67. { name:"usernameAttribute", displayName:Em.I18n.t('admin.authentication.form.usernameAttribute')},
  68. { name:"userDN", displayName:Em.I18n.t('admin.authentication.form.userDN') },
  69. { name:"userPassword", displayName:Em.I18n.t('admin.authentication.form.password'), displayType:'password'}
  70. ],
  71. fields:[],
  72. testConfiguration:function () {
  73. console.warn('Configuration test is randomized');
  74. this.set('testResult', parseInt(Math.random() * 2));
  75. return true;
  76. },
  77. testConfigurationMessage:function () {
  78. return this.get('testResult') ? Em.I18n.t('admin.authentication.form.test.success') : Em.I18n.t('admin.authentication.form.test.fail');
  79. }.property('testResult'),
  80. testConfigurationClass:function () {
  81. return this.get('testResult') ? "text-success" : "text-error";
  82. }.property('testConfigurationMessage')
  83. });