2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.service.sessionmgt;
22 import java.util.List;
24 import org.openecomp.portalapp.portal.domain.EPApp;
25 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
26 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
27 import org.openecomp.portalsdk.core.service.WebServiceCallServiceImpl;
28 import org.openecomp.portalsdk.core.util.CipherUtil;
29 import org.openecomp.portalsdk.core.util.SystemProperties;
30 import org.springframework.context.annotation.EnableAspectJAutoProxy;
31 import org.springframework.stereotype.Service;
32 import org.springframework.transaction.annotation.Transactional;
34 @Service("remoteWebServiceCallService")
36 @org.springframework.context.annotation.Configuration
37 @EnableAspectJAutoProxy
39 public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl implements RemoteWebServiceCallService {
41 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RemoteWebServiceCallServiceImpl.class);
45 * @see org.openecomp.portalapp.service.sessionmgt.RemoteWebServiceCallService#verifyRESTCredential(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
47 public boolean verifyRESTCredential(String secretKey, String requestUebKey, String requestAppName,
48 String requestPassword) throws Exception {
49 EPApp appRecord = findEpApp(requestUebKey);
50 if (appRecord == null) {
51 logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey);
55 String encryptedPwdDB = appRecord.getAppPassword();
56 String appUserName = appRecord.getUsername();
57 String decryptedPwd = CipherUtil.decrypt(encryptedPwdDB,
58 secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey);
59 if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName))
66 * Searches the FN_APP table for the specified UEB key.
68 * @return EPApp object if the key is found; else null.
70 public EPApp findEpApp(String uebKey) {
72 StringBuffer criteria = new StringBuffer();
73 criteria.append(" where ueb_key = '" + uebKey + "'");
74 list = getDataAccessService().getList(EPApp.class, criteria.toString(), null, null);
75 return (list == null || list.size() == 0) ? null : (EPApp) list.get(0);
78 public static void main(String args[]) throws Exception {
79 String decryptedPwd = CipherUtil.decrypt("okYTaDrhzibcbGVq5mjkVQ==", "AGLDdG4D04BKm2IxIWEr8o==");
80 System.out.print(decryptedPwd);