是否可以在Confluence插件中獲取用戶名和密碼? 的Usernam工作對我來說是這樣的:從Atlassian插件獲取當前用戶的證書
ApplicationUser user = userUtil.getUserByName(userManager.getRemoteUsername(request));
我要與當前用戶連接到吉拉REST API。
是否可以在Confluence插件中獲取用戶名和密碼? 的Usernam工作對我來說是這樣的:從Atlassian插件獲取當前用戶的證書
ApplicationUser user = userUtil.getUserByName(userManager.getRemoteUsername(request));
我要與當前用戶連接到吉拉REST API。
由於@Philipp Sander已經評論過,無法檢索用戶的密碼。 Confluence只以加密方式存儲密碼,所以它甚至不知道用戶密碼。
但是,由於您正在討論Confluence插件,因此還有另一種方法可以通過使用應用程序鏈接與其他Atlassian應用程序的REST API進行交談。
如果需要可以讓用戶在他們的合流的應用程序鏈接到JIRA,那麼你的插件可以讓使用ApplicationLinkService的getApplicationLinks方法ApplicationLink例如:
java.lang.Iterable<ApplicationLink> getApplicationLinks(java.lang.Class<? extends ApplicationType> type)
Retrieves all ApplicationLinks of a particular ApplicationType.
接下來,你可以調用createAuthenticatedRequestFactory方法您ApplicationLink實例,如:
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 Community上還有this useful related question,它解釋瞭如何使用JAXB獲取RequestFactory來整理對象。
獲取密碼?這將是一個巨大的安全缺陷。我希望這不起作用。 –