/**
- * ============LICENSE_START==========================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
- * ===================================================================
+ * ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
+ * Copyright © 2017-2018 European Software Marketing Ltd.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END============================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.modelloader.restclient;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.client.RestClient;
import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
* Wrapper around the standard A&AI Rest Client interface. This currently uses Jersey client 1.x
*
*/
+@Component
public class AaiRestClient {
public static final String HEADER_TRANS_ID = "X-TransactionId";
public OperationResult getAndDeleteResource(String url, String transId) {
// First, GET the model
OperationResult getResponse = getResource(url, transId, MediaType.APPLICATION_XML_TYPE);
- if ((getResponse == null) || (getResponse.getResultCode() != Response.Status.OK.getStatusCode())) {
+ if (getResponse == null || getResponse.getResultCode() != Response.Status.OK.getStatusCode()) {
return getResponse;
}
public boolean useBasicAuth() {
- return (config.getAaiAuthenticationUser() != null) && (config.getAaiAuthenticationPassword() != null);
+ return config.getAaiAuthenticationUser() != null && config.getAaiAuthenticationPassword() != null;
}
private RestClient setupClient() {
RestClient restClient = new RestClient();
-
- // @formatter:off
restClient.validateServerHostname(false)
.validateServerCertChain(false)
+ .connectTimeoutMs(config.getClientConnectTimeoutMs())
+ .readTimeoutMs(config.getClientReadTimeoutMs());
+
+ //Use certs only if SSL is enabled
+ if (config.useHttpsWithAAI())
+ {// @formatter:off
+ restClient
.clientCertFile(config.getAaiKeyStorePath())
.clientCertPassword(config.getAaiKeyStorePassword());
- // @formatter:on
+ // @formatter:on
+ }
if (useBasicAuth()) {
restClient.authenticationMode(RestAuthenticationMode.SSL_BASIC);