andante andante - 1 month ago 6x
reST (reStructuredText) Question

Atlassian Confluence communication/authentication between plugins

I'm (new at this) developing a macro plugin that builds on data that an existing plugin provides via its REST api. They would run on the same instance of Confluence, version 5.9.

I cannot use the Java api of the plugin, since it only provides access to a very limited amount of classes, so I decided on using Rest.

Given that the user has already authenticated with Confluence, is there any way to communicate my current user credentials from my plugins Java Rest client to the other one, preferably not using Basic Authentication?

So far, I've tried:

  1. Shared Access Layer - this apparently used to work with the method
    but is deprecated in SAL 3.0.5,
    see SAL Documentation (outdated?) and SAL Version Matrix

  2. ApplicationLink - would allow me to link to another application, but apparently it's not possible to link back to the same Confluence instance

  3. SAL
    - comments on this atlassian answer indicate there might be a way using this, but I can't seem to figure it out (yet).

  4. I've also tried reading up on atlassian documentation and posted a similar question on atlassian answers here. I don't mean to double post, but unfortunately, looking at other questions on that platform, few seem to get answered in a timely fashion so I thought I'd try my luck here.

Thanks for reading, I would appreciate your help on this.


Seems like this isn't a very common problem, but I thought I'd post how we eventually solved this, just in case it's needed again:

public class RestClient {

    private TrustedTokenFactory tokenFactory;

    // [...]
    public String doRequest(HttpClient client, String url) throws Exception {
        TrustedTokenAuthenticator auth = 
           new TrustedTokenAuthenticator(tokenFactory);
        HttpMethod method = auth.makeMethod(client, url);
        try {
             // add request headers, etc... 
             int statusCode = client.executeMethod(method);   
             // be sure to use response data here, catch exceptions...   
        } finally {