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


Java CurrentUser.isIdentifiedUser方法代码示例

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


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

示例1: generateName

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private String generateName(HttpServletRequest req) {
  String userName = "";

  CurrentUser who = user.get();
  if (who.isIdentifiedUser()) {
    String name = who.asIdentifiedUser().getUserName();
    if (name != null && !name.isEmpty()) {
      userName = " (" + name + ")";
    }
  }

  String uri = req.getServletPath();
  Matcher m = URI_PATTERN.matcher(uri);
  if (m.matches()) {
    String path = m.group(1);
    String cmd = m.group(2);
    return cmd + " " + path + userName;
  }

  return req.getMethod() + " " + uri + userName;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:ProjectQoSFilter.java

示例2: abandon

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
public Change abandon(
    BatchUpdate.Factory updateFactory,
    ChangeNotes notes,
    CurrentUser user,
    String msgTxt,
    NotifyHandling notifyHandling,
    ListMultimap<RecipientType, Account.Id> accountsToNotify)
    throws RestApiException, UpdateException {
  Account account = user.isIdentifiedUser() ? user.asIdentifiedUser().getAccount() : null;
  AbandonOp op = abandonOpFactory.create(account, msgTxt, notifyHandling, accountsToNotify);
  try (BatchUpdate u =
      updateFactory.create(dbProvider.get(), notes.getProjectName(), user, TimeUtil.nowTs())) {
    u.addOp(notes.getChangeId(), op).execute();
  }
  return op.getChange();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:Abandon.java

示例3: match

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public boolean match(String ref, CurrentUser user) {
  if (!ref.startsWith(prefix)) {
    return false;
  }

  for (String username : getUsernames(user)) {
    String u;
    if (isRE(template.getPattern())) {
      u = Pattern.quote(username);
    } else {
      u = username;
    }

    Account.Id accountId = user.isIdentifiedUser() ? user.getAccountId() : null;
    RefPatternMatcher next = getMatcher(expand(template, u, accountId));
    if (next != null && next.match(expand(ref, u, accountId), user)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:RefPatternMatcher.java

示例4: byChange

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
/**
 * Retrieve edit for a change and the given user.
 *
 * <p>At most one change edit can exist per user and change.
 *
 * @param notes change notes of change to retrieve change edits for.
 * @param user user to retrieve edits as.
 * @return edit for this change for this user, if present.
 * @throws AuthException if this is not a logged-in user.
 * @throws IOException if an error occurs.
 */
public Optional<ChangeEdit> byChange(ChangeNotes notes, CurrentUser user)
    throws AuthException, IOException {
  if (!user.isIdentifiedUser()) {
    throw new AuthException("Authentication required");
  }
  IdentifiedUser u = user.asIdentifiedUser();
  Change change = notes.getChange();
  try (Repository repo = gitManager.openRepository(change.getProject())) {
    int n = change.currentPatchSetId().get();
    String[] refNames = new String[n];
    for (int i = n; i > 0; i--) {
      refNames[i - 1] =
          RefNames.refsEdit(u.getAccountId(), change.getId(), new PatchSet.Id(change.getId(), i));
    }
    Ref ref = repo.getRefDatabase().firstExactRef(refNames);
    if (ref == null) {
      return Optional.empty();
    }
    try (RevWalk rw = new RevWalk(repo)) {
      RevCommit commit = rw.parseCommit(ref.getObjectId());
      PatchSet basePs = getBasePatchSet(notes, ref);
      return Optional.of(new ChangeEdit(change, ref.getName(), commit, basePs));
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:ChangeEditUtil.java

示例5: initVelocityModel

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private PluginVelocityModel initVelocityModel(HttpServletRequest request) throws IOException {
  PluginVelocityModel model = modelProvider.get();
  GitHubLogin gitHubLogin = loginProvider.get(request);
  model.put("myself", gitHubLogin.getMyself());
  model.put("config", config);

  CurrentUser user = userProvider.get();
  if (user.isIdentifiedUser()) {
    model.put("user", user);
    model.put("hub", gitHubLogin.getHub());
    model.put("scopeCookie", gitHubLogin.getScopesKeyFromCookie(request));
  }

  for (Entry<String, String[]> reqPar : request.getParameterMap().entrySet()) {
    model.put(reqPar.getKey(), reqPar.getValue());
  }
  return model;
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:19,代码来源:VelocityViewServlet.java

示例6: parse

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public GroupResource parse(TopLevelResource parent, IdString id)
    throws AuthException, ResourceNotFoundException {
  final CurrentUser user = self.get();
  if (user instanceof AnonymousUser) {
    throw new AuthException("Authentication required");
  } else if (!(user.isIdentifiedUser())) {
    throw new ResourceNotFoundException(id);
  }

  GroupDescription.Basic group = parseId(id.get());
  if (group == null) {
    throw new ResourceNotFoundException(id.get());
  }
  GroupControl ctl = groupControlFactory.controlFor(group);
  if (!ctl.isVisible()) {
    throw new ResourceNotFoundException(id);
  }
  return new GroupResource(ctl);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:GroupsCollection.java

示例7: toActionMap

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private Map<String, ActionInfo> toActionMap(
    ChangeNotes notes, List<ActionVisitor> visitors, ChangeInfo changeInfo) {
  CurrentUser user = userProvider.get();
  Map<String, ActionInfo> out = new LinkedHashMap<>();
  if (!user.isIdentifiedUser()) {
    return out;
  }

  Iterable<UiAction.Description> descs =
      uiActions.from(changeViews, changeResourceFactory.create(notes, user));

  // The followup action is a client-side only operation that does not
  // have a server side handler. It must be manually registered into the
  // resulting action map.
  Status status = notes.getChange().getStatus();
  if (status.isOpen() || status.equals(Status.MERGED)) {
    UiAction.Description descr = new UiAction.Description();
    PrivateInternals_UiActionDescription.setId(descr, "followup");
    PrivateInternals_UiActionDescription.setMethod(descr, "POST");
    descr.setTitle("Create follow-up change");
    descr.setLabel("Follow-Up");
    descs = Iterables.concat(descs, Collections.singleton(descr));
  }

  ACTION:
  for (UiAction.Description d : descs) {
    ActionInfo actionInfo = new ActionInfo(d);
    for (ActionVisitor visitor : visitors) {
      if (!visitor.visit(d.getId(), actionInfo, changeInfo)) {
        continue ACTION;
      }
    }
    out.put(d.getId(), actionInfo);
  }
  return out;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:ActionJson.java

示例8: getUser

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public CurrentUser getUser() {
  CurrentUser user = session.getUser();
  if (user != null && user.isIdentifiedUser()) {
    IdentifiedUser identifiedUser = userFactory.create(user.getAccountId());
    identifiedUser.setAccessPath(user.getAccessPath());
    return identifiedUser;
  }
  return user;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:SshScope.java

示例9: doFilter

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
    throws IOException, ServletException {
  CurrentUser user = userProvider.get();
  if (user != null && user.isIdentifiedUser()) {
    IdentifiedUser who = user.asIdentifiedUser();
    if (who.getUserName() != null && !who.getUserName().isEmpty()) {
      req.setAttribute(REQ_ATTR_KEY, who.getUserName());
    } else {
      req.setAttribute(REQ_ATTR_KEY, "a/" + who.getAccountId());
    }
  }
  chain.doFilter(req, resp);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:GetUserFilter.java

示例10: 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

示例11: describe

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
public static String describe(CurrentUser user) {
  if (user.isIdentifiedUser()) {
    return user.getAccountId().toString();
  }
  if (user instanceof SingleGroupUser) {
    return "group:" + user.getEffectiveGroups().getKnownGroups().iterator().next().toString();
  }
  return user.toString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:IndexUtils.java

示例12: canRemoveReviewerWithoutPermissionCheck

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private boolean canRemoveReviewerWithoutPermissionCheck(
    Change change, CurrentUser currentUser, Account.Id reviewer, int value)
    throws NoSuchProjectException, IOException {
  if (!change.getStatus().isOpen()) {
    return false;
  }

  if (currentUser.isIdentifiedUser()) {
    Account.Id aId = currentUser.getAccountId();
    if (aId.equals(reviewer)) {
      return true; // A user can always remove themselves.
    } else if (aId.equals(change.getOwner()) && 0 <= value) {
      return true; // The change owner may remove any zero or positive score.
    }
  }

  // Users with the remove reviewer permission, the branch owner, project
  // owner and site admin can remove anyone
  // TODO(hiesel): Remove all Control usage
  ProjectControl ctl = projectControlFactory.controlFor(change.getProject(), currentUser);
  if (ctl.controlForRef(change.getDest()).isOwner() // branch owner
      || ctl.isOwner() // project owner
      || ctl.isAdmin()) { // project admin
    return true;
  }
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:28,代码来源:RemoveReviewerControl.java

示例13: getUsernames

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private Iterable<String> getUsernames(CurrentUser user) {
  if (user.isIdentifiedUser()) {
    Set<String> emails = user.asIdentifiedUser().getEmailAddresses();
    if (user.getUserName() == null) {
      return emails;
    } else if (emails.isEmpty()) {
      return ImmutableSet.of(user.getUserName());
    }
    return Iterables.concat(emails, ImmutableSet.of(user.getUserName()));
  }
  if (user.getUserName() != null) {
    return ImmutableSet.of(user.getUserName());
  }
  return ImmutableSet.of();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:RefPatternMatcher.java

示例14: getIdentifiedUser

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
IdentifiedUser getIdentifiedUser() throws QueryParseException {
  try {
    CurrentUser u = getUser();
    if (u.isIdentifiedUser()) {
      return u.asIdentifiedUser();
    }
    throw new QueryParseException(NotSignedInException.MESSAGE);
  } catch (ProvisionException e) {
    throw new QueryParseException(NotSignedInException.MESSAGE, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:AccountQueryBuilder.java

示例15: getWatches

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
protected static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
    throws QueryParseException {
  CurrentUser user = args.getUser();
  if (user.isIdentifiedUser()) {
    return args.accountCache.get(args.getUser().getAccountId()).getProjectWatches().keySet();
  }
  return Collections.<ProjectWatchKey>emptySet();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:IsWatchedByPredicate.java


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