简体   繁体   English

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

[英]Get Credentials from Current User in Atlassian Plugin

is it possible to get Username and Password in a Confluence Plugin? 是否可以在Confluence插件中获取用户名和密码? The Usernam works for me like this: Usernam像这样为我工作:

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

I want to connect to the Jira Rest Api with the current User. 我想用当前用户连接到Jira Rest Api。

As @Philipp Sander already commented, it is not possible to retrieve the user's password. 正如@Philipp Sander所说,无法检索用户的密码。 Confluence only stores passwords in an encrypted way, so it doesn't even know user passwords. Confluence仅以加密方式存储密码,因此它甚至不知道用户密码。

However, since you're talking about a Confluence plugin, there is another way to talk to other Atlassian applications' REST APIs by using application links. 但是,由于您正在谈论Confluence插件,因此存在另一种使用应用程序链接与其他Atlassian应用程序的REST API进行通信的方法。

If you require users to configure an application link to JIRA in their Confluence, then your plugin can get that ApplicationLink instance using the ApplicationLinkService 's getApplicationLinks method: 如果您需要用户在其Confluence中配置指向JIRA的应用程序链接,则您的插件可以使用ApplicationLinkService的getApplicationLinks方法获取该ApplicationLink实例:

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

    Retrieves all ApplicationLinks of a particular ApplicationType.

Next, you can call the createAuthenticatedRequestFactory method on your ApplicationLink instance, eg: 接下来,您可以在ApplicationLink实例上调用createAuthenticatedRequestFactory方法,例如:

ApplicationLinkRequestFactory   createAuthenticatedRequestFactory() 

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

And the RequestFactory makes it possible to send REST requests to the application you're targetting, ie. 通过RequestFactory,可以将REST请求发送到您要定位的应用程序。 JIRA. JIRA。

For more info, you can also check the SAL API documentation which has an example about how to use a RequestFactory . 有关更多信息,您还可以查看SAL API文档,其中包含有关如何使用RequestFactory的示例。

There's also this useful related question on Atlassian Community that explains how you can get a RequestFactory to marshall objects using JAXB. Atlassian社区中还有一个有用的相关问题 ,它解释了如何使用JAXB获取RequestFactory来编组对象。

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

相关问题 如何从请求中获取用户凭据? - How to get user credentials from request? Atlassian插件不会编译,缺少安装包 - Atlassian plugin wont compile, missing packages from install 在Spring中,如何获得其凭据不属于当前http请求的当前用户? - In Spring how do you get the current user whose credentials are not part of the current http request? 如何从插件获取Eclipse的当前语言环境? - How to get current locale of Eclipse from a plugin? 使用当前用户的凭据进行javamail NTLM身份验证 - javamail NTLM authentication using credentials of current user 如何从当前登录的用户获取数据 - How to get data from current logged user 如何从当前用户那里获取角色? - How to get the role from the current user? 如何从 WebFlux 中的 ReactiveSecurityContextHolder 获取当前用户? - How to get current user from ReactiveSecurityContextHolder in WebFlux? 如何从 freemarker 模板中的当前 session 获取当前经过身份验证的用户 - how to get current authenticated user from current session in the freemarker template Eclipse插件从当前打开的文件中获取代码 - Eclipse Plugin Get Code from Current Open File
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM