Create git and gitblit dispatchers
10 files renamed
1 files deleted
3 files added
2 files modified
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.git.GitblitReceivePackFactory; |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.commands.AddKeyCommand; |
| | | import com.gitblit.transport.ssh.commands.CreateRepository; |
| | | import com.gitblit.transport.ssh.commands.DispatchCommand; |
| | | import com.gitblit.transport.ssh.commands.ListRepositoriesCommand; |
| | | import com.gitblit.transport.ssh.commands.Receive; |
| | | import com.gitblit.transport.ssh.commands.RemoveKeyCommand; |
| | | import com.gitblit.transport.ssh.commands.ReviewCommand; |
| | | import com.gitblit.transport.ssh.commands.SetAccountCommand; |
| | | import com.gitblit.transport.ssh.commands.Upload; |
| | | import com.gitblit.transport.ssh.commands.VersionCommand; |
| | | import com.gitblit.transport.ssh.git.GitDispatchCommand; |
| | | import com.gitblit.transport.ssh.gitblit.GitblitDispatchCommand; |
| | | import com.gitblit.utils.IdGenerator; |
| | | import com.gitblit.utils.WorkQueue; |
| | | import com.google.common.util.concurrent.Atomics; |
| | |
| | | protected DispatchCommand createRootDispatcher(SshDaemonClient client, String cmdLine) { |
| | | final UserModel user = client.getUser(); |
| | | |
| | | DispatchCommand gitblitCmd = new DispatchCommand(); |
| | | gitblitCmd.registerCommand(user, VersionCommand.class); |
| | | gitblitCmd.registerCommand(user, AddKeyCommand.class); |
| | | gitblitCmd.registerCommand(user, RemoveKeyCommand.class); |
| | | gitblitCmd.registerCommand(user, ListRepositoriesCommand.class); |
| | | gitblitCmd.registerCommand(user, ReviewCommand.class); |
| | | |
| | | gitblitCmd.registerCommand(user, CreateRepository.class); |
| | | gitblitCmd.registerCommand(user, SetAccountCommand.class); |
| | | |
| | | DispatchCommand gitCmd = new DispatchCommand(); |
| | | gitCmd.registerCommand(user, Upload.class); |
| | | gitCmd.registerCommand(user, Receive.class); |
| | | |
| | | DispatchCommand root = new DispatchCommand(); |
| | | root.registerDispatcher("gitblit", gitblitCmd); |
| | | root.registerDispatcher("git", gitCmd); |
| | | |
| | | root.setRepositoryResolver(new RepositoryResolver<SshDaemonClient>(gitblit)); |
| | | root.setUploadPackFactory(new GitblitUploadPackFactory<SshDaemonClient>(gitblit)); |
| | | root.setReceivePackFactory(new GitblitReceivePackFactory<SshDaemonClient>(gitblit)); |
| | | root.setAuthenticator(keyAuthenticator); |
| | | |
| | | DispatchCommand root = new DispatchCommand() { |
| | | }; |
| | | root.setContext(new SshCommandContext(gitblit, client, cmdLine)); |
| | | |
| | | // TODO convert these dispatchers to plugin extension points |
| | | root.registerDispatcher(user, GitblitDispatchCommand.class); |
| | | root.registerDispatcher(user, GitDispatchCommand.class); |
| | | |
| | | root.setAuthenticator(keyAuthenticator); |
| | | |
| | | return root; |
| | | } |
| | | |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.git.GitblitReceivePackFactory; |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.CachingPublicKeyAuthenticator; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | mport com.gitblit.utils.StringUtils; |
| | | import com.gitblit.transport.ssh.gitblit.BaseKeyCommand; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.utils.cli.SubcommandHandler; |
| | | import com.google.common.base.Charsets; |
| | | import com.google.common.base.Strings; |
| | | import com.google.common.collect.Maps; |
| | | import com.google.common.collect.Sets; |
| | | |
| | | public class DispatchCommand extends BaseCommand { |
| | | public abstract class DispatchCommand extends BaseCommand { |
| | | |
| | | private Logger log = LoggerFactory.getLogger(getClass()); |
| | | |
| | |
| | | commands = new HashSet<Class<? extends BaseCommand>>(); |
| | | } |
| | | |
| | | public void registerDispatcher(String name, Command cmd) { |
| | | public void registerDispatcher(UserModel user, Class<? extends DispatchCommand> cmd) { |
| | | if (!cmd.isAnnotationPresent(CommandMetaData.class)) { |
| | | throw new RuntimeException(MessageFormat.format("{0} must be annotated with {1}!", cmd.getName(), |
| | | CommandMetaData.class.getName())); |
| | | } |
| | | if (dispatchers == null) { |
| | | dispatchers = Maps.newHashMap(); |
| | | } |
| | | dispatchers.put(name, cmd); |
| | | |
| | | CommandMetaData meta = cmd.getAnnotation(CommandMetaData.class); |
| | | if (meta.admin() && !user.canAdmin()) { |
| | | log.debug(MessageFormat.format("excluding admin dispatch command {0} for {1}", meta.name(), user.username)); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | DispatchCommand dispatcher = cmd.newInstance(); |
| | | dispatcher.registerCommands(user); |
| | | dispatchers.put(meta.name(), dispatcher); |
| | | } catch (Exception e) { |
| | | log.error("failed to register {} dispatcher", meta.name()); |
| | | } |
| | | } |
| | | |
| | | protected void registerCommands(UserModel user) { |
| | | } |
| | | |
| | | |
| | |
| | | cmd.setErrorStream(err); |
| | | cmd.setExitCallback(exit); |
| | | |
| | | if (cmd instanceof BaseGitCommand) { |
| | | BaseGitCommand a = (BaseGitCommand) cmd; |
| | | a.setRepositoryResolver(repositoryResolver); |
| | | a.setUploadPackFactory(gitblitUploadPackFactory); |
| | | a.setReceivePackFactory(gitblitReceivePackFactory); |
| | | } else if (cmd instanceof DispatchCommand) { |
| | | DispatchCommand d = (DispatchCommand) cmd; |
| | | d.setRepositoryResolver(repositoryResolver); |
| | | d.setUploadPackFactory(gitblitUploadPackFactory); |
| | | d.setReceivePackFactory(gitblitReceivePackFactory); |
| | | d.setAuthenticator(authenticator); |
| | | } else if (cmd instanceof BaseKeyCommand) { |
| | | if (cmd instanceof BaseKeyCommand) { |
| | | BaseKeyCommand k = (BaseKeyCommand) cmd; |
| | | k.setAuthenticator(authenticator); |
| | | } |
| | | } |
| | | |
| | | private RepositoryResolver<SshDaemonClient> repositoryResolver; |
| | | |
| | | public void setRepositoryResolver(RepositoryResolver<SshDaemonClient> repositoryResolver) { |
| | | this.repositoryResolver = repositoryResolver; |
| | | } |
| | | |
| | | private GitblitUploadPackFactory<SshDaemonClient> gitblitUploadPackFactory; |
| | | |
| | | public void setUploadPackFactory(GitblitUploadPackFactory<SshDaemonClient> gitblitUploadPackFactory) { |
| | | this.gitblitUploadPackFactory = gitblitUploadPackFactory; |
| | | } |
| | | |
| | | private GitblitReceivePackFactory<SshDaemonClient> gitblitReceivePackFactory; |
| | | |
| | | public void setReceivePackFactory(GitblitReceivePackFactory<SshDaemonClient> gitblitReceivePackFactory) { |
| | | this.gitblitReceivePackFactory = gitblitReceivePackFactory; |
| | | } |
| | | |
| | | private CachingPublicKeyAuthenticator authenticator; |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/BaseGitCommand.java |
| | |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.git; |
| | | |
| | | import java.io.IOException; |
| | | |
| | |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | import com.gitblit.transport.ssh.commands.BaseCommand; |
| | | |
| | | /** |
| | | * @author Eric Myhre |
| | | * |
| | | */ |
| | | public abstract class BaseGitCommand extends BaseCommand { |
| | | abstract class BaseGitCommand extends BaseCommand { |
| | | @Argument(index = 0, metaVar = "REPOSITORY", required = true, usage = "repository name") |
| | | protected String repository; |
| | | |
New file |
| | |
| | | /* |
| | | * Copyright 2014 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.git; |
| | | |
| | | import com.gitblit.git.GitblitReceivePackFactory; |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.SshCommandContext; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | import com.gitblit.transport.ssh.commands.BaseCommand; |
| | | import com.gitblit.transport.ssh.commands.DispatchCommand; |
| | | |
| | | @CommandMetaData(name = "git", description="Dispatcher for git receive and upload commands", hidden = true) |
| | | public class GitDispatchCommand extends DispatchCommand { |
| | | |
| | | protected RepositoryResolver<SshDaemonClient> repositoryResolver; |
| | | protected GitblitUploadPackFactory<SshDaemonClient> uploadPackFactory; |
| | | protected GitblitReceivePackFactory<SshDaemonClient> receivePackFactory; |
| | | |
| | | @Override |
| | | public void setContext(SshCommandContext context) { |
| | | super.setContext(context); |
| | | |
| | | IGitblit gitblit = context.getGitblit(); |
| | | repositoryResolver = new RepositoryResolver<SshDaemonClient>(gitblit); |
| | | uploadPackFactory = new GitblitUploadPackFactory<SshDaemonClient>(gitblit); |
| | | receivePackFactory = new GitblitReceivePackFactory<SshDaemonClient>(gitblit); |
| | | } |
| | | |
| | | @Override |
| | | protected void registerCommands(UserModel user) { |
| | | registerCommand(user, Upload.class); |
| | | registerCommand(user, Receive.class); |
| | | } |
| | | |
| | | @Override |
| | | protected void provideStateTo(final BaseCommand cmd) { |
| | | super.provideStateTo(cmd); |
| | | |
| | | BaseGitCommand a = (BaseGitCommand) cmd; |
| | | a.setRepositoryResolver(repositoryResolver); |
| | | a.setUploadPackFactory(uploadPackFactory); |
| | | a.setReceivePackFactory(receivePackFactory); |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/Receive.java |
| | |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.git; |
| | | |
| | | import org.eclipse.jgit.transport.ReceivePack; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | |
| | | @CommandMetaData(name = "git-receive-pack", description = "Receive pack") |
| | | @CommandMetaData(name = "git-receive-pack", description = "Receives pushes from a client") |
| | | public class Receive extends BaseGitCommand { |
| | | @Override |
| | | protected void runImpl() throws Failure { |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/Upload.java |
| | |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.git; |
| | | |
| | | import org.eclipse.jgit.transport.UploadPack; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | |
| | | @CommandMetaData(name = "git-upload-pack", description = "Upload pack") |
| | | @CommandMetaData(name = "git-upload-pack", description = "Sends packs to a client for clone and fetch") |
| | | public class Upload extends BaseGitCommand { |
| | | @Override |
| | | protected void runImpl() throws Failure { |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/AddKeyCommand.java |
| | |
| | | * License for the specific language governing permissions and limitations under |
| | | * the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.IKeyManager; |
| | | |
| | | /** |
| | | * Add a key to the current user's authorized keys list. |
| | |
| | | public void run() throws IOException, UnloggedFailure { |
| | | String username = ctx.getClient().getUsername(); |
| | | List<String> keys = readKeys(addKeys); |
| | | IKeyManager keyManager = authenticator.getKeyManager(); |
| | | for (String key : keys) { |
| | | keyManager.addKey(username, key); |
| | | getKeyManager().addKey(username, key); |
| | | log.info("added SSH public key for {}", username); |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/BaseKeyCommand.java |
| | |
| | | * License for the specific language governing permissions and limitations under |
| | | * the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.List; |
| | | |
| | | import com.gitblit.transport.ssh.IKeyManager; |
| | | import com.gitblit.transport.ssh.CachingPublicKeyAuthenticator; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | import com.google.common.base.Charsets; |
| | | |
| | | /** |
| | |
| | | * Base class for commands that read SSH keys from stdin or a parameter list. |
| | | * |
| | | */ |
| | | public abstract class BaseKeyCommand extends SshCommand { |
| | | abstract class BaseKeyCommand extends SshCommand { |
| | | |
| | | protected List<String> readKeys(List<String> sshKeys) |
| | | throws UnsupportedEncodingException, IOException { |
| | |
| | | public void setAuthenticator(CachingPublicKeyAuthenticator authenticator) { |
| | | this.authenticator = authenticator; |
| | | } |
| | | |
| | | protected IKeyManager getKeyManager() { |
| | | return authenticator.getKeyManager(); |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/CreateRepository.java |
| | |
| | | * limitations under the License. |
| | | */ |
| | | |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import org.kohsuke.args4j.Option; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | |
| | | @CommandMetaData(name = "create-repository", description = "Create new GIT repository", admin = true, hidden = true) |
| | | public class CreateRepository extends SshCommand { |
New file |
| | |
| | | /* |
| | | * Copyright 2014 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.commands.DispatchCommand; |
| | | |
| | | @CommandMetaData(name = "gitblit", description = "Gitblit server commands") |
| | | public class GitblitDispatchCommand extends DispatchCommand { |
| | | |
| | | @Override |
| | | protected void registerCommands(UserModel user) { |
| | | // normal usage commands |
| | | registerCommand(user, VersionCommand.class); |
| | | registerCommand(user, AddKeyCommand.class); |
| | | registerCommand(user, RemoveKeyCommand.class); |
| | | registerCommand(user, LsCommand.class); |
| | | registerCommand(user, ReviewCommand.class); |
| | | |
| | | // administrative commands |
| | | registerCommand(user, CreateRepository.class); |
| | | registerCommand(user, SetAccountCommand.class); |
| | | } |
| | | } |
New file |
| | |
| | | /* |
| | | * Copyright 2014 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | |
| | | import org.kohsuke.args4j.Option; |
| | | import org.parboiled.common.StringUtils; |
| | | |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.ProjectModel; |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | |
| | | @CommandMetaData(name = "ls", description = "List repositories or projects") |
| | | public class LsCommand extends SshCommand { |
| | | |
| | | @Option(name = "--projects", aliases = { "-p" }, usage = "list projects") |
| | | private boolean projects; |
| | | |
| | | @Option(name = "--verbose", aliases = { "-v" }, usage = "verbose") |
| | | private boolean verbose; |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (projects) { |
| | | listProjects(); |
| | | } else { |
| | | listRepositories(); |
| | | } |
| | | } |
| | | |
| | | protected void listProjects() { |
| | | IGitblit gitblit = ctx.getGitblit(); |
| | | UserModel user = ctx.getClient().getUser(); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | List<ProjectModel> projects = gitblit.getProjectModels(user, false); |
| | | int nameLen = 0; |
| | | int descLen = 0; |
| | | for (ProjectModel project : projects) { |
| | | int len = project.name.length(); |
| | | if (len > nameLen) { |
| | | nameLen = len; |
| | | } |
| | | if (!StringUtils.isEmpty(project.description)) { |
| | | len = project.description.length(); |
| | | if (len > descLen) { |
| | | descLen = len; |
| | | } |
| | | } |
| | | } |
| | | |
| | | String pattern; |
| | | if (verbose) { |
| | | pattern = MessageFormat.format("%-{0,number,0}s\t%-{1,number,0}s\t%s", nameLen, descLen); |
| | | } else { |
| | | pattern = "%s"; |
| | | } |
| | | |
| | | for (ProjectModel project : projects) { |
| | | stdout.println(String.format(pattern, |
| | | project.name, |
| | | project.description == null ? "" : project.description, |
| | | df.format(project.lastChange))); |
| | | } |
| | | } |
| | | |
| | | protected void listRepositories() { |
| | | IGitblit gitblit = ctx.getGitblit(); |
| | | UserModel user = ctx.getClient().getUser(); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | List<RepositoryModel> repositories = gitblit.getRepositoryModels(user); |
| | | int nameLen = 0; |
| | | int descLen = 0; |
| | | for (RepositoryModel repo : repositories) { |
| | | int len = repo.name.length(); |
| | | if (len > nameLen) { |
| | | nameLen = len; |
| | | } |
| | | if (!StringUtils.isEmpty(repo.description)) { |
| | | len = repo.description.length(); |
| | | if (len > descLen) { |
| | | descLen = len; |
| | | } |
| | | } |
| | | } |
| | | |
| | | String pattern; |
| | | if (verbose) { |
| | | pattern = MessageFormat.format("%-{0,number,0}s\t%-{1,number,0}s\t%s", nameLen, descLen); |
| | | } else { |
| | | pattern = "%s"; |
| | | } |
| | | |
| | | for (RepositoryModel repo : repositories) { |
| | | stdout.println(String.format(pattern, |
| | | repo.name, |
| | | repo.description == null ? "" : repo.description, |
| | | df.format(repo.lastChange))); |
| | | } |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/RemoveKeyCommand.java |
| | |
| | | * License for the specific language governing permissions and limitations under |
| | | * the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.IKeyManager; |
| | | |
| | | |
| | | /** |
| | |
| | | public void run() throws IOException, UnloggedFailure { |
| | | String username = ctx.getClient().getUsername(); |
| | | List<String> keys = readKeys(removeKeys); |
| | | IKeyManager keyManager = authenticator.getKeyManager(); |
| | | if (keys.contains(ALL)) { |
| | | keyManager.removeAllKeys(username); |
| | | getKeyManager().removeAllKeys(username); |
| | | log.info("removed all SSH public keys from {}", username); |
| | | } else { |
| | | for (String key : keys) { |
| | | keyManager.removeKey(username, key); |
| | | getKeyManager().removeKey(username, key); |
| | | log.info("removed SSH public key from {}", username); |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/ReviewCommand.java |
| | |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | |
| | | import com.gitblit.models.TicketModel.Score; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | import com.gitblit.wicket.GitBlitWebSession; |
| | | |
| | | @CommandMetaData(name = "review", description = "Verify, approve and/or submit one or more patch sets", hidden = true) |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/SetAccountCommand.java |
| | |
| | | //See the License for the specific language governing permissions and |
| | | //limitations under the License. |
| | | |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.kohsuke.args4j.Option; |
| | | |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.IKeyManager; |
| | | |
| | | /** Set a user's account settings. **/ |
| | | @CommandMetaData(name = "set-account", description = "Change an account's settings", admin = true) |
| | |
| | | |
| | | private void addSshKeys(List<String> sshKeys) throws UnloggedFailure, |
| | | IOException { |
| | | IKeyManager keyManager = authenticator.getKeyManager(); |
| | | for (String sshKey : sshKeys) { |
| | | keyManager.addKey(user, sshKey); |
| | | getKeyManager().addKey(user, sshKey); |
| | | } |
| | | } |
| | | |
| | | private void deleteSshKeys(List<String> sshKeys) { |
| | | IKeyManager keyManager = authenticator.getKeyManager(); |
| | | if (sshKeys.contains(ALL)) { |
| | | keyManager.removeAllKeys(user); |
| | | getKeyManager().removeAllKeys(user); |
| | | } else { |
| | | for (String sshKey : sshKeys) { |
| | | keyManager.removeKey(user, sshKey); |
| | | getKeyManager().removeKey(user, sshKey); |
| | | } |
| | | } |
| | | } |
File was renamed from src/main/java/com/gitblit/transport/ssh/commands/VersionCommand.java |
| | |
| | | * limitations under the License. |
| | | */ |
| | | |
| | | package com.gitblit.transport.ssh.commands; |
| | | package com.gitblit.transport.ssh.gitblit; |
| | | |
| | | import com.gitblit.Constants; |
| | | import com.gitblit.transport.ssh.CommandMetaData; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | |
| | | @CommandMetaData(name="version", description = "Display the Gitblit version") |
| | | public class VersionCommand extends SshCommand { |