| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172 |
1
1
1
1
12
12
4
4
4
4
4
4
4
4
8
8
8
8
8
8
4
4
4
8
8
12
12
| 'use strict';
;require.register("mixins/common/kdc_credentials_controller_mixin", function (exports, require, module) {
/**
* 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');
var credentialsUtils = require('utils/credentials');
App.KDCCredentialsControllerMixin = Em.Mixin.create({
/**
* Alias name used to store KDC credentials
*
* @type {string}
*/
credentialAlias: credentialsUtils.ALIAS.KDC_CREDENTIALS,
/**
* Returns <code>true</code> if persisted secure storage available.
*
* @type {boolean}
*/
isStorePersisted: Em.computed.alias('App.isCredentialStorePersistent'),
/**
* List of required UI-only properties needed for storing KDC credentials
*
* @type {object[]}
*/
credentialsStoreConfigs: [{
name: 'persist_credentials',
displayType: 'checkbox',
value: 'false',
recommendedValue: 'false',
supportsFinal: false,
recommendedIsFinal: false,
displayName: Em.I18n.t('admin.kerberos.credentials.store.label'),
category: 'Kadmin',
isRequired: false,
isRequiredByAgent: false,
hintMessage: false,
rightSideLabel: true,
isEditable: true,
index: 3
}],
/**
* @param {object} resource resource info to set e.g.
* <code>
* {
* principal: "USERNAME",
* key: "SecretKey",
* type: "persisted"
* }
* </code>
*
* Where:
* <ul>
* <li>principal: the principal (or username) part of the credential to store</li>
* <li>key: the secret key part of the credential to store</li>
* <li>type: declares the storage facility type: "persisted" or "temporary"</li>
* </ul>
* @returns {$.Deferred} promise object
*/
createKDCCredentials: function createKDCCredentials(configs) {
var resource = credentialsUtils.createCredentialResource(Em.getWithDefault(configs.findProperty('name', 'admin_principal') || {}, 'value', ''), Em.getWithDefault(configs.findProperty('name', 'admin_password') || {}, 'value', ''), this._getStorageTypeValue(configs));
return credentialsUtils.createOrUpdateCredentials(App.get('clusterName'), this.get('credentialAlias'), resource);
},
/**
* Remove KDC credentials
*
* @returns {$.Deferred} promise object
*/
removeKDCCredentials: function removeKDCCredentials() {
return credentialsUtils.removeCredentials(App.get('clusterName'), this.get('credentialAlias'));
},
/**
* @see createKDCCredentials
* @param {object} resource
* @returns {$.Deferred} promise object
*/
updateKDCCredentials: function updateKDCCredentials(resource) {
return credentialsUtils.updateCredentials(App.get('clusterName'), this.get('credentialAlias'), resource);
},
/**
* initialize additional properties regarding KDC credential storage
* @method initializeKDCStoreProperties
* @param {App.ServiceConfigProperty[]} configs list of configs
*/
initializeKDCStoreProperties: function initializeKDCStoreProperties(configs) {
this.generateKDCStoreProperties().forEach(function (configObject) {
var configProperty = configs.findProperty('name', configObject.name);
Iif (!Em.isNone(configProperty)) {
Em.setProperties(configProperty, configObject);
} else {
configs.pushObject(configObject);
}
});
},
/**
* Generate additional properties regarding KDC credential storage
* @method updateKDCStoreProperties
* @param {App.ServiceConfigProperty[]} configs list of configs
*/
updateKDCStoreProperties: function updateKDCStoreProperties(configs) {
this.generateKDCStoreProperties().forEach(function (configObject) {
var configProperty = configs.findProperty('name', configObject.name);
Eif (!Em.isNone(configProperty)) {
Em.setProperties(configProperty, configObject);
}
});
},
/**
* generate additional properties regarding KDC credential storage
* @method generateKDCStoreProperties
* @returns {Array} properties
*/
generateKDCStoreProperties: function generateKDCStoreProperties() {
var properties = [];
this.get('credentialsStoreConfigs').forEach(function (item) {
var configObject = App.config.createDefaultConfig(item.name, 'krb5-conf.xml', false);
$.extend(configObject, item);
Eif (item.name === 'persist_credentials') {
if (this.get('isStorePersisted')) {
configObject.hintMessage = Em.I18n.t('admin.kerberos.credentials.store.hint.supported');
} else {
configObject.hintMessage = Em.I18n.t('admin.kerberos.credentials.store.hint.not.supported');
configObject.isEditable = false;
}
}
properties.push(configObject);
}, this);
return properties;
},
/**
* Return storage type e.g. <b>temporary</b>, <b>persisted</b>
*
* @param {App.ServiceConfigProperty[]} configs configs array from step configs
* @returns {string} storage type value
*/
_getStorageTypeValue: function _getStorageTypeValue(configs) {
Eif (this.get('isStorePersisted')) {
return Em.getWithDefault(configs.findProperty('name', 'persist_credentials') || {}, 'value', '') === "true" ? credentialsUtils.STORE_TYPES.PERSISTENT : credentialsUtils.STORE_TYPES.TEMPORARY;
}
return credentialsUtils.STORE_TYPES.TEMPORARY;
}
});
}); |