Alfresco - Get file (401 - Unauthorized) Authentication

50 views
Skip to first unread message

Patrícia Sousa

unread,
Nov 20, 2015, 10:06:48 AM11/20/15
to Alfresco Technical Discussion

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?

Patrícia Sousa

unread,
Nov 21, 2015, 9:22:19 AM11/21/15
to Alfresco Technical Discussion
If anyone needs to know, I solve this with this: https://wiki.alfresco.com/wiki/NodeRef_cookbook. More information you can talk with me.
Reply all
Reply to author
Forward
0 new messages