本文整理汇总了Java中com.google.gerrit.server.AnonymousUser类的典型用法代码示例。如果您正苦于以下问题:Java AnonymousUser类的具体用法?Java AnonymousUser怎么用?Java AnonymousUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnonymousUser类属于com.google.gerrit.server包,在下文中一共展示了AnonymousUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.google.gerrit.server.AnonymousUser; //导入依赖的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);
}
示例2: parseIdOnBehalfOf
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
private IdentifiedUser parseIdOnBehalfOf(@Nullable CurrentUser caller, String id)
throws AuthException, OrmException, IOException, ConfigInvalidException {
if (id.equals("self")) {
CurrentUser user = self.get();
if (user.isIdentifiedUser()) {
return user.asIdentifiedUser();
} else if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else {
return null;
}
}
Account match = resolver.find(id);
if (match == null) {
return null;
}
CurrentUser realUser = caller != null ? caller.getRealUser() : null;
return userFactory.runAs(null, match.getId(), realUser);
}
示例3: GerritGitBlitUserManager
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
public GerritGitBlitUserManager(final ProjectControl.GenericFactory projectControl, final GitBlitSettings settings,
final DynamicItem<WebSession> gerritSession, final Provider<AnonymousUser> anonymousUser, final GetDiffPreferences getDiffPreferences) {
this.projectControl = projectControl;
this.userProvider = new Provider<CurrentUser>() {
@Override
public CurrentUser get() {
return gerritSession.get().getUser();
}
};
this.anonymousUser = anonymousUser;
this.getDiffPreferences = getDiffPreferences;
if (!settings.getBoolean(Keys.web.authenticateViewPages, false) && !fixAnonymousUser()) {
settings.saveSettings(ImmutableMap.of(Keys.web.authenticateViewPages, Boolean.TRUE.toString()));
}
}
示例4: exec
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
CurrentUser curUser = StoredValues.CURRENT_USER.getOrNull(engine);
if (curUser == null) {
throw new EvaluationException("Current user not available in this rule type");
}
Term resultTerm;
if (curUser.isIdentifiedUser()) {
Account.Id id = curUser.getAccountId();
resultTerm = new IntegerTerm(id.get());
} else if (curUser instanceof AnonymousUser) {
resultTerm = anonymous;
} else if (curUser instanceof PeerDaemonUser) {
resultTerm = peerDaemon;
} else {
throw new EvaluationException("Unknown user type");
}
if (!a1.unify(new StructureTerm(user, resultTerm), engine.trail)) {
return engine.fail();
}
return cont;
}
示例5: CacheBasedWebSession
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
protected CacheBasedWebSession(
HttpServletRequest request,
HttpServletResponse response,
WebSessionManager manager,
AuthConfig authConfig,
Provider<AnonymousUser> anonymousProvider,
IdentifiedUser.RequestFactory identified) {
this.request = request;
this.response = response;
this.manager = manager;
this.authConfig = authConfig;
this.anonymousProvider = anonymousProvider;
this.identified = identified;
if (request.getRequestURI() == null || !GitSmartHttpTools.isGitClient(request)) {
String cookie = readCookie(request);
if (cookie != null) {
authFromCookie(cookie);
} else {
String token;
try {
token = ParameterParser.getQueryParams(request).accessToken();
} catch (BadRequestException e) {
token = null;
}
if (token != null) {
authFromQueryParameter(token);
}
}
if (val != null && val.needsCookieRefresh()) {
// Session is more than half old; update cache entry with new expiration date.
val = manager.createVal(key, val);
}
}
}
示例6: checkUserSession
import com.google.gerrit.server.AnonymousUser; //导入依赖的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());
}
}
示例7: H2CacheBasedWebSession
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
H2CacheBasedWebSession(
HttpServletRequest request,
@Nullable HttpServletResponse response,
WebSessionManagerFactory managerFactory,
@Named(WebSessionManager.CACHE_NAME) Cache<String, Val> cache,
AuthConfig authConfig,
Provider<AnonymousUser> anonymousProvider,
RequestFactory identified) {
super(
request, response, managerFactory.create(cache), authConfig, anonymousProvider, identified);
}
示例8: list
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Override
public RestView<TopLevelResource> list() throws ResourceNotFoundException, AuthException {
final CurrentUser user = self.get();
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if (!(user.isIdentifiedUser())) {
throw new ResourceNotFoundException();
}
if (hasQuery2) {
return queryGroups.get();
}
return list.get();
}
示例9: Args
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
Args(
ProjectCache projectCache,
PermissionBackend permissionBackend,
GitRepositoryManager repositoryManager,
PatchListCache patchListCache,
PatchSetInfoFactory patchSetInfoFactory,
IdentifiedUser.GenericFactory userFactory,
Provider<AnonymousUser> anonymousUser,
@GerritServerConfig Config config) {
this.projectCache = projectCache;
this.permissionBackend = permissionBackend;
this.repositoryManager = repositoryManager;
this.patchListCache = patchListCache;
this.patchSetInfoFactory = patchSetInfoFactory;
this.userFactory = userFactory;
this.anonymousUser = anonymousUser;
int limit = config.getInt("rules", null, "reductionLimit", 100000);
reductionLimit = limit <= 0 ? Integer.MAX_VALUE : limit;
limit =
config.getInt(
"rules",
null,
"compileReductionLimit",
(int) Math.min(10L * limit, Integer.MAX_VALUE));
compileLimit = limit <= 0 ? Integer.MAX_VALUE : limit;
}
示例10: PostReviewers
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
PostReviewers(
AccountsCollection accounts,
ReviewerResource.Factory reviewerFactory,
PermissionBackend permissionBackend,
GroupsCollection groupsCollection,
GroupMembers groupMembers,
AccountLoader.Factory accountLoaderFactory,
Provider<ReviewDb> db,
ChangeData.Factory changeDataFactory,
RetryHelper retryHelper,
IdentifiedUser.GenericFactory identifiedUserFactory,
@GerritServerConfig Config cfg,
ReviewerJson json,
NotesMigration migration,
NotifyUtil notifyUtil,
ProjectCache projectCache,
Provider<AnonymousUser> anonymousProvider,
PostReviewersOp.Factory postReviewersOpFactory,
OutgoingEmailValidator validator) {
super(retryHelper);
this.accounts = accounts;
this.reviewerFactory = reviewerFactory;
this.permissionBackend = permissionBackend;
this.groupsCollection = groupsCollection;
this.groupMembers = groupMembers;
this.accountLoaderFactory = accountLoaderFactory;
this.dbProvider = db;
this.changeDataFactory = changeDataFactory;
this.identifiedUserFactory = identifiedUserFactory;
this.cfg = cfg;
this.json = json;
this.migration = migration;
this.notifyUtil = notifyUtil;
this.projectCache = projectCache;
this.anonymousProvider = anonymousProvider;
this.postReviewersOpFactory = postReviewersOpFactory;
this.validator = validator;
}
示例11: open
import com.google.gerrit.server.AnonymousUser; //导入依赖的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);
}
}
示例12: GitwebServlet
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
GitwebServlet(
GitRepositoryManager repoManager,
ProjectCache projectCache,
PermissionBackend permissionBackend,
Provider<AnonymousUser> anonymousUserProvider,
Provider<CurrentUser> userProvider,
SitePaths site,
@GerritServerConfig Config cfg,
SshInfo sshInfo,
GitwebConfig gitwebConfig,
GitwebCgiConfig gitwebCgiConfig)
throws IOException {
if (!(repoManager instanceof LocalDiskRepositoryManager)) {
throw new ProvisionException("Gitweb can only be used with LocalDiskRepositoryManager");
}
this.repoManager = (LocalDiskRepositoryManager) repoManager;
this.projectCache = projectCache;
this.permissionBackend = permissionBackend;
this.anonymousUserProvider = anonymousUserProvider;
this.userProvider = userProvider;
this.gitwebCgi = gitwebCgiConfig.getGitwebCgi();
this.deniedActions = new HashSet<>();
final String url = gitwebConfig.getUrl();
if ((url != null) && (!url.equals("gitweb"))) {
URI uri = null;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
log.error("Invalid gitweb.url: " + url);
}
gitwebUrl = uri;
} else {
gitwebUrl = null;
}
deniedActions.add("forks");
deniedActions.add("opml");
deniedActions.add("project_index");
_env = new EnvList();
makeSiteConfig(site, cfg, sshInfo);
if (!_env.envMap.containsKey("SystemRoot")) {
String os = System.getProperty("os.name");
if (os != null && os.toLowerCase().contains("windows")) {
String sysroot = System.getenv("SystemRoot");
if (sysroot == null || sysroot.isEmpty()) {
sysroot = "C:\\WINDOWS";
}
_env.set("SystemRoot", sysroot);
}
}
if (!_env.envMap.containsKey("PATH")) {
_env.set("PATH", System.getenv("PATH"));
}
}
示例13: EmailArguments
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Inject
EmailArguments(
GitRepositoryManager server,
ProjectCache projectCache,
PermissionBackend permissionBackend,
GroupBackend groupBackend,
AccountCache accountCache,
PatchListCache patchListCache,
ApprovalsUtil approvalsUtil,
FromAddressGenerator fromAddressGenerator,
EmailSender emailSender,
PatchSetInfoFactory patchSetInfoFactory,
GenericFactory identifiedUserFactory,
ChangeNotes.Factory changeNotesFactory,
AnonymousUser anonymousUser,
@AnonymousCowardName String anonymousCowardName,
GerritPersonIdentProvider gerritPersonIdentProvider,
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
AllProjectsName allProjectsName,
ChangeQueryBuilder queryBuilder,
Provider<ReviewDb> db,
ChangeData.Factory changeDataFactory,
@MailTemplates SoyTofu soyTofu,
EmailSettings settings,
@SshAdvertisedAddresses List<String> sshAddresses,
SitePaths site,
DynamicSet<OutgoingEmailValidationListener> outgoingEmailValidationListeners,
Provider<InternalAccountQuery> accountQueryProvider,
OutgoingEmailValidator validator) {
this.server = server;
this.projectCache = projectCache;
this.permissionBackend = permissionBackend;
this.groupBackend = groupBackend;
this.accountCache = accountCache;
this.patchListCache = patchListCache;
this.approvalsUtil = approvalsUtil;
this.fromAddressGenerator = fromAddressGenerator;
this.emailSender = emailSender;
this.patchSetInfoFactory = patchSetInfoFactory;
this.identifiedUserFactory = identifiedUserFactory;
this.changeNotesFactory = changeNotesFactory;
this.anonymousUser = anonymousUser;
this.anonymousCowardName = anonymousCowardName;
this.gerritPersonIdent = gerritPersonIdentProvider.get();
this.urlProvider = urlProvider;
this.allProjectsName = allProjectsName;
this.queryBuilder = queryBuilder;
this.db = db;
this.changeDataFactory = changeDataFactory;
this.soyTofu = soyTofu;
this.settings = settings;
this.sshAddresses = sshAddresses;
this.site = site;
this.outgoingEmailValidationListeners = outgoingEmailValidationListeners;
this.accountQueryProvider = accountQueryProvider;
this.validator = validator;
}
示例14: getAnonymousUser
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
public AnonymousUser getAnonymousUser() {
return anonymousUser.get();
}
示例15: createValue
import com.google.gerrit.server.AnonymousUser; //导入依赖的package包/类
@Override
protected AnonymousUser createValue(Prolog engine) {
PrologEnvironment env = (PrologEnvironment) engine.control;
return env.getArgs().getAnonymousUser();
}