private String value;
@Override
public void run() throws Failure {
final String username = getContext().getClient().getUsername();
IPublicKeyManager keyManager = getContext().getGitblit().getPublicKeyManager();
List<SshKey> keys = keyManager.getKeys(username);
if (index > keys.size()) {
throw new UnloggedFailure(1, "Invalid key index!");
}
SshKey key = keys.get(index - 1);
AccessPermission permission = AccessPermission.fromCode(value);
if (permission.exceeds(AccessPermission.NONE)) {
try {
key.setPermission(permission);
} catch (IllegalArgumentException e) {
throw new Failure(1, e.getMessage());
}
}
if (keyManager.addKey(username, key)) {
stdout.println(String.format("Updated the permission for key #%d.", index));
} else {
throw new Failure(1, String.format("Failed to update the comment for key #%d!", index));
}
}