当前位置: 首页>>代码示例>>Java>>正文


Java CurrentUser.setAccessPath方法代码示例

本文整理汇总了Java中com.google.gerrit.server.CurrentUser.setAccessPath方法的典型用法代码示例。如果您正苦于以下问题:Java CurrentUser.setAccessPath方法的具体用法?Java CurrentUser.setAccessPath怎么用?Java CurrentUser.setAccessPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.server.CurrentUser的用法示例。


在下文中一共展示了CurrentUser.setAccessPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SshSession

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
SshSession(SshSession parent, SocketAddress peer, CurrentUser user) {
  user.setAccessPath(AccessPath.SSH_COMMAND);
  this.sessionId = parent.sessionId;
  this.remoteAddress = peer;
  if (parent.remoteAddress == peer) {
    this.remoteAsString = parent.remoteAsString;
  } else {
    this.remoteAsString = format(peer) + "/" + parent.remoteAsString;
  }
  this.identity = user;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:SshSession.java

示例2: checkUserSession

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private void checkUserSession(HttpServletRequest req) throws AuthException {
  CurrentUser user = globals.currentUser.get();
  if (isRead(req)) {
    user.setAccessPath(AccessPath.REST_API);
  } else if (user instanceof AnonymousUser) {
    throw new AuthException("Authentication required");
  } else if (!globals.webSession.get().isAccessPathOk(AccessPath.REST_API)) {
    throw new AuthException(
        "Invalid authentication method. In order to authenticate, "
            + "prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/).");
  }
  if (user.isIdentifiedUser()) {
    user.setLastLoginExternalIdKey(globals.webSession.get().getLastLoginExternalId());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:RestApiServlet.java

示例3: open

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public Repository open(HttpServletRequest req, String projectName)
    throws RepositoryNotFoundException, ServiceNotAuthorizedException,
        ServiceNotEnabledException, ServiceMayNotContinueException {
  while (projectName.endsWith("/")) {
    projectName = projectName.substring(0, projectName.length() - 1);
  }

  if (projectName.endsWith(".git")) {
    // Be nice and drop the trailing ".git" suffix, which we never keep
    // in our database, but clients might mistakenly provide anyway.
    //
    projectName = projectName.substring(0, projectName.length() - 4);
    while (projectName.endsWith("/")) {
      projectName = projectName.substring(0, projectName.length() - 1);
    }
  }

  CurrentUser user = userProvider.get();
  user.setAccessPath(AccessPath.GIT);

  try {
    Project.NameKey nameKey = new Project.NameKey(projectName);
    ProjectState state = projectCache.checkedGet(nameKey);
    if (state == null) {
      throw new RepositoryNotFoundException(nameKey.get());
    }
    req.setAttribute(ATT_STATE, state);

    try {
      permissionBackend.user(user).project(nameKey).check(ProjectPermission.ACCESS);
    } catch (AuthException e) {
      if (user instanceof AnonymousUser) {
        throw new ServiceNotAuthorizedException();
      }
      throw new ServiceNotEnabledException(e.getMessage());
    }

    return manager.openRepository(nameKey);
  } catch (IOException | PermissionBackendException err) {
    throw new ServiceMayNotContinueException(projectName + " unavailable", err);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:44,代码来源:GitOverHttpServlet.java


注:本文中的com.google.gerrit.server.CurrentUser.setAccessPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。