-
- private String provURL;
-
- private HttpURLConnection uc;
-
-
- private String topicMgrCred;
- private boolean useAAF;
- private String user;
- private String encPwd;
-
- public MrProvConnection() {
- String mechIdProperty = "aaf.TopicMgrUser";
- String pwdProperty = "aaf.TopicMgrPassword";
- DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
- 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 pwd = "";
- AafDecrypt decryptor = new AafDecrypt();
- pwd = decryptor.decrypt(encPwd);
- return user + ":" + pwd;
- }
-
-
- public boolean makeTopicConnection( MR_Cluster cluster ) {
- logger.info( "connect to cluster: " + cluster.getDcaeLocationName());
-
-
- provURL = cluster.getTopicProtocol() + "://" + cluster.getFqdn() + ":" + cluster.getTopicPort() + "/topics/create";
-
- if ( cluster.getTopicProtocol().equals( "https" ) ) {
- return makeSecureConnection( provURL );
- }
- return makeConnection( provURL );
- }
-
- private boolean makeSecureConnection( String pURL ) {
- logger.info( "makeConnection to " + pURL );
-
- try {
- URL u = new URL( pURL );
- uc = (HttpsURLConnection) u.openConnection();
- uc.setInstanceFollowRedirects(false);
- logger.info( "open connect to " + pURL );
- return(true);
- } catch( UnknownHostException uhe ){
- logger.error( "Caught UnknownHostException for " + pURL);
- return(false);
+
+ private String provURL;
+
+ private HttpURLConnection uc;
+
+
+ private String topicMgrCred;
+ private String authMethod;
+ private String user;
+ private String encPwd;
+ private String unit_test;
+ private boolean hostnameVerify;
+
+ public MrProvConnection() {
+ String mechIdProperty = "aaf.TopicMgrUser";
+ String pwdProperty = "aaf.TopicMgrPassword";
+ DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
+ user = p.getProperty( mechIdProperty, "noMechId@domain.netset.com" );
+ encPwd = p.getProperty( pwdProperty, "notSet" );
+ authMethod = p.getProperty("MR.authentication", "none");
+ topicMgrCred = getCred();
+ hostnameVerify= "true".equalsIgnoreCase(p.getProperty("MR.hostnameVerify", "true"));
+ unit_test = p.getProperty( "UnitTest", "No" );
+
+ }
+
+ private String getCred( ) {
+
+
+ String pwd = "";
+ AafDecrypt decryptor = new AafDecrypt();
+ pwd = decryptor.decrypt(encPwd);
+ return user + ":" + pwd;
+ }
+
+
+ public boolean makeTopicConnection( MR_Cluster cluster ) {
+ boolean rc = false;
+ logger.info( "connect to cluster: " + cluster.getDcaeLocationName());
+
+
+ provURL = cluster.getTopicProtocol() + "://" + cluster.getFqdn() + ":" + cluster.getTopicPort() + "/topics/create";
+
+ if ( cluster.getTopicProtocol().equals( "https" ) ) {
+ rc = makeSecureConnection( provURL );
+ } else {
+ rc = makeConnection( provURL );
+ }
+ if ( rc && unit_test.equals( "Yes" ) ) {
+ // set timeouts low so we don't hold up unit tests in build process
+ uc.setReadTimeout(5);
+ uc.setConnectTimeout(5);
+ }
+ return rc;
+
+ }
+
+ private boolean makeSecureConnection( String pURL ) {
+ logger.info( "makeConnection to " + pURL );
+
+ try {
+
+ HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify( String hostname, SSLSession session ) {
+ return true;
+ }
+
+ };
+ URL u = new URL( pURL );
+ uc = (HttpsURLConnection) u.openConnection();
+ uc.setInstanceFollowRedirects(false);
+ if ( ! hostnameVerify ) {
+ HttpsURLConnection ucs = (HttpsURLConnection) uc;
+ ucs.setHostnameVerifier(hostnameVerifier);
+ }
+ logger.info( "open secure connect to " + pURL );
+ return(true);
+ } catch( UnknownHostException uhe ){
+ logger.error( "Caught UnknownHostException for " + pURL);
+ return(false);