8329ec0e9ebfbb7d01fb15503a75bc0485a850d4
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config;
19
20 import java.io.File;
21 import java.io.FileInputStream;
22 import java.io.IOException;
23 import java.util.Properties;
24
25 public class AaiClientPropertiesFile {
26
27     private final File mFile;
28     private String mPCKS12CertFilename;
29     private String mPCKS12Passphrase;
30     private boolean mTrustInsecureSSL;
31     private String mApplicationIdentifier;
32     private String mRemoteUrl;
33     private int mConnectionTimeout;
34     private int mReadTimeout;
35
36     public String getFilename() {
37         return this.mFile.getAbsolutePath();
38     }
39
40     public String getPCKS12CertFilename() {
41         return this.mPCKS12CertFilename;
42     }
43
44     public String getPCKS12Passphrase() {
45         return this.mPCKS12Passphrase;
46     }
47
48     public boolean trustInsecureSSL() {
49         return this.mTrustInsecureSSL;
50     }
51
52     public String getApplicationIdentifier() {
53         return this.mApplicationIdentifier;
54     }
55
56     public String getRemoteUrl() {
57         return this.mRemoteUrl;
58     }
59
60     public int getConnectionTimeout() {
61         return this.mConnectionTimeout;
62     }
63
64     public int getReadTimeout() {
65         return this.mReadTimeout;
66     }
67
68     public boolean exists() {
69         return this.mFile.exists();
70     }
71
72     public AaiClientPropertiesFile(String filename) {
73         this.mFile = new File(filename);
74     }
75
76     public void load() throws IOException, NumberFormatException {
77         Properties defaultProps = new Properties();
78         FileInputStream in = new FileInputStream(this.mFile);
79         defaultProps.load(in);
80         this.mPCKS12CertFilename = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", null);
81         this.mPCKS12Passphrase = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd", null);
82         this.mTrustInsecureSSL = defaultProps
83                 .getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore", "false").equals("true");
84         this.mApplicationIdentifier = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application", null);
85         this.mRemoteUrl = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri", null);
86         this.mConnectionTimeout = Integer.parseInt(defaultProps.getProperty("connection.timeout", "60000"));
87         this.mReadTimeout = Integer.parseInt(defaultProps.getProperty("read.timeout", "60000"));
88         in.close();
89     }
90
91 }