X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2FPAPRestConfig.java;h=2ca87af28cc36a13b1fe8d000ce4f8e2bb67b0f0;hp=6c80f9c0436a512f6f3b556ca9e28c7b67cddd39;hb=c2ca6ea5cb44103903e1409e8dd6db80167e61e8;hpb=3555353c1baedc080f310e9e737a46f7cc7aa89e diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java index 6c80f9c04..2ca87af28 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java @@ -2,14 +2,15 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +18,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.pap.xacml.rest; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -31,7 +32,8 @@ import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; import org.hibernate.SessionFactory; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; -import org.onap.policy.utils.CryptoUtils; +import org.onap.policy.rest.XacmlRestProperties; +import org.onap.policy.utils.PeCryptoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -45,9 +47,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc @EnableTransactionManagement -@ComponentScan(basePackages = { "org.onap.*", "com.*" }) +@ComponentScan(basePackages = {"org.onap.*", "com.*"}) public class PAPRestConfig extends WebMvcConfigurerAdapter { - private static final Logger LOGGER = FlexLogger.getLogger(PAPRestConfig.class); + private static final Logger LOGGER = FlexLogger.getLogger(PAPRestConfig.class); private static String dbDriver = null; private static String dbUrl = null; @@ -55,17 +57,18 @@ public class PAPRestConfig extends WebMvcConfigurerAdapter { private static String dbPassword = null; @PostConstruct - public void init(){ + public void init() { Properties prop = new Properties(); - try(InputStream input = new FileInputStream("xacml.pap.properties")) { + try (InputStream input = new FileInputStream("xacml.pap.properties")) { // load a properties file prop.load(input); setDbDriver(prop.getProperty("javax.persistence.jdbc.driver")); setDbUrl(prop.getProperty("javax.persistence.jdbc.url")); setDbUserName(prop.getProperty("javax.persistence.jdbc.user")); - setDbPassword( CryptoUtils.decryptTxtNoExStr(prop.getProperty("javax.persistence.jdbc.password", ""))); - }catch(Exception e){ - LOGGER.error("Exception Occured while loading properties file"+e); + PeCryptoUtils.initAesKey(prop.getProperty(XacmlRestProperties.PROP_AES_KEY)); + setDbPassword(PeCryptoUtils.decrypt(prop.getProperty("javax.persistence.jdbc.password"))); + } catch (Exception e) { + LOGGER.error("Exception Occured while loading properties file" + e); } } @@ -130,7 +133,7 @@ public class PAPRestConfig extends WebMvcConfigurerAdapter { } public static void setDbPassword(String dbPassword) { - PAPRestConfig.dbPassword = CryptoUtils.decryptTxtNoExStr(dbPassword); + PAPRestConfig.dbPassword = dbPassword; } }