Change the header to SO
[so.git] / bpmn / MSORESTClient / src / main / java / org / openecomp / mso / rest / RESTConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.mso.rest;
22
23 /**
24  * Configuration values to be used by the RESTClient.
25  *
26  * @version 1.0
27  *
28  */
29 public class RESTConfig {
30     private final String URL;
31
32     private final boolean trustAllCerts;
33     private final String proxyHost;
34     private final int proxyPort;
35
36     /**
37      * Creates a RESTConfig with the specified URL.
38      * <p>
39      * By default, no proxy will be used, and only valid certificates will
40      * be used.
41      *
42      * @param URL url to set
43      */
44     public RESTConfig(final String URL) {
45         this(URL, null, -1, false);
46     }
47
48     /**
49      * Creates a RESTConfig with the specified URL and whether to trust all
50      * certificates.
51      * <p>
52      * Trusting all certificates is useful for testing self-signed
53      * certificates. By default, no proxy will be used.
54      *
55      * @param URL url to set
56      * @param trustAllCerts whether to trust all certificates
57      */
58     public RESTConfig(final String URL, final boolean trustAllCerts) {
59         this(URL, null, -1, trustAllCerts);
60     }
61     
62     /**
63      * Creates a RESTConfig with the specified URL and proxy.
64      * <p>
65      * By default, only valid certificates will be allowed.
66      *
67      * @param URL url to set
68      * @param proxyHost proxy host to set 
69      * @param proxyPort proxy port to set
70      */
71     public RESTConfig(final String URL, final String proxyHost, 
72             final int proxyPort) {
73
74         this(URL, proxyHost, proxyPort, false);
75     }
76
77     /**
78      * Creates a RESTConfig object with the specified URL, proxy host, proxy
79      * port, and whether to trust all certificates. Allowing all certificates
80      * is useful for testing self-signed certificates.
81      *
82      * @param URL url to set
83      * @param proxyHost proxy host to set
84      * @param proxyPort porxy port to set
85      * @param trustAllCerts whether to trust all certificates
86      */
87     public RESTConfig(final String URL, final String proxyHost, 
88             final int proxyPort, boolean trustAllCerts) {
89         
90         this.URL = URL;
91         this.proxyHost = proxyHost;
92         this.proxyPort = proxyPort;
93         this.trustAllCerts = trustAllCerts;
94     }
95
96     /**
97      * Gets the URL to use.
98      *
99      * @return URL to use
100      */
101     public String getURL() {
102         return this.URL;
103     }
104
105     /**
106      * Gets whether to trust all certificates.
107      * 
108      * @return true if to trust all certificates, false otherwise
109      */
110     public boolean trustAllCerts() {
111         return this.trustAllCerts;
112     }
113     
114     /**
115      * Gets proxy host or null if proxy host has not been set.
116      *
117      * @return proxy host
118      */
119     public String getProxyHost() {
120         return this.proxyHost;
121     }
122
123     /**
124      * Gets proxy port or -1 if no proxy port has been set.
125      *
126      * @return proxy port
127      */
128     public int getProxyPort() {
129         return this.proxyPort;
130     }
131 }