AnsweredAssumed Answered

Alfresco - Authentication token/ticket httprequest

Question asked by pat9rv3sousa on Nov 20, 2015
Latest reply on Nov 27, 2015 by openpj
I'm trying to access a file that I have on Alfresco, but I always get a 401 error - Unauthorized.

I'm trying to do something like this:

URL url = new URL (filepath);
String userPassword = user + ":" + password;
String encoding = new sun.misc.BASE64Encoder().encode(userPassword.getBytes());
URLConnection connection = url.openConnection();
uc.setRequestProperty("Authorization", "Basic " + encoding);

Then I use connection.getURL() and I open the stream to download the file into a byte[].

Unfortunately, the string userPassword cannot be accessed like this because I don't need to have access to the user and password of the current client that accesses the file. How can I get one token or something else to get authorization?

I make a javascript with connector.get (I think it's the same) but in java I don't find anything.

And other question, after making some modifications, as I return to update the same file?

EDIT: my question is not duplicated because I don't want to give username and password in the java code.