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


Java AuthenticatedUserThreadLocal类代码示例

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


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


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