Commit 369764b8 by Adi Amir

bugfix: cisco password trunked while reading from environment

parent 6a7e8284
......@@ -3,7 +3,7 @@ mde:
IPG_ENV_PARAMS: "-Dds.IpAddress=172.16.1.151:8012#\
-Dredis.host=172.16.1.151#\
-Dmde.cisco.username=devoperator11@cdp.com#\
-Dmde.cisco.password=z9E+H=9$J#\
-Dmde.cisco.password=ejlFK0g9OSRK#\
-Dmde.cisco.clientId=a27b18484c3c4e08a7c193e42c639347#\
-Dmde.cisco.clientSecret=b863de8f453c4a05A88126F45B958CF1"
USE_DEBUG: "yes"
......
......@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.gdata.util.common.base.PercentEscaper;
import com.google.gdata.util.common.util.Base64;
import http.simpleHttpClient.SimpleHttpClient;
import http.simpleHttpClient.SimpleHttpRequest;
import http.simpleHttpClient.SimpleHttpResponse;
......@@ -26,6 +27,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
......@@ -76,10 +78,24 @@ public class CiscoManager {
}
private void LoadLoginInfo() {
loginInfo.username = System.getProperty("mde.cisco.username", "");
loginInfo.password = System.getProperty("mde.cisco.password", "");
loginInfo.clientId = System.getProperty("mde.cisco.clientId", "");
loginInfo.clientSecret = System.getProperty("mde.cisco.clientSecret", "");
loginInfo.username = getConfigParam("mde.cisco.username", false, null);
loginInfo.password = getConfigParam("mde.cisco.password", true, null);
loginInfo.clientId = getConfigParam("mde.cisco.clientId", false, null);
loginInfo.clientSecret = getConfigParam("mde.cisco.clientSecret", false, null);
}
private String getConfigParam(String paramName, Boolean bEscaped, String defaultValue) {
try {
String paramValue = System.getProperty(paramName, defaultValue);
if (paramValue != null && bEscaped) {
paramValue = new String(Base64.decodeWebSafe(paramValue.getBytes()), Charset.forName("UTF-8"));
}
return paramValue;
} catch (Exception e) {
logger.error("getConfigParam() failed. paramName=" + paramName + " e: " + e.toString());
return null;
}
}
public BaseRestResponse executeRequest(String serviceId, String[] apiIdAsParams, RequestContext requestContext) {
......@@ -91,11 +107,11 @@ public class CiscoManager {
logger.info("cisco.executeRequest() started: " + getApiIdString(apiIdAsParams));
// login for the first time
//if (loginInfo.loginSuccessfull == false) {
if (loginInfo.loginSuccessfull == false) {
brr = login(loginInfo);
if (brr.success == false)
return brr;
//}
}
if (apiIdAsParams.length == 1 && apiIdAsParams[0].equals("traffic-lanes")) {
brr = getTrafficLanes();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment