7912f047b5cf477e68d01c77aa00acc5809b5a67
[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.config.impl;
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     public String getPCKS12CertFilename()
39     {return this.mPCKS12CertFilename;}
40     public String getPCKS12Passphrase()
41     {return this.mPCKS12Passphrase;    }
42     public boolean trustInsecureSSL()
43     {return this.mTrustInsecureSSL;}
44     public String getApplicationIdentifier()
45     {return this.mApplicationIdentifier;}
46     public String getRemoteUrl()
47     {return this.mRemoteUrl;}
48     public int getConnectionTimeout()
49     {return this.mConnectionTimeout;}
50     public int getReadTimeout()
51     {return this.mReadTimeout;}
52
53     public boolean exists()
54     {return this.mFile.exists();}
55     public AaiClientPropertiesFile(String filename)
56     {
57         this.mFile=new File(filename);
58     }
59     public void load() throws IOException,NumberFormatException
60     {
61         Properties defaultProps = new Properties();
62         FileInputStream in = new FileInputStream(this.mFile);
63         defaultProps.load(in);
64         this.mPCKS12CertFilename=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key",null);
65         this.mPCKS12Passphrase=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd",null);
66         this.mTrustInsecureSSL=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore","false").equals("true");
67         this.mApplicationIdentifier=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application",null);
68         this.mRemoteUrl=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri",null);
69         this.mConnectionTimeout=Integer.parseInt(defaultProps.getProperty("connection.timeout","60000"));
70         this.mReadTimeout=Integer.parseInt(defaultProps.getProperty("read.timeout","60000"));
71         in.close();
72     }
73
74 }