2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
20 package org.onap.dmaap.dbcapi.server;
22 import java.io.FileInputStream;
23 import java.io.IOException;
24 import java.util.Properties;
26 import org.onap.aaf.cadi.PropAccess;
28 public class CadiCertificateManager extends CertificateManager {
29 private PropAccess propAccess;
31 CadiCertificateManager( Properties properties ) {
32 String cadiPropsFile = properties.getProperty("cadi.properties", "etc/org.onap.dmaa-bc.props");
33 logger.info( "using cadi properties in ", cadiPropsFile);
35 propAccess = new PropAccess();
38 propAccess.load( new FileInputStream( cadiPropsFile ));
39 } catch ( IOException e ) {
40 logger.error( "Failed to load props file: " + cadiPropsFile + "\n" + e.getMessage());
43 setKeyStoreType( "jks");
44 setKeyStoreFile( propAccess.getProperty("cadi_keystore") );
45 setKeyStorePassword( decryptPass( propAccess.getProperty("cadi_keystore_password_jks" ) ));
47 setTrustStoreType( "jks");
48 setTrustStoreFile( propAccess.getProperty("cadi_truststore" ) );
49 setTrustStorePassword( decryptPass( propAccess.getProperty("cadi_truststore_password" ) ));
52 private String decryptPass( String password ) {
55 clear = propAccess.decrypt(password, false );
56 } catch (IOException e) {
57 logger.error( "Failed to decrypt " + password + ": " + e.getMessage() );