2 * ============LICENSE_START=======================================================
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
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=========================================================
21 package org.openecomp.mso.rest;
24 * Configuration values to be used by the RESTClient.
29 public class RESTConfig {
30 private final String URL;
32 private final boolean trustAllCerts;
33 private final String proxyHost;
34 private final int proxyPort;
37 * Creates a RESTConfig with the specified URL.
39 * By default, no proxy will be used, and only valid certificates will
42 * @param URL url to set
44 public RESTConfig(final String URL) {
45 this(URL, null, -1, false);
49 * Creates a RESTConfig with the specified URL and whether to trust all
52 * Trusting all certificates is useful for testing self-signed
53 * certificates. By default, no proxy will be used.
55 * @param URL url to set
56 * @param trustAllCerts whether to trust all certificates
58 public RESTConfig(final String URL, final boolean trustAllCerts) {
59 this(URL, null, -1, trustAllCerts);
63 * Creates a RESTConfig with the specified URL and proxy.
65 * By default, only valid certificates will be allowed.
67 * @param URL url to set
68 * @param proxyHost proxy host to set
69 * @param proxyPort proxy port to set
71 public RESTConfig(final String URL, final String proxyHost,
72 final int proxyPort) {
74 this(URL, proxyHost, proxyPort, false);
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.
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
87 public RESTConfig(final String URL, final String proxyHost,
88 final int proxyPort, boolean trustAllCerts) {
91 this.proxyHost = proxyHost;
92 this.proxyPort = proxyPort;
93 this.trustAllCerts = trustAllCerts;
97 * Gets the URL to use.
101 public String getURL() {
106 * Gets whether to trust all certificates.
108 * @return true if to trust all certificates, false otherwise
110 public boolean trustAllCerts() {
111 return this.trustAllCerts;
115 * Gets proxy host or null if proxy host has not been set.
119 public String getProxyHost() {
120 return this.proxyHost;
124 * Gets proxy port or -1 if no proxy port has been set.
128 public int getProxyPort() {
129 return this.proxyPort;