Commit bdd3f5a5 authored by Spiros Koulouzis's avatar Spiros Koulouzis

moved data types to separate project

parent 1574a94b
...@@ -46,8 +46,6 @@ import provisioning.credential.EGICredential; ...@@ -46,8 +46,6 @@ import provisioning.credential.EGICredential;
*/ */
public class MessageParsing { public class MessageParsing {
private static ObjectMapper mapper;
public static List<File> getTopologies(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException { public static List<File> getTopologies(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException {
List<File> topologyFiles = new ArrayList<>(); List<File> topologyFiles = new ArrayList<>();
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
...@@ -117,10 +115,12 @@ public class MessageParsing { ...@@ -117,10 +115,12 @@ public class MessageParsing {
String name = (String) param.get("name"); String name = (String) param.get("name");
if (name.equals("cloud_credential")) { if (name.equals("cloud_credential")) {
Credential credential = null; Credential credential = null;
mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
String credentialString = (String) param.get("value"); String credentialString = (String) param.get("value");
credentialString = credentialString.substring(1, credentialString.length() - 2); System.err.println(credentialString);
credentialString = credentialString.substring(1, credentialString.length() - 1);
System.err.println(credentialString);
CloudCredentials cred = mapper.readValue(credentialString, CloudCredentials.class); CloudCredentials cred = mapper.readValue(credentialString, CloudCredentials.class);
if (cred.getCloudProviderName().toLowerCase().equals("ec2")) { if (cred.getCloudProviderName().toLowerCase().equals("ec2")) {
EC2Credential ec2 = new EC2Credential(); EC2Credential ec2 = new EC2Credential();
...@@ -136,12 +136,19 @@ public class MessageParsing { ...@@ -136,12 +136,19 @@ public class MessageParsing {
} }
for (KeyPair pair : cred.getKeyPairs()) { for (KeyPair pair : cred.getKeyPairs()) {
File dir = new File(tempInputDirPath + File.separator + pair.getId()); if (pair != null) {
dir.mkdir(); File dir = new File(tempInputDirPath + File.separator + pair.getId());
Key privateKey = pair.getPrivateKey(); dir.mkdir();
writeValueToFile(privateKey.getKey(), new File(dir.getAbsolutePath() + File.separator + privateKey.getName())); Key privateKey = pair.getPrivateKey();
Key publicKey = pair.getPublicKey(); if (privateKey != null) {
writeValueToFile(publicKey.getKey(), new File(dir.getAbsolutePath() + File.separator + publicKey.getName())); writeValueToFile(privateKey.getKey(), new File(dir.getAbsolutePath() + File.separator + privateKey.getName()));
}
Key publicKey = pair.getPublicKey();
if (publicKey != null) {
writeValueToFile(publicKey.getKey(), new File(dir.getAbsolutePath() + File.separator + publicKey.getName()));
}
}
} }
credentials.add(credential); credentials.add(credential);
} }
......
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