12-09-2013 08:45 AM
String name = "admin";
String password = "admin";
String authString = name + ":" + password;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
try {
URL url = new URL(aPdfURL);
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
is = urlConnection.getInputStream();
byte[] byteChunk = new byte[READ_CHUNK_SIZE];
int n;
while ((n = is.read(byteChunk)) > 0) {
bais.write(byteChunk, 0, n);
}
pdfAsByteArray = bais.toByteArray();
} catch (Throwable t) {
logger.warn("Failed to retrieve PDF for URL " + aPdfURL, t);
return pdfAsByteArray;
}
C:\temp>curl -v -uadmin:admin http://127.0.0.1:8080/alfresco/d/d/workspace/SpacesStore/57000863-5dbd-4153-9489-36f007a457d4/sample...
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1…
* Adding handle: conn: 0x63adc0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x63adc0) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET /alfresco/d/d/workspace/SpacesStore/57000863-5dbd-4153-9489-36f007a457d4/sampleDoc.pdf HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.32.0
> Host: 127.0.0.1:8080
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=2AB897F5161270BB2BA923CEDFE1C7BD; Path=/alfresco
< Location: http://127.0.0.1:8080/alfresco/faces/jsp/login.jsp?_alfRedirect=%2Falfresco%2Fd%2Fd%2Fworkspace%2FSp...
< Content-Length: 0
< Date: Mon, 09 Dec 2013 14:23:30 GMT
<
* Connection #0 to host 127.0.0.1 left intact
12-09-2013 11:45 AM
12-09-2013 12:26 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.