* ===================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
* under the Apache License, Version 2.0 (the "License");
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
return null;
}
+
} else {
logger.error(EELFLoggerDelegate.errorLogger,
"getUserAsAdminApps: only Account Admin may invoke this function!");
return new ArrayList<EPApp>();
}
}
+
+
@Override
public List<EPApp> getUserByOrgUserIdAsAdminApps(String orgUserId) {
ecompApp.setUrl(app.getUrl());
ecompApp.setAlternateUrl(app.getAlternateUrl());
ecompApp.setUebTopicName(app.getUebTopicName());
- ecompApp.setUebKey(app.getUebKey());
+ //ecompApp.setUebKey(app.getUebKey());
ecompApp.setUebSecret(app.getUebSecret());
ecompApp.setEnabled(app.getEnabled());
ecompApp.setCentralAuth(app.getCentralAuth());
}
}
+
+
@SuppressWarnings("unchecked")
@Override
public List<AppIdAndNameTransportModel> getAdminApps(EPUser user) {
- if (adminRolesService.isAccountAdmin(user)) {
- String format = "SELECT app.APP_ID, app.APP_NAME, app.APP_TYPE FROM FN_APP app inner join FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID "
- + "where userrole.USER_ID = %d AND userrole.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID
- + " AND (app.ENABLED = 'Y' OR app.APP_ID=1)";
- String sql = String.format(format, user.getId());
- // sql += " AND app.APP_REST_ENDPOINT IS NOT NULL AND
- // app.APP_REST_ENDPOINT <> ''";
- logQuery(sql);
+
+ if (adminRolesService.isAccountAdmin(user) && adminRolesService.isRoleAdmin(user)) {
+ final Map<String, Long> params = new HashMap<>();
+ params.put("userId", user.getId());
+ List applicationRoleswithAccountandRoleadmin = dataAccessService
+ .executeNamedQuery("getApplicationsofTheUserwithAdminAndRoleAdmin", params, null);
try {
- return dataAccessService.executeSQLQuery(sql, AppIdAndNameTransportModel.class, null);
+ return applicationRoleswithAccountandRoleadmin;
} catch (Exception e) {
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
logger.error(EELFLoggerDelegate.errorLogger,
- "Exception occurred while fetching the adminApps for user " + user.getLoginId(), e);
+ "Exception occurred while fetching the list of user who has type account and role approver "
+ + user.getLoginId(),
+ e);
}
}
+
+ else {
+ if (adminRolesService.isAccountAdmin(user)) {
+ String format = "SELECT app.APP_ID, app.APP_NAME, app.APP_TYPE FROM FN_APP app inner join FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID "
+ + "where userrole.USER_ID = %d AND userrole.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID
+ + " AND (app.ENABLED = 'Y' OR app.APP_ID=1)";
+ String sql = String.format(format, user.getId());
+ logQuery(sql);
+ try {
+ return dataAccessService.executeSQLQuery(sql, AppIdAndNameTransportModel.class, null);
+ } catch (Exception e) {
+ EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Exception occurred while fetching the adminApps for user " + user.getLoginId(), e);
+ }
+
+ }
+
+ if (adminRolesService.isRoleAdmin(user)) {
+ final Map<String, Long> params = new HashMap<>();
+ params.put("userId", user.getId());
+ List applicationRoles = dataAccessService.executeNamedQuery("getApplicationsofTheUserContainsApprover",
+ params, null);
+
+ try {
+ return applicationRoles;
+ } catch (Exception e) {
+ EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Exception occurred while fetching the list of user who has type approver "
+ + user.getLoginId(),
+ e);
+ }
+
+ }
+ }
+ // sql += " AND app.APP_REST_ENDPOINT IS NOT NULL AND
+ // app.APP_REST_ENDPOINT <> ''";
+
return new ArrayList<AppIdAndNameTransportModel>();
}
protected FieldsValidator onboardingAppFieldsChecker(OnboardingApp onboardingApp) {
FieldsValidator fieldsValidator = new FieldsValidator();
+ if(onboardingApp.isCentralAuth){
if (onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.url == null
|| onboardingApp.url.length() == 0 || onboardingApp.restrictedApp == null
|| onboardingApp.isOpen == null || onboardingApp.isEnabled == null
- || (onboardingApp.id != null && onboardingApp.id.equals(ECOMP_APP_ID))
- // For a normal app (appType==1), these fields must be filled
+ || (onboardingApp.id != null && ECOMP_APP_ID.equals(onboardingApp.id.toString()))
+ // For a normal app (appType == PortalConstants.PortalAppId),
+ // these fields must be filled
// in.
// For a restricted app (appType==2), they will be empty.
- || ((!onboardingApp.restrictedApp)
- && (onboardingApp.username == null || onboardingApp.username.length() == 0
- || onboardingApp.appPassword == null || onboardingApp.appPassword.length() == 0))) {
+ || ((!onboardingApp.restrictedApp) && (onboardingApp.myLoginsAppName == null
+ || onboardingApp.myLoginsAppName.length() == 0 || onboardingApp.myLoginsAppOwner == null
+ || onboardingApp.myLoginsAppOwner.length() == 0 || onboardingApp.username == null
+ || onboardingApp.username.length() == 0 ))) {
fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST);
+ }
+ }else{
+
+ if (onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.url == null
+ || onboardingApp.url.length() == 0 || onboardingApp.restrictedApp == null
+ || onboardingApp.isOpen == null || onboardingApp.isEnabled == null
+ || (onboardingApp.id != null && ECOMP_APP_ID.equals(onboardingApp.id.toString()))
+ // For a normal app (appType == PortalConstants.PortalAppId),
+ // these fields must be filled
+ // in.
+ // For a restricted app (appType==2), they will be empty.
+ || ((!onboardingApp.restrictedApp) && (onboardingApp.myLoginsAppName == null
+ || onboardingApp.myLoginsAppName.length() == 0 || onboardingApp.myLoginsAppOwner == null
+ || onboardingApp.myLoginsAppOwner.length() == 0 || onboardingApp.username == null
+ || onboardingApp.username.length() == 0 || onboardingApp.appPassword == null
+ || onboardingApp.appPassword.length() == 0))) {
+ fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST);
+ }
+
+
}
return fieldsValidator;
}
// Don't encrypt or decrypt the password if it is null or the empty string
private String decryptedPassword(String encryptedAppPwd, EPApp app) {
String result = "";
- if (encryptedAppPwd != null & encryptedAppPwd.length() > 0) {
+ if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) {
try {
result = CipherUtil.decryptPKC(encryptedAppPwd,
SystemProperties.getProperty(SystemProperties.Decryption_Key));
protected String encryptedPassword(String decryptedAppPwd, EPApp app) {
String result = "";
- if (decryptedAppPwd != null & decryptedAppPwd.length() > 0) {
+ if (decryptedAppPwd != null && !decryptedAppPwd.isEmpty()) {
try {
result = CipherUtil.encryptPKC(decryptedAppPwd,
SystemProperties.getProperty(SystemProperties.Decryption_Key));
return userAndRoles;
}
-}
\ No newline at end of file
+}