2 * ============LICENSE_START===================================================
3 * Copyright (c) 2018 Amdocs
4 * ============================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=====================================================
18 package org.onap.sdnc.apps.pomba.networkdiscovery;
20 import com.fasterxml.jackson.databind.ObjectMapper;
21 import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
22 import javax.ws.rs.client.Client;
23 import javax.ws.rs.client.ClientBuilder;
24 import org.glassfish.jersey.client.ClientConfig;
25 import org.glassfish.jersey.client.ClientProperties;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.beans.factory.annotation.Value;
28 import org.springframework.context.annotation.Bean;
29 import org.springframework.stereotype.Component;
32 public class CallbackConfiguration {
33 /** Use same object mapper as embedded tomcat server */
35 private ObjectMapper objectMapper;
37 @Value("${callback.keyStorePath:}")
38 private String keyStorePath;
40 @Value("${callback.keyStorePassword:}")
41 private String keyStorePassword;
43 @Value("${callback.connectionTimeout:5000}")
44 private int connectionTimeout;
46 @Value("${callback.readTimeout:60000}")
47 private int readTimeout;
49 @Value("${callback.username:}")
50 private String basicAuthUsername;
52 @Value("${callback.password:}")
53 private String basicAuthPassword;
55 @Bean(name="callbackClient")
56 public Client getClient() throws Exception {
57 ClientConfig configuration = new ClientConfig()
58 .property(ClientProperties.CONNECT_TIMEOUT, this.connectionTimeout)
59 .property(ClientProperties.READ_TIMEOUT, this.readTimeout)
60 .register(new JacksonJaxbJsonProvider(objectMapper, null));
62 // TODO set up SSL if configured
64 // setupSecureSocketLayerClientConfig(clientConfig);
66 // Finally, create and initialize our client...
67 Client client = ClientBuilder.newClient(configuration);
69 // ...and return it to the caller.