summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-08-04 15:49:44 +0530
committerSelvasundaram <selvam@gluster.com>2011-08-04 15:49:44 +0530
commit899c2623e4fe877c46c457f19f48524771551d9a (patch)
treec5de393442d78317c3be17b813034d561f9f2bee /src
parent8e8dcb7bbd179a8f50dfe04c5844b8f0fff931bb (diff)
Bug 3239 - Not able to export the keys properly - fix
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java
index 34dad497..648de3f6 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java
@@ -62,33 +62,33 @@ public class KeysResource extends AbstractResource {
}
private String createSskKeyZipFile() {
- String targetDir = System.getProperty("java.io.tmpdir");
- String zipFile = targetDir + "ssh-keys.tar";
- String sourcePemFile = SshUtil.PRIVATE_KEY_FILE.getAbsolutePath();
- String sourcePubKeyFile = SshUtil.PUBLIC_KEY_FILE.getAbsolutePath();
- String targetPemFile = targetDir + File.separator + SshUtil.PRIVATE_KEY_FILE.getName();
+ String targetDir = FileUtil.getTempDirName();
+ String zipFile = targetDir + File.separator + "ssh-keys.tar";
+ String sourcePrivateKeyFile = SshUtil.PRIVATE_KEY_FILE.getAbsolutePath();
+ String sourcePublicKeyFile = SshUtil.PUBLIC_KEY_FILE.getAbsolutePath();
+ String targetPrivateKeyFile = targetDir + File.separator + SshUtil.PRIVATE_KEY_FILE.getName();
String targetPubKeyFile = targetDir + File.separator + SshUtil.PUBLIC_KEY_FILE.getName();
if (!SshUtil.PRIVATE_KEY_FILE.isFile()) {
- throw new GlusterRuntimeException("No private key file [" + SshUtil.PRIVATE_KEY_FILE.getName() + "] found!" );
+ throw new GlusterRuntimeException("No private key file [" + SshUtil.PRIVATE_KEY_FILE.getName() + "] found!");
}
if (!SshUtil.PUBLIC_KEY_FILE.isFile()) {
- throw new GlusterRuntimeException("No public key file [" + SshUtil.PUBLIC_KEY_FILE.getName() + "] found!" );
+ throw new GlusterRuntimeException("No public key file [" + SshUtil.PUBLIC_KEY_FILE.getName() + "] found!");
}
// Copy keys to temp folder
- ProcessResult result = processUtil.executeCommand("cp", sourcePemFile, targetPemFile);
+ ProcessResult result = processUtil.executeCommand("cp", sourcePrivateKeyFile, targetPrivateKeyFile);
if (!result.isSuccess()) {
throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]");
}
- result = processUtil.executeCommand("cp", sourcePubKeyFile, targetPubKeyFile);
+ result = processUtil.executeCommand("cp", sourcePublicKeyFile, targetPubKeyFile);
if (!result.isSuccess()) {
throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]");
}
// To compress the key files
- result = processUtil.executeCommand("tar", "cvf", zipFile, "-C", "/tmp", SshUtil.PRIVATE_KEY_FILE.getName(),
+ result = processUtil.executeCommand("tar", "cvf", zipFile, "-C", targetDir, SshUtil.PRIVATE_KEY_FILE.getName(),
SshUtil.PUBLIC_KEY_FILE.getName());
if (!result.isSuccess()) {
throw new GlusterRuntimeException("Failed to compress key files! [" + result.getOutput() + "]");
@@ -96,7 +96,7 @@ public class KeysResource extends AbstractResource {
// To remove the copied key files
try {
- processUtil.executeCommand("rm", "-f", targetPemFile, targetPubKeyFile); // Ignore the errors if any
+ processUtil.executeCommand("rm", "-f", targetPrivateKeyFile, targetPubKeyFile); // Ignore the errors if any
} catch (Exception e) {
logger.warn(e.toString());
}
@@ -111,10 +111,10 @@ public class KeysResource extends AbstractResource {
writeToFile(uploadedInputStream, uploadedFile.getAbsolutePath());
- // To backup existing SSH pem and public keys, if exist.
+ // To backup existing SSH private and public keys, if exist.
if (SshUtil.PRIVATE_KEY_FILE.isFile()) {
if (!SshUtil.PRIVATE_KEY_FILE.renameTo(new File(SshUtil.PRIVATE_KEY_FILE.getAbsolutePath() + "-" + timestamp))) {
- throw new GlusterRuntimeException("Unable to backup pem key!");
+ throw new GlusterRuntimeException("Unable to backup private key!");
}
}
@@ -124,7 +124,7 @@ public class KeysResource extends AbstractResource {
throw new GlusterRuntimeException("Unable to backup public key!");
}
}
- // Extract SSH pem and public key files.
+ // Extract SSH private and public key files.
ProcessResult output = processUtil.executeCommand("tar", "xvf", uploadedFile.getName(), "-C",
SshUtil.SSH_AUTHORIZED_KEYS_DIR_LOCAL);
uploadedFile.delete();