繁体   English   中英

在Atlassian插件中从当前用户获取凭据

[英]Get Credentials from Current User in Atlassian Plugin

是否可以在Confluence插件中获取用户名和密码? Usernam像这样为我工作:

ApplicationUser user = userUtil.getUserByName(userManager.getRemoteUsername(request));

我想用当前用户连接到Jira Rest Api。

正如@Philipp Sander所说,无法检索用户的密码。 Confluence仅以加密方式存储密码,因此它甚至不知道用户密码。

但是,由于您正在谈论Confluence插件,因此存在另一种使用应用程序链接与其他Atlassian应用程序的REST API进行通信的方法。

如果您需要用户在其Confluence中配置指向JIRA的应用程序链接,则您的插件可以使用ApplicationLinkService的getApplicationLinks方法获取该ApplicationLink实例:

java.lang.Iterable<ApplicationLink> getApplicationLinks(java.lang.Class<? extends ApplicationType> type) 

    Retrieves all ApplicationLinks of a particular ApplicationType.

接下来,您可以在ApplicationLink实例上调用createAuthenticatedRequestFactory方法,例如:

ApplicationLinkRequestFactory   createAuthenticatedRequestFactory() 

    The ApplicationLinkRequestFactory returned by this method will choose a single AuthenticationProvider for automatically authenticating created Request objects.

通过RequestFactory,可以将REST请求发送到您要定位的应用程序。 JIRA。

有关更多信息,您还可以查看SAL API文档,其中包含有关如何使用RequestFactory的示例。

Atlassian社区中还有一个有用的相关问题 ,它解释了如何使用JAXB获取RequestFactory来编组对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM