Jump to content

Recommended Posts

Posted

So I've set up my jasper server to accept PreAuth tokens for authentication and I've verified its working by entering the url with token into my browser and getting into the server. However what I really want to do is be able to embed this in an application using the rest api. The problem I've run into is that while the rest/login service always reaturns the Set-Cookie/JSessionID, using a preauth token only sometimes returns the cookie. Is there a way to use preauth token the same way as the login rest service to get the cookie (consistently)?

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Posted

So weirdly enough I solved this problem by switching from spring rest template to apache HttpClient and it completely solved the problem for me.

  • 10 months later...
Posted

Yeah sure. So what I ended up getting working is using the apache packages for authentication, specifically:

org.apache.http.HttpResponse;org.apache.http.client.HttpClient;org.apache.http.client.methods.HttpGet;org.apache.http.impl.client.DefaultHttpClient;[/code]

Using those packages I did something like this:

    public String init(Integer userId) {        server = cfg.getString("server");        String target = server + "/";        String token = reportAuthorizer.buildToken(userId); // builds my preauth token with user id        String ret = "cookie";        URI uri = UriComponentsBuilder.fromHttpUrl(target).queryParam("pp", token).build().toUri();        HttpClient client = new DefaultHttpClient();        HttpGet req = new HttpGet(uri);        try {            HttpResponse resp = client.execute(req);            ret = resp.getHeaders("Set-Cookie")[0].getValue();        } catch (IOException e) {            LOGGER.error("Error with jasper cookie");            LOGGER.error(e.toString());        }        return ret; //sessionid    }[/code]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...