HADOOP-11455. KMS and Credential CLI should request confirmation for deletion by default. (Charles Lamb via yliu)
This commit is contained in:
parent
ddc5be48fc
commit
21c6f01831
@ -452,6 +452,9 @@ Release 2.7.0 - UNRELEASED
|
|||||||
HADOOP-11399. Java Configuration file and .xml files should be
|
HADOOP-11399. Java Configuration file and .xml files should be
|
||||||
automatically cross-compared (rchiang via rkanter)
|
automatically cross-compared (rchiang via rkanter)
|
||||||
|
|
||||||
|
HADOOP-11455. KMS and Credential CLI should request confirmation for
|
||||||
|
deletion by default. (Charles Lamb via yliu)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-11323. WritableComparator#compare keeps reference to byte array.
|
HADOOP-11323. WritableComparator#compare keeps reference to byte array.
|
||||||
|
@ -47,7 +47,7 @@ public class KeyShell extends Configured implements Tool {
|
|||||||
" [" + ListCommand.USAGE + "]\n";
|
" [" + ListCommand.USAGE + "]\n";
|
||||||
private static final String LIST_METADATA = "keyShell.list.metadata";
|
private static final String LIST_METADATA = "keyShell.list.metadata";
|
||||||
|
|
||||||
private boolean interactive = false;
|
private boolean interactive = true;
|
||||||
private Command command = null;
|
private Command command = null;
|
||||||
|
|
||||||
/** allows stdout to be captured if necessary */
|
/** allows stdout to be captured if necessary */
|
||||||
@ -169,8 +169,8 @@ public class KeyShell extends Configured implements Tool {
|
|||||||
getConf().set(KeyProviderFactory.KEY_PROVIDER_PATH, args[++i]);
|
getConf().set(KeyProviderFactory.KEY_PROVIDER_PATH, args[++i]);
|
||||||
} else if ("-metadata".equals(args[i])) {
|
} else if ("-metadata".equals(args[i])) {
|
||||||
getConf().setBoolean(LIST_METADATA, true);
|
getConf().setBoolean(LIST_METADATA, true);
|
||||||
} else if ("-i".equals(args[i]) || ("-interactive".equals(args[i]))) {
|
} else if ("-f".equals(args[i]) || ("-force".equals(args[i]))) {
|
||||||
interactive = true;
|
interactive = false;
|
||||||
} else if ("-help".equals(args[i])) {
|
} else if ("-help".equals(args[i])) {
|
||||||
printKeyShellUsage();
|
printKeyShellUsage();
|
||||||
return 1;
|
return 1;
|
||||||
@ -367,11 +367,13 @@ public class KeyShell extends Configured implements Tool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class DeleteCommand extends Command {
|
private class DeleteCommand extends Command {
|
||||||
public static final String USAGE = "delete <keyname> [-provider <provider>] [-help]";
|
public static final String USAGE =
|
||||||
|
"delete <keyname> [-provider <provider>] [-f] [-help]";
|
||||||
public static final String DESC =
|
public static final String DESC =
|
||||||
"The delete subcommand deletes all versions of the key\n" +
|
"The delete subcommand deletes all versions of the key\n" +
|
||||||
"specified by the <keyname> argument from within the\n" +
|
"specified by the <keyname> argument from within the\n" +
|
||||||
"provider specified -provider.";
|
"provider specified -provider. The command asks for\n" +
|
||||||
|
"user confirmation unless -f is specified.";
|
||||||
|
|
||||||
String keyName = null;
|
String keyName = null;
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
@ -397,10 +399,10 @@ public class KeyShell extends Configured implements Tool {
|
|||||||
try {
|
try {
|
||||||
cont = ToolRunner
|
cont = ToolRunner
|
||||||
.confirmPrompt("You are about to DELETE all versions of "
|
.confirmPrompt("You are about to DELETE all versions of "
|
||||||
+ " key: " + keyName + " from KeyProvider "
|
+ " key " + keyName + " from KeyProvider "
|
||||||
+ provider + ". Continue?:");
|
+ provider + ". Continue? ");
|
||||||
if (!cont) {
|
if (!cont) {
|
||||||
out.println("Nothing has been be deleted.");
|
out.println(keyName + " has not been deleted.");
|
||||||
}
|
}
|
||||||
return cont;
|
return cont;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -44,7 +44,7 @@ public class CredentialShell extends Configured implements Tool {
|
|||||||
" [" + DeleteCommand.USAGE + "]\n" +
|
" [" + DeleteCommand.USAGE + "]\n" +
|
||||||
" [" + ListCommand.USAGE + "]\n";
|
" [" + ListCommand.USAGE + "]\n";
|
||||||
|
|
||||||
private boolean interactive = false;
|
private boolean interactive = true;
|
||||||
private Command command = null;
|
private Command command = null;
|
||||||
|
|
||||||
/** allows stdout to be captured if necessary */
|
/** allows stdout to be captured if necessary */
|
||||||
@ -116,8 +116,8 @@ public class CredentialShell extends Configured implements Tool {
|
|||||||
userSuppliedProvider = true;
|
userSuppliedProvider = true;
|
||||||
getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
|
getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
|
||||||
args[++i]);
|
args[++i]);
|
||||||
} else if (args[i].equals("-i") || (args[i].equals("-interactive"))) {
|
} else if (args[i].equals("-f") || (args[i].equals("-force"))) {
|
||||||
interactive = true;
|
interactive = false;
|
||||||
} else if (args[i].equals("-v") || (args[i].equals("-value"))) {
|
} else if (args[i].equals("-v") || (args[i].equals("-value"))) {
|
||||||
value = args[++i];
|
value = args[++i];
|
||||||
} else if (args[i].equals("-help")) {
|
} else if (args[i].equals("-help")) {
|
||||||
@ -236,11 +236,13 @@ public class CredentialShell extends Configured implements Tool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class DeleteCommand extends Command {
|
private class DeleteCommand extends Command {
|
||||||
public static final String USAGE = "delete <alias> [-provider] [-help]";
|
public static final String USAGE =
|
||||||
|
"delete <alias> [-provider] [-f] [-help]";
|
||||||
public static final String DESC =
|
public static final String DESC =
|
||||||
"The delete subcommand deletes the credenital\n" +
|
"The delete subcommand deletes the credential\n" +
|
||||||
"specified as the <alias> argument from within the provider\n" +
|
"specified as the <alias> argument from within the provider\n" +
|
||||||
"indicated through the -provider argument";
|
"indicated through the -provider argument. The command asks for\n" +
|
||||||
|
"confirmation unless the -f option is specified.";
|
||||||
|
|
||||||
String alias = null;
|
String alias = null;
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
@ -267,9 +269,9 @@ public class CredentialShell extends Configured implements Tool {
|
|||||||
if (interactive) {
|
if (interactive) {
|
||||||
try {
|
try {
|
||||||
cont = ToolRunner
|
cont = ToolRunner
|
||||||
.confirmPrompt("You are about to DELETE the credential: " +
|
.confirmPrompt("You are about to DELETE the credential " +
|
||||||
alias + " from CredentialProvider " + provider.toString() +
|
alias + " from CredentialProvider " + provider.toString() +
|
||||||
". Continue?:");
|
". Continue? ");
|
||||||
if (!cont) {
|
if (!cont) {
|
||||||
out.println("Nothing has been deleted.");
|
out.println("Nothing has been deleted.");
|
||||||
}
|
}
|
||||||
@ -293,7 +295,7 @@ public class CredentialShell extends Configured implements Tool {
|
|||||||
provider.flush();
|
provider.flush();
|
||||||
printProviderWritten();
|
printProviderWritten();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
out.println(alias + "has NOT been deleted.");
|
out.println(alias + " has NOT been deleted.");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ public class TestKeyShell {
|
|||||||
private void deleteKey(KeyShell ks, String keyName) throws Exception {
|
private void deleteKey(KeyShell ks, String keyName) throws Exception {
|
||||||
int rc;
|
int rc;
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
final String[] delArgs = {"delete", keyName, "-provider", jceksProvider};
|
final String[] delArgs =
|
||||||
|
{"delete", keyName, "-f", "-provider", jceksProvider};
|
||||||
rc = ks.run(delArgs);
|
rc = ks.run(delArgs);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
assertTrue(outContent.toString().contains(keyName + " has been " +
|
assertTrue(outContent.toString().contains(keyName + " has been " +
|
||||||
|
@ -47,6 +47,7 @@ public class TestCredShell {
|
|||||||
System.setOut(new PrintStream(outContent));
|
System.setOut(new PrintStream(outContent));
|
||||||
System.setErr(new PrintStream(errContent));
|
System.setErr(new PrintStream(errContent));
|
||||||
final Path jksPath = new Path(tmpDir.toString(), "keystore.jceks");
|
final Path jksPath = new Path(tmpDir.toString(), "keystore.jceks");
|
||||||
|
new File(jksPath.toString()).delete();
|
||||||
jceksProvider = "jceks://file" + jksPath.toUri();
|
jceksProvider = "jceks://file" + jksPath.toUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class TestCredShell {
|
|||||||
assertTrue(outContent.toString().contains("credential1"));
|
assertTrue(outContent.toString().contains("credential1"));
|
||||||
|
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
String[] args4 = {"delete", "credential1", "-provider",
|
String[] args4 = {"delete", "credential1", "-f", "-provider",
|
||||||
jceksProvider};
|
jceksProvider};
|
||||||
rc = cs.run(args4);
|
rc = cs.run(args4);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
@ -113,7 +114,7 @@ public class TestCredShell {
|
|||||||
assertTrue(outContent.toString().contains("WARNING: you are modifying a " +
|
assertTrue(outContent.toString().contains("WARNING: you are modifying a " +
|
||||||
"transient provider."));
|
"transient provider."));
|
||||||
|
|
||||||
String[] args2 = {"delete", "credential1", "-provider", "user:///"};
|
String[] args2 = {"delete", "credential1", "-f", "-provider", "user:///"};
|
||||||
rc = cs.run(args2);
|
rc = cs.run(args2);
|
||||||
assertEquals(outContent.toString(), 0, rc);
|
assertEquals(outContent.toString(), 0, rc);
|
||||||
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
||||||
@ -167,7 +168,7 @@ public class TestCredShell {
|
|||||||
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
||||||
"created."));
|
"created."));
|
||||||
|
|
||||||
String[] args2 = {"delete", "credential1", "-provider",
|
String[] args2 = {"delete", "credential1", "-f", "-provider",
|
||||||
jceksProvider};
|
jceksProvider};
|
||||||
rc = shell.run(args2);
|
rc = shell.run(args2);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user