コード例 #1
0
ファイル: RootDispatcher.java プロジェクト: kxyfyh/gitblit
  public RootDispatcher(IGitblit gitblit, SshDaemonClient client, String cmdLine) {
    super();
    setContext(new SshCommandContext(gitblit, client, cmdLine));

    UserModel user = client.getUser();
    register(user, VersionCommand.class);
    register(user, GitDispatcher.class);
    register(user, KeysDispatcher.class);
    register(user, PluginDispatcher.class);

    List<DispatchCommand> exts = gitblit.getExtensions(DispatchCommand.class);
    for (DispatchCommand ext : exts) {
      Class<? extends DispatchCommand> extClass = ext.getClass();
      PluginWrapper wrapper = gitblit.whichPlugin(extClass);
      String plugin = wrapper.getDescriptor().getPluginId();
      CommandMetaData meta = extClass.getAnnotation(CommandMetaData.class);
      log.debug("Dispatcher {} is loaded from plugin {}", meta.name(), plugin);
      register(user, ext);
    }
  }
コード例 #2
0
  /**
   * Returns the user making the request, if the user has authenticated.
   *
   * @param httpRequest
   * @return user
   */
  public UserModel getUser(HttpServletRequest httpRequest) {
    UserModel user = null;
    String username = (String) httpRequest.getAttribute("gerrit-username");
    String token = (String) httpRequest.getAttribute("gerrit-token");

    if (token == null || username == null) {
      return null;
    }

    user =
        gitBlit.authenticate(
            username, (GerritToGitBlitUserService.SESSIONAUTH + token).toCharArray(), null);
    if (user != null) {
      return user;
    }

    return null;
  }