use of com.bluenimble.platform.cli.ToolStartupException in project serverless by bluenimble.
the class AbstractTool method startup.
@Override
public void startup(String[] args) throws ToolStartupException {
for (Command command : getCommands()) {
command.onStartup(this);
}
startTime = new Date();
writeln(Lang.BLANK);
printer.textLn(0, getDescription(), FColor.CYAN.name(), null);
writeln(Lang.BLANK);
writeln(Lang.BLANK);
printer.textLn(0, startTime.toString(), FColor.YELLOW.name(), null);
try {
prompt();
onReady();
prompt();
} catch (Throwable th) {
// IGNORE
}
addShutdownHook();
// signle run
if (args != null && args.length > 0) {
for (int i = 0; i < args.length; i++) {
try {
processCommand(args[i]);
} catch (IOException e) {
throw new ToolStartupException(e);
}
}
try {
processCommand("quit");
} catch (IOException e) {
throw new ToolStartupException(e);
}
return;
}
}
use of com.bluenimble.platform.cli.ToolStartupException in project serverless by bluenimble.
the class BlueNimble method loadKeys.
private static String loadKeys(Tool tool, File s, String currentSecret) throws ToolStartupException {
String sname = s.getName().substring(0, s.getName().lastIndexOf(Lang.DOT)).toLowerCase();
InputStream in = null;
try {
in = new FileInputStream(s);
Keys keys = new Keys(sname, Json.load(new ByteArrayInputStream(Base64.decodeBase64(IOUtils.toString(in))), tool.getParaphrase(true)));
KeysMap.put(sname, keys);
if (sname.equals(currentSecret)) {
useKeys(sname);
}
} catch (Exception e) {
tool.printer().error("Can't load keys " + s.getName() + ". Cause: " + e.getMessage());
} finally {
IOUtils.closeQuietly(in);
}
return sname;
}
use of com.bluenimble.platform.cli.ToolStartupException in project serverless by bluenimble.
the class BlueNimble method loadKeys.
public static void loadKeys(Tool tool) throws ToolStartupException {
File keysFolder = keysFolder();
if (!keysFolder.exists()) {
keysFolder.mkdirs();
}
if (!keysFolder.isDirectory()) {
throw new ToolStartupException(keysFolder.getAbsolutePath() + " isn't valid forder to store bluenimble keys");
}
String sCurrentKeys = Json.getString(Config, CliSpec.Config.CurrentKeys);
File[] keys = keysFolder.listFiles(new FileFilter() {
@Override
public boolean accept(File f) {
return f.isFile() && f.getName().endsWith(CliSpec.KeysExt);
}
});
if (keys == null || keys.length == 0) {
Config.remove(CliSpec.Config.CurrentKeys);
return;
}
for (File s : keys) {
loadKeys(tool, s, sCurrentKeys);
}
}
Aggregations