37 |
37 |
}
|
38 |
38 |
|
39 |
39 |
protected void initializeConfigurations() {
|
40 |
|
try
|
41 |
|
{
|
|
40 |
try {
|
42 |
41 |
ConfigurationDAO configurationDAO = MinimalDAOFactory.minimalInstance().getConfigurationDAO();
|
43 |
42 |
boolean isConfigChange = configurationDAO.isConfigChanged();
|
44 |
43 |
|
45 |
|
if (configFirstLoad || isConfigChange)
|
46 |
|
{
|
|
44 |
if (configFirstLoad || isConfigChange) {
|
|
45 |
|
47 |
46 |
logger.info("Refresh Configuration ....");
|
48 |
47 |
|
49 |
48 |
List configurations = configurationDAO.getConfigurationsFromStore();
|
... | ... | |
52 |
51 |
|
53 |
52 |
int configType;
|
54 |
53 |
Iterator itr = configurations.iterator();
|
55 |
|
while (itr.hasNext())
|
56 |
|
{
|
|
54 |
while (itr.hasNext()) {
|
57 |
55 |
configPojo = (ConfigurationBean) itr.next();
|
58 |
56 |
configType = configPojo.getApplicationId();
|
59 |
57 |
|
60 |
58 |
configBean = (ConfigBean) configurationMap.get(new Integer(configType));
|
61 |
|
if (configBean == null)
|
62 |
|
{
|
|
59 |
if (configBean == null) {
|
63 |
60 |
configBean = new ConfigBean();
|
64 |
61 |
}
|
65 |
|
|
66 |
62 |
logger.info("COnfig Type:" + configType + "=config name:" + configPojo.getConfigName()
|
67 |
63 |
+ "=config Value:" + configPojo.getConfigValue());
|
68 |
64 |
configBean.setConfigBean(configPojo.getConfigName(), configPojo.getConfigValue());
|
... | ... | |
74 |
70 |
}
|
75 |
71 |
logger.info("Refresh Configuration Done ....");
|
76 |
72 |
}
|
77 |
|
} catch (Exception e)
|
78 |
|
{
|
|
73 |
} catch (Exception e) {
|
79 |
74 |
logger.error(e);
|
80 |
75 |
}
|
81 |
76 |
}
|
... | ... | |
99 |
94 |
String configValue = (String) paramMap.get(configName);
|
100 |
95 |
configBean.setConfigBean(configName, configValue);
|
101 |
96 |
}
|
102 |
|
|
103 |
97 |
return configBean;
|
104 |
98 |
}
|
105 |
99 |
|
... | ... | |
155 |
149 |
if (userAlias.equalsIgnoreCase(doubleHashedPassword)) {
|
156 |
150 |
return MinimalConstants.ERR_PASSWORD_SAMEAS_USERALIAS;
|
157 |
151 |
}
|
158 |
|
int rc = verifyStaticPasswordService.verifyStaticPassword(
|
159 |
|
appAccessId, hashedSecretKey, true, MinimalConstants.UTYPE_STATE_USER, txSession);
|
160 |
|
|
161 |
|
if (rc != MinimalConstants.ERR_SUCCESS) {
|
162 |
|
return rc;
|
163 |
|
}
|
164 |
|
Integer appId = null;
|
|
152 |
int rc;
|
165 |
153 |
try {
|
166 |
|
appId = appAccessMgtService.getAppIdForAdmin(appAccessId, txSession);
|
|
154 |
Integer appId = checkAppAccess(appAccessId, hashedSecretKey);
|
167 |
155 |
|
168 |
156 |
if (appId == null)
|
169 |
157 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
... | ... | |
177 |
165 |
} catch (MultipleAppAccessesFound e) {
|
178 |
166 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
179 |
167 |
e.printStackTrace();
|
|
168 |
|
|
169 |
} catch (UPassException e) {
|
|
170 |
rc = e.getErrorCode();
|
|
171 |
e.printStackTrace();
|
180 |
172 |
}
|
181 |
173 |
logger.info("addUser - user alias: [" + userAlias + "] Return: " + rc);
|
182 |
174 |
return rc;
|
... | ... | |
203 |
195 |
return rc;
|
204 |
196 |
}
|
205 |
197 |
|
206 |
|
public int verifyStaticPasswordPerApp(
|
|
198 |
public int verifyStaticPassword_withAppChecked(
|
207 |
199 |
String appAccessId, String hashedSecretKey,
|
208 |
200 |
String username, String hashedPassword) {
|
209 |
201 |
|
210 |
|
int rc = verifyStaticPasswordService.verifyStaticPassword(
|
211 |
|
appAccessId, hashedSecretKey, true,
|
212 |
|
MinimalConstants.UTYPE_STATE_USER);
|
213 |
|
|
214 |
|
if (rc != MinimalConstants.ERR_SUCCESS)
|
215 |
|
return rc;
|
216 |
|
|
217 |
|
Integer appId = null;
|
|
202 |
int rc;
|
218 |
203 |
try {
|
219 |
|
appId = appAccessMgtService.getAppIdForAdmin(appAccessId, null);
|
220 |
|
|
221 |
|
List appIdsForUser = appAccessMgtService.listAppIdsForUser(username, null);
|
222 |
|
rc = appIdsForUser.contains(appId) ?
|
223 |
|
MinimalConstants.ERR_SUCCESS
|
224 |
|
: MinimalConstants.ERR_USERALIAS_NOT_FOUND;
|
225 |
|
|
226 |
|
if (rc != MinimalConstants.ERR_SUCCESS)
|
227 |
|
return rc;
|
228 |
|
|
|
204 |
checkAppAccessToUser(appAccessId, hashedSecretKey, username);
|
229 |
205 |
rc = verifyStaticPasswordService.verifyStaticPassword(
|
230 |
206 |
username, hashedPassword, false, 0);
|
231 |
207 |
|
232 |
208 |
} catch (MultipleAppAccessesFound e) {
|
233 |
209 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
234 |
210 |
e.printStackTrace();
|
|
211 |
|
|
212 |
} catch (UPassException e) {
|
|
213 |
rc = e.getErrorCode();
|
|
214 |
e.printStackTrace();
|
235 |
215 |
}
|
236 |
|
logger.info("verifyStaticPassword - user alias: [" + username + "] Return: " + rc);
|
|
216 |
logger.info("verifyStaticPassword_withAppChecked - user alias: [" + username + "] Return: " + rc);
|
237 |
217 |
return rc;
|
238 |
218 |
}
|
239 |
219 |
|
... | ... | |
273 |
253 |
adminUserAlias, adminUserPassword, true,
|
274 |
254 |
MinimalConstants.UTYPE_STATE_ADMIN);
|
275 |
255 |
|
276 |
|
if (rc != MinimalConstants.ERR_SUCCESS)
|
277 |
|
{
|
|
256 |
if (rc != MinimalConstants.ERR_SUCCESS) {
|
278 |
257 |
return rc;
|
279 |
258 |
}
|
280 |
259 |
|
... | ... | |
294 |
273 |
|
295 |
274 |
MinimalUserBean user = profile.getMinUser();
|
296 |
275 |
final String userAlias = user.getUserAlias();
|
297 |
|
final String doubleHashedPassword = user.getPcipherText();
|
298 |
276 |
|
299 |
277 |
// // check if password is similar to user alias
|
300 |
278 |
// if (userAlias.equalsIgnoreCase(doubleHashedPassword)) {
|
301 |
279 |
// return MinimalConstants.ERR_PASSWORD_SAMEAS_USERALIAS;
|
302 |
280 |
// }
|
303 |
281 |
|
304 |
|
int rc = verifyStaticPasswordService.verifyStaticPassword(
|
305 |
|
appAccessId, hashedSecretKey, true,
|
306 |
|
MinimalConstants.UTYPE_STATE_USER, txSession);
|
307 |
|
|
308 |
|
if (rc != MinimalConstants.ERR_SUCCESS)
|
309 |
|
return rc;
|
310 |
|
|
311 |
|
Integer appId = null;
|
|
282 |
int rc;
|
312 |
283 |
try {
|
313 |
|
appId = appAccessMgtService.getAppIdForAdmin(appAccessId, txSession);
|
|
284 |
Integer appId = checkAppAccess(appAccessId, hashedSecretKey);
|
314 |
285 |
|
315 |
286 |
final Object appIdObj = AppAccessMgtService.profileToAppMap.get(profile.getClass());
|
316 |
287 |
final int appIdForProfile = ((Integer) appIdObj).intValue();
|
... | ... | |
324 |
295 |
} catch (MultipleAppAccessesFound e) {
|
325 |
296 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
326 |
297 |
e.printStackTrace();
|
|
298 |
|
|
299 |
} catch (UPassException e) {
|
|
300 |
rc = e.getErrorCode();
|
|
301 |
e.printStackTrace();
|
327 |
302 |
}
|
328 |
303 |
logger.info("updateProfileShallowly - user alias: [" + userAlias + "] Return: " + rc);
|
329 |
304 |
return rc;
|
... | ... | |
350 |
325 |
logger.info("SP_ChangeStaticPassword - user alias: [" + userAlias + "] Return: " + rc);
|
351 |
326 |
return rc;
|
352 |
327 |
}
|
|
328 |
|
|
329 |
public int changeStaticPassword_withAppChecked(
|
|
330 |
String appAccessId, String hashedSecretKey,
|
|
331 |
String username, String newHashedPassword, String oldHashedPassword) {
|
|
332 |
|
|
333 |
int rc;
|
|
334 |
try {
|
|
335 |
checkAppAccessToUser(appAccessId, hashedSecretKey, username);
|
|
336 |
rc = changeStaticPasswordService.changeStaticPassword(
|
|
337 |
username, newHashedPassword, oldHashedPassword, true);
|
|
338 |
|
|
339 |
} catch (MultipleAppAccessesFound e) {
|
|
340 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
|
341 |
e.printStackTrace();
|
|
342 |
|
|
343 |
} catch (UPassException e) {
|
|
344 |
rc = e.getErrorCode();
|
|
345 |
e.printStackTrace();
|
|
346 |
}
|
|
347 |
logger.info("changeStaticPassword_withAppChecked - user alias: [" + username + "] Return: " + rc);
|
|
348 |
return rc;
|
|
349 |
}
|
|
350 |
|
|
351 |
public int resetPassword_withAppChecked(
|
|
352 |
String appAccessId, String hashedSecretKey,
|
|
353 |
String username, String newHashedPassword) {
|
|
354 |
|
|
355 |
int rc;
|
|
356 |
try {
|
|
357 |
checkAppAccessToUser(appAccessId, hashedSecretKey, username);
|
|
358 |
rc = modifyUserService.modifyUser(
|
|
359 |
username, MinimalConstants.UTYPE_STATE_USER, "",
|
|
360 |
newHashedPassword, MinimalConstants.UID_STATE_ACTIVE);
|
|
361 |
|
|
362 |
} catch (MultipleAppAccessesFound e) {
|
|
363 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
|
364 |
e.printStackTrace();
|
|
365 |
|
|
366 |
} catch (UPassException e) {
|
|
367 |
rc = e.getErrorCode();
|
|
368 |
e.printStackTrace();
|
|
369 |
}
|
|
370 |
logger.info("resetPassword_withAppChecked - user alias: [" + username + "] Return: " + rc);
|
|
371 |
return rc;
|
|
372 |
}
|
|
373 |
|
|
374 |
// Helper methods
|
|
375 |
|
|
376 |
protected Integer checkAppAccessToUser(String appAccessId, String hashedSecretKey, String username)
|
|
377 |
throws MultipleAppAccessesFound, UPassException {
|
|
378 |
|
|
379 |
Integer appId = checkAppAccess(appAccessId, hashedSecretKey);
|
|
380 |
|
|
381 |
List appIdsForUser = appAccessMgtService.listAppIdsForUser(username, null);
|
|
382 |
int rc = appIdsForUser.contains(appId) ?
|
|
383 |
MinimalConstants.ERR_SUCCESS
|
|
384 |
: MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
|
|
385 |
|
|
386 |
if (rc != MinimalConstants.ERR_SUCCESS)
|
|
387 |
throw new UPassException(rc);
|
|
388 |
|
|
389 |
return appId;
|
|
390 |
}
|
|
391 |
|
|
392 |
protected Integer checkAppAccess(String appAccessId, String hashedSecretKey)
|
|
393 |
throws UPassException, MultipleAppAccessesFound {
|
|
394 |
|
|
395 |
int rc = verifyStaticPasswordService.verifyStaticPassword(
|
|
396 |
appAccessId, hashedSecretKey, true,
|
|
397 |
MinimalConstants.UTYPE_STATE_USER);
|
|
398 |
|
|
399 |
if (rc != MinimalConstants.ERR_SUCCESS)
|
|
400 |
throw new UPassException(rc);
|
|
401 |
|
|
402 |
Integer appId = appAccessMgtService.getAppIdForAdmin(appAccessId, null);
|
|
403 |
return appId;
|
|
404 |
}
|
353 |
405 |
}
|