| | |
| | | import com.gitblit.git.GitblitReceivePackFactory; |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.transport.ssh.AbstractGitCommand; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.SshKeyAuthenticator; |
| | | import com.gitblit.transport.ssh.PublicKeyAuthenticator; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | import com.gitblit.utils.cli.SubcommandHandler; |
| | | import com.google.common.base.Charsets; |
| | |
| | | } |
| | | |
| | | 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()) { |
| | |
| | | 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()))); |
| | | } |
| | |
| | | this.gitblitReceivePackFactory = gitblitReceivePackFactory; |
| | | } |
| | | |
| | | private SshKeyAuthenticator authenticator; |
| | | public void setAuthenticator(SshKeyAuthenticator authenticator) { |
| | | private PublicKeyAuthenticator authenticator; |
| | | public void setAuthenticator(PublicKeyAuthenticator authenticator) { |
| | | this.authenticator = authenticator; |
| | | } |
| | | } |