James Moger
2014-03-14 22957a70fb7ba8a38564d6b6be15c661da0c3a20
src/main/java/com/gitblit/transport/ssh/commands/DispatchCommand.java
@@ -93,6 +93,12 @@
      }
      Command cmd = getCommand();
      if (cmd.getClass().isAnnotationPresent(CommandMetaData.class)) {
         CommandMetaData meta = cmd.getClass().getAnnotation(CommandMetaData.class);
         if (meta.admin() && !ctx.getClient().getUser().canAdmin()) {
            throw new UnloggedFailure(1, MessageFormat.format("{0} requires admin permissions", commandName));
         }
      }
      if (cmd instanceof BaseCommand) {
        BaseCommand bc = (BaseCommand) cmd;
        if (getName().isEmpty()) {
@@ -160,9 +166,15 @@
    String format = "%-" + maxLength + "s   %s";
    for (String name : Sets.newTreeSet(m.keySet())) {
      final Class<? extends Command> c = m.get(name);
      usage.append("   ");
      CommandMetaData meta = c.getAnnotation(CommandMetaData.class);
      if (meta != null) {
        if (meta.admin() && !ctx.getClient().getUser().canAdmin()) {
           continue;
        }
        if (meta.hidden()) {
           continue;
        }
        usage.append("   ");
        usage.append(String.format(format, name,
            Strings.nullToEmpty(meta.description())));
      }
@@ -198,9 +210,9 @@
      d.setUploadPackFactory(gitblitUploadPackFactory);
      d.setReceivePackFactory(gitblitReceivePackFactory);
      d.setAuthenticator(authenticator);
     } else if (cmd instanceof SetAccountCommand) {
        SetAccountCommand setAccountCommand = (SetAccountCommand)cmd;
        setAccountCommand.setAuthenticator(authenticator);
     } else if (cmd instanceof BaseKeyCommand) {
        BaseKeyCommand k = (BaseKeyCommand)cmd;
        k.setAuthenticator(authenticator);
     }
  }