• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AuthenticatedUserThreadLocal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.atlassian.confluence.user.AuthenticatedUserThreadLocal的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatedUserThreadLocal类的具体用法?Java AuthenticatedUserThreadLocal怎么用?Java AuthenticatedUserThreadLocal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuthenticatedUserThreadLocal类属于com.atlassian.confluence.user包,在下文中一共展示了AuthenticatedUserThreadLocal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getProfile

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@GET
@Path("/{username}")
@AnonymousAllowed
@Produces({"application/json"})
public Response getProfile(@PathParam("username") String username) {
    final Response response;
    final ConfluenceUser user = _userAccessor.getUserByName(username);
    final ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
    final Locale locale = currentUser != null ? _localeManager.getLocale(currentUser) : null;
    if (user == null || !_userHelper.isProfileViewPermitted()) {
        response = getNotFoundResponse();
    } else {
        final UserDto original = _userDtoFactory.getUserDto(user);
        final ExtendedUserDto dto = new ExtendedUserDto(original, createGroupsFor(currentUser, user, locale));
        response = ok(dto).build();
    }
    return response;
}
 
开发者ID:echocat,项目名称:adam,代码行数:19,代码来源:ProfileResource.java


示例2: getRemoteUser

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
public User getRemoteUser()
  {
      HttpServletRequest request = ServletActionContext.getRequest();

if (request != null)
      {
          String remoteUserName = request.getRemoteUser();
	
	if (remoteUserName != null)
	{
		return getUserAccessor().getUser(remoteUserName);
	}
}

return AuthenticatedUserThreadLocal.getUser();
  }
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:17,代码来源:ConfluenceGreenPepper.java


示例3: newFriendlyDateFormatter

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
protected FriendlyDateFormatter newFriendlyDateFormatter() {
	// Get current user's timezone, or default one
	User authUser = AuthenticatedUserThreadLocal.getUser();
	TimeZone timeZone;
	if (authUser == null) {
		// anonymous
		timeZone = TimeZone.getDefault();
	} else {
		ConfluenceUserPreferences prefs = userAccessor
				.getConfluenceUserPreferences(authUser);
		timeZone = prefs.getTimeZone();
	}
	// Build date formatter
	DateFormatter dateFormatter = new DateFormatter(timeZone,
			formatSettingsManager, localeManager);

	// Build "friendly" date formatter
	FriendlyDateFormatter friendlyDateFormatter = new FriendlyDateFormatter(
			new Date(), dateFormatter);
	return friendlyDateFormatter;
}
 
开发者ID:baloise,项目名称:dashboard-plus,代码行数:22,代码来源:StatusLightBasedMacro.java


示例4: newNumberFormatter

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
protected NumberFormat newNumberFormatter() {
	// Get current user's timezone, or default one
	User authUser = AuthenticatedUserThreadLocal.getUser();
	NumberFormat result = null;
	if (authUser != null) {
		ConfluenceUserPreferences prefs = userAccessor
				.getConfluenceUserPreferences(authUser);
		if (prefs != null && prefs.getLocale() != null) {
			result = NumberFormat.getNumberInstance(prefs.getLocale());
		}
	}
	if (result == null) {
		// anonymous
		result = NumberFormat.getNumberInstance();
	}
	return result;
}
 
开发者ID:baloise,项目名称:dashboard-plus,代码行数:18,代码来源:StatusLightBasedMacro.java


示例5: saveItemWithAttachments

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
/**
 * This is the rest API call to save a new Item.
 *
 * @param message
 * @param threadID
 * @return a new item with the given parameters
 */
@POST
@Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
@Path("items/withAttachments")
public Response saveItemWithAttachments(@QueryParam(value = "message") String message,
                                        @QueryParam(value = "threadID") int threadID, @QueryParam(value = "attachments") String attachments) {
    Date date = Calendar.getInstance().getTime();
    String safeMessage = sanitizer.sanitizeInput(message);
    checkEmptyInput(safeMessage);
    String userKey = AuthenticatedUserThreadLocal.get().getKey().getStringValue();
    if (attachments.isEmpty()) {
        return getResponseItemAdd(threadID, date, safeMessage, userKey);
    } else {
        List<SerializableAttachment> safeAttachments = sanitizer.parseAttachmentJson(attachments);
        return Response.ok(
                SerializablePost.build(itemRepository.add(safeMessage, date, threadID, userKey, safeAttachments))
        ).build();
    }
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:26,代码来源:ItemRestService.java


示例6: saveThread

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
/**
 * This is the rest API call to save a new thread.
 *
 * @param title
 * @param description
 * @param sticky
 * @return a new thread with the given parameters
 */

@POST
@Consumes({MediaType.APPLICATION_FORM_URLENCODED})
@Path("threads")
public Response saveThread(@FormParam(value = "title") String title,
                           @FormParam(value = "description") String description,
                           @FormParam(value = "sticky") boolean sticky,
                           @FormParam(value = "forumID") int forumID) {
    System.out.println("forumID: " + forumID);
    String safeTitle = sanitizer.sanitizeInput(title);
    String safeDescription = sanitizer.sanitizeInput(description);
    checkEmptyInput(safeTitle);
    checkEmptyInput(safeDescription);
    Date date = Calendar.getInstance().getTime();
    String userKey = AuthenticatedUserThreadLocal.get().getKey().getStringValue();
    return Response.ok(
            SerializableThread.build(threadRepo.add(safeTitle, safeDescription,
                    sticky, date, forumID, userKey))
    ).build();
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:29,代码来源:ThreadRestService.java


示例7: setUp

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    assertNotNull(entityManager);
    ao = new TestActiveObjects(entityManager);
    forumAO = ao.create(ForumAO.class, new DBParam("TITLE", "ForumTitle"));
    forumAO.setDescription("ForumDescription");
    forumAO.save();
    forumID = forumAO.getID();
    userManagementRepository = new UserManagementRepositoryImplement(ao);
    roleManagementRepository = new RoleManagementRepositoryImplement(ao);
    permissionManagementRepository = new PermissionManagementRepositoryImplement(ao);
    forumRepository = new ForumRepositoryImplement(ao);
    rightsManagement = new RightsManagementImplement(userManagementRepository, roleManagementRepository, permissionManagementRepository, forumRepository);
    threadRepository = new ThreadRepositoryImplement(ao, rightsManagement);
    itemRepository = new ItemRepositoryImplement(ao, rightsManagement);
    mockAdminUser = MockConfluenceUserFactory.mockUser();
    mockParticipantUser = MockConfluenceUserFactory.mockUser();
    userKeyAdmin = mockAdminUser.getKey().getStringValue();
    userKeyParticipant = mockParticipantUser.getKey().getStringValue();
    rightsManagement.initPermissions();
    rightsManagement.initAdmin(userKeyAdmin, forumID);
    rightsManagement.addUser(userKeyAdmin, userKeyParticipant, "Admin",
            forumID);
    AuthenticatedUserThreadLocal.set(mockAdminUser);
    AuthenticatedUserThreadLocal.set(mockParticipantUser);
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:27,代码来源:ThreadRepositoryTest.java


示例8: setUp

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    assertNotNull(entityManager);
    ao = new TestActiveObjects(entityManager);
    forumAO = ao.create(ForumAO.class, new DBParam("TITLE", "ForumTitle"));
    forumAO.setDescription("ForumDescription");
    forumAO.save();
    forumID = forumAO.getID();
    userManagementRepository = new UserManagementRepositoryImplement(ao);
    roleManagementRepository = new RoleManagementRepositoryImplement(ao);
    permissionManagementRepository = new PermissionManagementRepositoryImplement(ao);
    forumRepository = new ForumRepositoryImplement(ao);
    rightsManagement = new RightsManagementImplement(userManagementRepository, roleManagementRepository, permissionManagementRepository, forumRepository);
    threadRepository = new ThreadRepositoryImplement(ao, rightsManagement);
    itemRepository = new ItemRepositoryImplement(ao, rightsManagement);
    itemRestService = new ItemRestService(itemRepository, sanitizer);
    mockAdminUser = MockConfluenceUserFactory.mockUser();
    userKeyAdmin = mockAdminUser.getKey().getStringValue();
    rightsManagement.initPermissions();
    rightsManagement.initAdmin(userKeyAdmin, forumID);
    AuthenticatedUserThreadLocal.set(mockAdminUser);
    thread = threadRepository.add(threadTitle, threadDescription,
            threadSticky, date, forumID, userKeyAdmin);
    item = itemRepository.add(itemMessage, date, thread.getID(),
            userKeyAdmin);
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:27,代码来源:ItemRestServiceTest.java


示例9: setUp

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    assertNotNull(entityManager);
    ao = new TestActiveObjects(entityManager);
    forumAO = ao.create(ForumAO.class, new DBParam("TITLE", "ForumTitle"));
    forumAO.setDescription("ForumDescription");
    forumAO.save();
    forumID = forumAO.getID();
    userManagementRepository = new UserManagementRepositoryImplement(ao);
    roleManagementRepository = new RoleManagementRepositoryImplement(ao);
    permissionManagementRepository = new PermissionManagementRepositoryImplement(ao);
    forumRepository = new ForumRepositoryImplement(ao);
    rightsManagement = new RightsManagementImplement(userManagementRepository, roleManagementRepository, permissionManagementRepository, forumRepository);
    threadRepository = new ThreadRepositoryImplement(ao, rightsManagement);
    threadRestService = new ThreadRestService(threadRepository, sanitizer);
    mockAdminUser = MockConfluenceUserFactory.mockUser();
    userKeyAdmin = mockAdminUser.getKey().getStringValue();
    rightsManagement.initPermissions();
    rightsManagement.initAdmin(userKeyAdmin, forumID);
    AuthenticatedUserThreadLocal.set(mockAdminUser);
    thread = threadRepository.add(threadTitle, threadDescription,
            threadSticky, threadDate, forumID, userKeyAdmin);
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:24,代码来源:ThreadRestServiceTest.java


示例10: getTemplateNameFor

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@Nonnull
protected String getTemplateNameFor(@Nonnull Map<String, Object> context, @Nullable User user) {
    final ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
    final String variant;
    if ((user == null || !user.equals(currentUser)) && !_permissionManager.hasPermission(currentUser, VIEW, TARGET_PEOPLE_DIRECTORY)) {
        variant = ".accessDenied";
    } else {
        final Object username = context.get("username");
        if (username == null || username.toString().isEmpty()) {
            variant = ".missingUsername";
        } else if (context.get("user") == null) {
            variant = ".unknownUser";
        } else {
            variant = "";
        }
    }
    return TEMPLATE_NAME_PREFIX + variant + TEMPLATE_NAME_SUFFIX;
}
 
开发者ID:echocat,项目名称:adam,代码行数:19,代码来源:UserProfileMacro.java


示例11: onSpaceRemoveEvent

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@EventListener
public void onSpaceRemoveEvent(SpaceRemoveEvent spaceRemoveEvent) {
    String username = AuthenticatedUserThreadLocal.getUsername();
    if (username == null) {
        username = "";
    }
    metricCollector.spaceDeleteCounter(username);
}
 
开发者ID:AndreyVMarkelov,项目名称:prom-confluence-exporter,代码行数:9,代码来源:MetricListener.java


示例12: onSpaceCreateEvent

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@EventListener
public void onSpaceCreateEvent(SpaceCreateEvent spaceCreateEvent) {
    String username = AuthenticatedUserThreadLocal.getUsername();
    if (username == null) {
        username = "";
    }
    metricCollector.spaceCreateCounter(username);
}
 
开发者ID:AndreyVMarkelov,项目名称:prom-confluence-exporter,代码行数:9,代码来源:MetricListener.java


示例13: doesCurrentUserHaveToken

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
@GET
@Path("ask")
public boolean doesCurrentUserHaveToken() {
    String userKey = AuthenticatedUserThreadLocal.get().getKey().getStringValue();
    return ao.executeInTransaction(() ->
            ao.find(BundleAccessToken.class, Query.select().where("USER_KEY = ?", userKey)).length == 1);
}
 
开发者ID:NetworkedAssets,项目名称:doc,代码行数:8,代码来源:BundleAccessTokenService.java


示例14: shouldDisplay

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
public boolean shouldDisplay(Map<String, Object> context)
{
	Attachment attachment = (Attachment) context.get("attachment");
	if (attachment == null)
	{
		return false;
	}
	if (!isXExtension(attachment.getFileExtension()))
	{
		return false;
	}
	if (attachment.getFileSize() > DocumentManager.GetMaxFileSize())
	{
		return false;
	}

	ConfluenceUser user = AuthenticatedUserThreadLocal.get();
	boolean accessEdit = AttachmentUtil.checkAccess(attachment, user, true);
	boolean accessView = AttachmentUtil.checkAccess(attachment, user, false);
	if (!forEdit && (!accessView || accessEdit))
	{
		return false;
	}
	if (forEdit && !accessEdit)
	{
		return false;
	}

	return true;
}
 
开发者ID:ONLYOFFICE,项目名称:onlyoffice-confluence,代码行数:31,代码来源:IsOfficeFileAttachment.java


示例15: saveAttachment

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
public static void saveAttachment(Long attachmentId, InputStream attachmentData, int size, ConfluenceUser user)
		throws IOException, IllegalArgumentException
{
	AttachmentManager attachmentManager = (AttachmentManager) ContainerManager.getComponent("attachmentManager");
	Attachment attachment = attachmentManager.getAttachment(attachmentId);
	
	Attachment oldAttachment = attachment.copy();
	attachment.setFileSize(size);

	AuthenticatedUserThreadLocal.set(user);

	attachmentManager.saveAttachment(attachment, oldAttachment, attachmentData);
}
 
开发者ID:ONLYOFFICE,项目名称:onlyoffice-confluence,代码行数:14,代码来源:AttachmentUtil.java


示例16: login

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
private String login(String username, String password) throws RemoteException
  {
  	if(StringUtil.isEmpty(username)) return "";
  	String token = gpUtil.getTokenAuthenticationManager().login(username, password);
AuthenticatedUserThreadLocal.setUser(getUser(token));
return token;
  }
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:8,代码来源:ConfluenceXmlRpcGreenPepperServiceImpl.java


示例17: getRemoteUser

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
/**
 * <p>getRemoteUser.</p>
 *
 * @return a {@link com.atlassian.user.User} object.
 */
public User getRemoteUser() {
    HttpServletRequest request = ServletActionContext.getRequest();

    if (request != null) {
        String remoteUserName = request.getRemoteUser();

        if (remoteUserName != null) {
            return getUserAccessor().getUserIfAvailable(remoteUserName);
        }
    }

    return AuthenticatedUserThreadLocal.getUser();
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:19,代码来源:ConfluenceGreenPepper.java


示例18: getRemoteUser

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
public User getRemoteUser() {
    HttpServletRequest request = ServletActionContext.getRequest();

    if (request != null) {
        String remoteUserName = request.getRemoteUser();

        if (remoteUserName != null) {
            return getUserAccessor().getUserByName(remoteUserName);
        }
    }

    return AuthenticatedUserThreadLocal.get();
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-confluence,代码行数:14,代码来源:LivingDocConfluenceManager.java


示例19: createNewForum

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
private ForumAO createNewForum(Map parameters) {
    ForumAO newForum = ao.create(ForumAO.class, new DBParam("TITLE", "title"));
    newForum.setTitle((String) parameters.get(forumTitel));
    newForum.setDescription((String) parameters.get("forum_description"));
    newForum.save();
    // Initialize permissions if not yet done and add current user as
    // admin
    if (ao.find(PermissionAO.class).length == 0) {
        rightsManagement.initPermissions();
    }
    ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
    rightsManagement.initAdmin(currentUser.getKey().getStringValue(), newForum.getID());
    rightsManagement.initDeletedUserRole(newForum.getID());
    return newForum;
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:16,代码来源:Forum.java


示例20: saveItem

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; //导入依赖的package包/类
/**
 * This is the rest API call to save a new Item with attachments.
 *
 * @param message
 * @param threadID
 * @return a new item with the given parameters
 */
@POST
@Consumes({MediaType.APPLICATION_FORM_URLENCODED})
@Path("items")
public Response saveItem(@FormParam(value = "message") String message,
                         @FormParam(value = "threadID") int threadID) {
    Date date = Calendar.getInstance().getTime();
    String safeMessage = sanitizer.sanitizeInput(message);
    checkEmptyInput(safeMessage);
    String userKey = AuthenticatedUserThreadLocal.get().getKey().getStringValue();
    return getResponseItemAdd(threadID, date, safeMessage, userKey);
}
 
开发者ID:confluence-fourum,项目名称:Fourum-Plugin,代码行数:19,代码来源:ItemRestService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NullCompleter类代码示例发布时间:2022-05-22
下一篇:
Java ClassLoaderReference类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap