public VaultInteraction(VaultSession vaultSession) {
this.vaultNISession = vaultSession;
}
public void start() {
Console console = System.console();
if (console == null) {
System.err.println(SecurityLogger.ROOT_LOGGER.noConsole());
System.exit(1);
}
Scanner in = new Scanner(System.in);
while (true) {
String commandStr = SecurityLogger.ROOT_LOGGER.interactionCommandOptions();
System.out.println(commandStr);
int choice = in.nextInt();
switch (choice) {
case 0:
System.out.println(SecurityLogger.ROOT_LOGGER.taskStoreSecuredAttribute());
char[] attributeValue = VaultInteractiveSession.getSensitiveValue(SecurityLogger.ROOT_LOGGER.interactivePromptSecureAttributeValue(), SecurityLogger.ROOT_LOGGER.interactivePromptSecureAttributeValueAgain());
String vaultBlock = null;
while (vaultBlock == null || vaultBlock.length() == 0) {
vaultBlock = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptVaultBlock());
}
String attributeName = null;
while (attributeName == null || attributeName.length() == 0) {
attributeName = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptAttributeName());
}
try {
vaultNISession.addSecuredAttributeWithDisplay(vaultBlock, attributeName, attributeValue);
} catch (Exception e) {
System.out.println(SecurityLogger.ROOT_LOGGER.problemOcurred() + "\n" + e.getLocalizedMessage());
}
break;
case 1:
System.out.println(SecurityLogger.ROOT_LOGGER.taskVerifySecuredAttributeExists());
try {
vaultBlock = null;
while (vaultBlock == null || vaultBlock.length() == 0) {
vaultBlock = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptVaultBlock());
}
attributeName = null;
while (attributeName == null || attributeName.length() == 0) {
attributeName = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptAttributeName());
}
if (!vaultNISession.checkSecuredAttribute(vaultBlock, attributeName)) {
System.out.println(SecurityLogger.ROOT_LOGGER.interactiveMessageNoValueStored(VaultSession
.blockAttributeDisplayFormat(vaultBlock, attributeName)));
} else {
System.out.println(SecurityLogger.ROOT_LOGGER.interactiveMessageValueStored(VaultSession
.blockAttributeDisplayFormat(vaultBlock, attributeName)));
}
} catch (Exception e) {
System.out.println(SecurityLogger.ROOT_LOGGER.problemOcurred() + "\n" + e.getLocalizedMessage());
}
break;
case 2:
System.out.println(SecurityLogger.ROOT_LOGGER.taskRemoveSecuredAttribute());
try {
vaultBlock = null;
while (vaultBlock == null || vaultBlock.length() == 0) {
vaultBlock = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptVaultBlock());
}
attributeName = null;
while (attributeName == null || attributeName.length() == 0) {
attributeName = console.readLine(SecurityLogger.ROOT_LOGGER.interactivePromptAttributeName());
}
if (!vaultNISession.removeSecuredAttribute(vaultBlock, attributeName)) {
System.out.println(SecurityLogger.ROOT_LOGGER.messageAttributeNotRemoved(VaultSession
.blockAttributeDisplayFormat(vaultBlock, attributeName)));
} else {