import java.net.ProtocolException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection;
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());
try {
byte[] postData = postTopic.getBytes();
- logger.info( "post fields=" + postData.toString() );
- uc.setRequestProperty("Authorization", auth);
- logger.info( "Authenticating with " + auth );
+ logger.info( "post fields=" + Arrays.toString(postData));
+
+ // 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");