Commit e932d736 authored by Abmar Barros's avatar Abmar Barros
Browse files

normalizing tokens

parent 048ec83f
...@@ -28,7 +28,7 @@ public class FogbowClient { ...@@ -28,7 +28,7 @@ public class FogbowClient {
public FogbowClient(String managerHost, Integer managerPort, String federationAuthToken) { public FogbowClient(String managerHost, Integer managerPort, String federationAuthToken) {
this.managerHost = managerHost; this.managerHost = managerHost;
this.managerPort = managerPort; this.managerPort = managerPort;
this.federationAuthToken = federationAuthToken; this.federationAuthToken = normalizeToken(federationAuthToken);
this.httpWrapper = new HttpWrapper(); this.httpWrapper = new HttpWrapper();
} }
...@@ -36,6 +36,13 @@ public class FogbowClient { ...@@ -36,6 +36,13 @@ public class FogbowClient {
return managerHost + ":" + managerPort; return managerHost + ":" + managerPort;
} }
private static String normalizeToken(String token) {
if (token == null) {
return null;
}
return token.replace("\n", "");
}
public String createRequest(int minCPU, int minRAM, public String createRequest(int minCPU, int minRAM,
String imageName, String pubKeyFilePath, String localAuthToken) throws Exception { String imageName, String pubKeyFilePath, String localAuthToken) throws Exception {
return createRequests(1, true, null, "Glue2vCPU >= " + minCPU + " Glue2RAM >= " + minRAM, return createRequests(1, true, null, "Glue2vCPU >= " + minCPU + " Glue2RAM >= " + minRAM,
...@@ -94,7 +101,11 @@ public class FogbowClient { ...@@ -94,7 +101,11 @@ public class FogbowClient {
RequestAttribute.DATA_PUBLIC_KEY.getValue() + "=" + pubKey)); RequestAttribute.DATA_PUBLIC_KEY.getValue() + "=" + pubKey));
} }
headers.add(new BasicHeader(OCCIHeaders.X_LOCAL_AUTH_TOKEN, localAuthToken)); if (localAuthToken != null) {
headers.add(new BasicHeader(OCCIHeaders.X_LOCAL_AUTH_TOKEN,
normalizeToken(localAuthToken)));
}
String response = httpWrapper.doRequest("post", String response = httpWrapper.doRequest("post",
getManagerURL() + "/" + RequestConstants.TERM, getManagerURL() + "/" + RequestConstants.TERM,
......
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 to comment