2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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.onap.policy.common.endpoints.event.comm.bus.internal.impl;
23 import com.att.nsa.mr.client.impl.MRConsumerImpl;
24 import com.att.nsa.mr.test.clients.ProtocolTypeConstants;
26 import java.net.MalformedURLException;
27 import java.util.List;
28 import java.util.Properties;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
36 public class DmaapAafConsumerWrapper extends DmaapConsumerWrapper {
38 private static Logger logger = LoggerFactory.getLogger(DmaapAafConsumerWrapper.class);
40 private final Properties props;
45 * @param servers messaging bus hosts
47 * @param apiKey API Key
48 * @param apiSecret API Secret
49 * @param aafLogin AAF Login
50 * @param aafPassword AAF Password
51 * @param consumerGroup Consumer Group
52 * @param consumerInstance Consumer Instance
53 * @param fetchTimeout Fetch Timeout
54 * @param fetchLimit Fetch Limit
55 * @throws MalformedURLException
57 public DmaapAafConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret, String aafLogin,
58 String aafPassword, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit,
59 boolean useHttps) throws MalformedURLException {
61 super(servers, topic, apiKey, apiSecret, aafLogin, aafPassword, consumerGroup, consumerInstance, fetchTimeout,
64 // super constructor sets servers = {""} if empty to avoid errors when using DME2
65 if ((servers.size() == 1 && ("".equals(servers.get(0)))) || (servers == null) || (servers.isEmpty())) {
66 throw new IllegalArgumentException("Must provide at least one host for HTTP AAF");
69 this.consumer.setProtocolFlag(ProtocolTypeConstants.AAF_AUTH.getValue());
71 props = new Properties();
74 props.setProperty(PROTOCOL_PROP, "https");
75 this.consumer.setHost(servers.get(0) + ":3905");
78 props.setProperty(PROTOCOL_PROP, "http");
79 this.consumer.setHost(servers.get(0) + ":3904");
82 this.consumer.setProps(props);
83 logger.info("{}: CREATION", this);
87 public String toString() {
88 final MRConsumerImpl consumer = this.consumer;
90 return "DmaapConsumerWrapper [" + "consumer.getAuthDate()=" + consumer.getAuthDate()
91 + ", consumer.getAuthKey()=" + consumer.getAuthKey() + ", consumer.getHost()=" + consumer.getHost()
92 + ", consumer.getProtocolFlag()=" + consumer.getProtocolFlag() + ", consumer.getUsername()="
93 + consumer.getUsername() + "]";