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;
22 import java.util.List;
24 import org.openecomp.portalapp.portal.domain.EPApp;
25 import org.openecomp.portalapp.portal.service.AppsCacheService;
26 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
27 import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
28 import org.openecomp.portalsdk.core.service.WebServiceCallServiceImpl;
29 import org.openecomp.portalsdk.core.util.SystemProperties;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.context.annotation.EnableAspectJAutoProxy;
32 import org.springframework.stereotype.Service;
33 import org.springframework.transaction.annotation.Transactional;
35 @Service("remoteWebServiceCallService")
37 @org.springframework.context.annotation.Configuration
38 @EnableAspectJAutoProxy
39 public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl implements RemoteWebServiceCallService {
41 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RemoteWebServiceCallServiceImpl.class);
43 AppsCacheService appCacheService;
47 * @see org.openecomp.portalapp.service.sessionmgt.RemoteWebServiceCallService#verifyRESTCredential(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
49 public boolean verifyRESTCredential(String secretKey, String requestUebKey, String requestAppName,
50 String requestPassword) throws Exception {
51 EPApp appRecord = findEpApp(requestUebKey);
52 if (appRecord == null) {
53 logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey);
57 String encryptedPwdDB = appRecord.getAppPassword();
58 String appUserName = appRecord.getUsername();
59 String decryptedPwd = CipherUtil.decrypt(encryptedPwdDB,
60 secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey);
61 if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName))
68 * currently this method only validates the application key to fetch the application
70 public boolean verifyAppKeyCredential(String requestUebKey) throws Exception {
71 String failMessage = "Failed to find application with UEB key " + requestUebKey;
72 if(requestUebKey == null || requestUebKey.equals("")) {
73 logger.warn(EELFLoggerDelegate.errorLogger, failMessage);
77 EPApp appRecord = findEpApp(requestUebKey);
78 if (appRecord == null) {
79 logger.warn(EELFLoggerDelegate.errorLogger, failMessage);
87 * Searches the FN_APP table for the specified UEB key.
89 * @return EPApp object if the key is found; else null.
91 public EPApp findEpApp(String uebKey) {
93 StringBuffer criteria = new StringBuffer();
94 criteria.append(" where ueb_key = '" + uebKey + "'");
95 list = getDataAccessService().getList(EPApp.class, criteria.toString(), null, null);
96 return (list == null || list.size() == 0) ? null : (EPApp) list.get(0);
99 public static void main(String args[]) throws Exception {
100 String decryptedPwd = CipherUtil.decrypt("okYTaDrhzibcbGVq5mjkVQ==", "AGLDdG4D04BKm2IxIWEr8o==");
101 System.out.print(decryptedPwd);