From 1c6b5fa580c9b82e17b710dbc4cf9bbce57eb5bc Mon Sep 17 00:00:00 2001 From: dglFromAtt Date: Thu, 19 Apr 2018 18:06:04 -0400 Subject: Fix cluster object to use http port Change-Id: I8cf3f4caf4701be7fd95bb35f94f75592d7b4c05 Signed-off-by: dglFromAtt Issue-ID: DMAAP-295 --- .../onap/dmaap/dbcapi/client/MrProvConnection.java | 42 ++++++++++---------- .../dmaap/dbcapi/client/MrTopicConnection.java | 9 +++-- .../org/onap/dmaap/dbcapi/model/MR_Cluster.java | 45 +++++++--------------- 3 files changed, 39 insertions(+), 57 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java index a8ace78..4db6ca3 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java +++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java @@ -54,37 +54,31 @@ public class MrProvConnection extends BaseLoggingClass{ private String topicMgrCred; + private boolean useAAF; + private String user; + private String encPwd; - private String getCred( ) { + public MrProvConnection() { String mechIdProperty = "aaf.TopicMgrUser"; String pwdProperty = "aaf.TopicMgrPassword"; DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig(); - logger.info( "templog:getCred: 10"); + user = p.getProperty( mechIdProperty, "noMechId@domain.netset.com" ); + encPwd = p.getProperty( pwdProperty, "notSet" ); + useAAF= "true".equalsIgnoreCase(p.getProperty("UseAAF", "false")); + topicMgrCred = getCred(); + + } + + private String getCred( ) { - String user = p.getProperty( mechIdProperty, "noMechId@domain.netset.com" ); - logger.info( "templog:getCred: 20"); String pwd = ""; - String encPwd = p.getProperty( pwdProperty, "notSet" ); - logger.info( "templog:getCred: 30"); - - AafDecrypt decryptor = new AafDecrypt(); - logger.info( "templog:getCred: 40"); + AafDecrypt decryptor = new AafDecrypt(); pwd = decryptor.decrypt(encPwd); - logger.info( "templog:getCred: 50"); - - return user + ":" + pwd; - - - + return user + ":" + pwd; } - public MrProvConnection( ) { - topicMgrCred = getCred(); - - } - public boolean makeTopicConnection( MR_Cluster cluster ) { logger.info( "connect to cluster: " + cluster.getDcaeLocationName()); @@ -162,8 +156,12 @@ public class MrProvConnection extends BaseLoggingClass{ try { byte[] postData = postTopic.getBytes(); logger.info( "post fields=" + postData.toString() ); - uc.setRequestProperty("Authorization", auth); - logger.info( "Authenticating with " + auth ); + + // when not using AAF, do not attempt Basic Authentication + if ( useAAF ) { + uc.setRequestProperty("Authorization", auth); + logger.info( "Authenticating with " + auth ); + } uc.setRequestMethod("POST"); uc.setRequestProperty("Content-Type", "application/json"); uc.setRequestProperty( "charset", "utf-8"); diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java index e1ea955..18fdeba 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java +++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java @@ -47,13 +47,14 @@ public class MrTopicConnection extends BaseLoggingClass { private String mmProvCred; private String unit_test; - + private boolean useAAF; public MrTopicConnection(String user, String pwd ) { mmProvCred = new String( user + ":" + pwd ); DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig(); unit_test = p.getProperty( "UnitTest", "No" ); + useAAF= "true".equalsIgnoreCase(p.getProperty("UseAAF", "false")); } public boolean makeTopicConnection( MR_Cluster cluster, String topic, String overrideFqdn ) { @@ -126,8 +127,10 @@ public class MrTopicConnection extends BaseLoggingClass { try { byte[] postData = postMessage.getBytes(); logger.info( "post fields=" + postMessage ); - uc.setRequestProperty("Authorization", auth); - logger.info( "Authenticating with " + auth ); + if ( useAAF ) { + uc.setRequestProperty("Authorization", auth); + logger.info( "Authenticating with " + auth ); + } uc.setRequestMethod("POST"); uc.setRequestProperty("Content-Type", "application/json"); uc.setRequestProperty( "charset", "utf-8"); diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java index 8185083..a6827a9 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java +++ b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java @@ -31,7 +31,6 @@ public class MR_Cluster extends DmaapObject { private String dcaeLocationName; private String fqdn; - private String[] hosts; private DmaapTimestamp lastMod; private String topicProtocol; private String topicPort; @@ -47,7 +46,6 @@ public class MR_Cluster extends DmaapObject { public MR_Cluster() { this.topicProtocol = defaultTopicProtocol; this.topicPort = defaultTopicPort; - this.hosts = new String[3]; this.lastMod = new DmaapTimestamp(); this.lastMod.mark(); @@ -55,24 +53,7 @@ public class MR_Cluster extends DmaapObject { } - // Deprecate this constructor - public MR_Cluster( String dLN, - String f, - String a, - String[] h ) { - this.dcaeLocationName = dLN; - this.fqdn = f; - this.hosts = new String[3]; - this.hosts[0] = h[0]; - this.hosts[1] = h[1]; - this.hosts[2] = h[2]; - this.topicProtocol = defaultTopicProtocol; - this.topicPort = defaultTopicPort; - this.lastMod = new DmaapTimestamp(); - this.lastMod.mark(); - debugLogger.debug( "depracated MR_Cluster constructor w initialization complete" + this.lastMod.getVal() ); - } // new style constructor public MR_Cluster( String dLN, @@ -81,12 +62,19 @@ public class MR_Cluster extends DmaapObject { String port ) { this.dcaeLocationName = dLN; this.fqdn = f; - this.hosts = new String[3]; - this.hosts[0] = fqdn; - this.hosts[1] = fqdn; - this.hosts[2] = fqdn; - this.topicProtocol = prot; - this.topicPort = port; + + if ( prot == null || prot.isEmpty() ) { + this.topicProtocol = defaultTopicProtocol; + } else { + this.topicProtocol = prot; + } + if ( port == null || port.isEmpty() ) { + this.topicPort = defaultTopicPort; + } else { + this.topicPort = port; + } + + this.lastMod = new DmaapTimestamp(); this.lastMod.mark(); @@ -108,13 +96,6 @@ public class MR_Cluster extends DmaapObject { this.fqdn = fqdn; } - public String[] getHosts() { - return hosts; - } - - public void setHosts(String[] hosts) { - this.hosts = hosts; - } public String getTopicProtocol() { return topicProtocol; -- cgit 1.2.3-korg