String path = options.nonOptionArguments().get(1);
logger.debug(path);
OverEncryptClient client = new OverEncryptClient();
AuthenticationClient pinManagementClient = new AuthenticationClient();
PermissionsClient permissionsClient = new PermissionsClient();
Response resp = client.readResponse(path);
logger.debug("Response:\n===\n" + resp.toString() + "===");
if (resp.getPrimitive() == ServerPrimitives.OE_DHKEYPAIRS) {
exitWithError(1, "The user hasn't chosen a passphrase yet. "
+ "Use the '" + new GenerateKeysCommand().getKeyword()
+ "' command to choose one.");
}
String userId = resp.getValue("userId");
String passphrase = "";
if (options.has("p") || options.has("passphrase")) {
passphrase = (String) options.valueOf("p");
} else {
exitWithError(2, "No passphrase supplied. Please use " +
"the -p/--passphrase option to supply a valid passphrase.");
}
client.deleteResponse(path);
while (resp.getPrimitive() == ServerPrimitives.OE_AUTHENTICATION) {
resp = pinManagementClient.checkPin(path, userId, passphrase);
logger.debug("Response:\n===\n" + resp.toString() + "===");
}
if (resp.getPrimitive() == ServerPrimitives.OE_UPDATE_ALL_PERMS) {
permissionsClient.updateAllPermissions(resp.getValue("friends"),