X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FBasicAuthenticationCredentialServiceImpl.java;h=da09c172c608c5a7eb41e6aafd3bb0337830526f;hb=refs%2Fchanges%2F59%2F43759%2F1;hp=b50eb39159a84b0d4aeb9f48f842dffaab1c4219;hpb=21a8761f684745bb300e075c7e98ad897ace9eed;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java index b50eb391..da09c172 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalapp.portal.service; @@ -47,7 +47,10 @@ import org.onap.portalapp.portal.domain.EPEndpoint; import org.onap.portalapp.portal.domain.EPEndpointAccount; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; @@ -68,20 +71,31 @@ public class BasicAuthenticationCredentialServiceImpl implements BasicAuthentica List restrictionsList = new ArrayList(); Criterion contextUserNameCrit = Restrictions.eq("username", username); restrictionsList.add(contextUserNameCrit); - Criterion contextPasswordCrit = Restrictions.eq("password", password); - restrictionsList.add(contextPasswordCrit); @SuppressWarnings("unchecked") List credList = (List) dataAccessService .getList(BasicAuthCredentials.class, null, restrictionsList, null); - if (credList == null || credList.size() == 0) { + if (credList ==null || credList.isEmpty()) { logger.error(EELFLoggerDelegate.errorLogger, "getBasicAuthCredentialByAppName: no credential(s) for " + username); return null; } logger.debug(EELFLoggerDelegate.debugLogger, "getBasicAuthCredentialByAppName: cred list size: " + credList.size()); - BasicAuthCredentials cred = (BasicAuthCredentials) credList.get(0); + BasicAuthCredentials cred = null; + for (BasicAuthCredentials basicAuthCredentials : credList) { + try { + final String dbDecryptedPwd = CipherUtil.decryptPKC(basicAuthCredentials.getPassword()); + if (dbDecryptedPwd.equals(password)) { + cred= (BasicAuthCredentials) basicAuthCredentials; + break; + } + } catch (CipherUtilException e) { + logger.error(EELFLoggerDelegate.errorLogger, "getBasicAuthCredentialByUsernameAndPassword() failed", e); + } + + } + if (cred!=null && cred.getId()!=null) cred.setEndpoints(getEndpointsByAccountId(cred.getId())); return cred; }