chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florent Guillaume ...@nuxeo.com>
Subject Re: SharePoint Base64 decoding error in OpenCMIS
Date Fri, 29 Apr 2011 10:41:52 GMT
OpenCMIS may add headers telling it understands gzip when doing the
request. Other headers could influence the results.

Anyway a network trace tool like wireshark would help you greatly in
diagnosing things.

Florent


On Fri, Apr 29, 2011 at 12:10 AM, Jonathan Lee <johnnyhowey@gmail.com> wrote:
> Hi Florian,
>
> I am using BASIC authentication right now and the file size is only 81
> bytes. Its a text file with some text in it.
>
> I see it in the HttpUtils that it will perform gunzip and base64 if the
> response header C*ontent-Encoding* is *gzip *and Content-Transfer-Encoding
> is *base64*
> *
> *
> However when I implement my own method the response from SharePoint is not
> gzipped and  I didn't perform the gunzip. And with this method The Base64
> decoder will decode without error.
>
>  Here is my code.
>
> //SAME URL that OpenCMIS is requesting
> *URL url = new URL("http://
> [server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=51-512");
> *
> *String method = "GET";*
> *HttpURLConnection connection = (HttpURLConnection)url.openConnection();*
> *connection.setRequestMethod(method);*
> *        *
> *// write auth header*
> *BASE64Encoder encoder = new BASE64Encoder();*
> *String encodedCredential = encoder.encode( ("user" + ":" +
> "password").getBytes() );*
> *connection.setRequestProperty("Authorization", "BASIC " +
> encodedCredential);*
> *        *
> *return new Base64.InputStream(connection.getInputStream());*
> *
> *
> But when I called document.getContentStream(). the same response is however
> gzipped. Therefore gzipped is preformed, and then a bad stream is passed to
> the Base64 decoder?
>
> That is the only difference I can notice right now. I have a feeling the
> response from SharePoint is actually not gzipped. Could that be a problem? I
> don't understand why two of the same request will return two different
> responses. One has C*ontent-Encoding* is *gzip, *and one does not
>
> Thank you so much for your response.
>
> Jonathan Lee
>
>
> On Thu, Apr 28, 2011 at 12:25 PM, Florian Müller <
> florian.mueller@alfresco.com> wrote:
>
>> Hi Jonathan,
>>
>> Are you using NTLM? How big are your documents?
>> We have seen issues with NTLM and documents around 120kb and bigger. The
>> stream is closed on the server side before the content is completely read
>> and leaves you with invalid Base64.
>> The only solution I'm aware of is to avoid NTLM and use basic
>> authentication instead.
>>
>> Florian
>>
>>
>> ----- Original Message -----
>> From: "Jonathan Lee" <johnnyhowey@gmail.com>
>> To: dev@chemistry.apache.org
>> Sent: Thursday, April 28, 2011 8:07:22 PM GMT +00:00 GMT Britain, Ireland,
>> Portugal
>> Subject: SharePoint Base64 decoding error in OpenCMIS
>>
>> Hi all
>>
>> Currently we are trying to use openCMIS 0.3.0 to mount a SharePoint 2010
>> Repository. We have run into an issue when trying to get the content stream
>> of the documents. SharePoint 2010 return the stream with Base64 encoding,
>> and I am aware that
>> org.apache.chemistry.opencmis.client.bindings.spi.atompub.HttpUtils returns
>> a Base64.InputStream if the content encoding type is base64. However there
>> is an error when Base64 is trying to decode the stream. Here is the
>> exception,
>>
>> java.lang.ArrayIndexOutOfBoundsException: -19
>> at
>>
>> org.apache.chemistry.opencmis.commons.impl.Base64.decode4to3(Base64.java:1048)
>> at
>>
>> org.apache.chemistry.opencmis.commons.impl.Base64.access$200(Base64.java:33)
>> at
>>
>> org.apache.chemistry.opencmis.commons.impl.Base64$InputStream.read(Base64.java:1766)
>> at
>>
>> org.apache.chemistry.opencmis.commons.impl.Base64$InputStream.read(Base64.java:1832)
>> at java.io.FilterInputStream.read(Unknown Source)
>>
>> After some debugging I realized the InputStream being decoded is not the
>> correct stream.
>>
>> So instead of using the InputStream I get from calling,
>>
>> *docuemnt.getcontentStream().getStream()*
>>
>>
>> I did my own Http Get Request
>>
>> http://
>>
>> [Server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=48-512
>>
>> and called this to get the InputStream
>>
>> inputStream = new Base64.InputStream(connection.getInputStream());
>>
>> When I pass the inputStream I acquired through my own method to Base64, The
>> decoding works!
>>
>> I am wondering if document.getContentStream().getStream() is returning the
>> correct stream when retrieving from SharePoint. Can anyone share some
>> insight on this problem?
>>
>> Here are some extra information that I think you might want to know.
>>
>> This is the respond header when we call
>> http://
>> [Server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=48-512
>> This
>>
>> Cache-ControlprivateContent-Typetext/plain; charset=utf-8Content-Encoding
>> gzipVaryAccept-EncodingServerMicrosoft-IIS/7.0SPRequestGuid
>> a8bcfa3a-fced-4149-8553-38
>> f40ebad01dSet-CookieWSS_KeepSessionAuthenticated={774a893e-3944-489d-84b1-b861ed338a6f};
>> path=/X-SharePointHealthScore5Content-Transfer-Encodingbase64
>> X-AspNet-Version2.0.50727X-Powered-ByASP.NETMicrosoftSharePointTeamSe...
>> 14.0.0.4762DateThu, 28 Apr 2011 18:28:55 GMTContent-Length1546
>>
>> This is the response body, which is Base64 encoded
>>
>>
>> VGhpcyBpcyBhIFRlc3RpbmcgRG9jdW1lbnQNCg0KVGVzdGluZyBPcGVuQ01JUw0KDQpTaGFyZVBvaW50IDIwMTANCg0KSm9uYXRoYW4gTGVl
>>
>> Any help or insight would be much appreciated!
>>
>> Thanks
>>
>> Jonathan Lee
>>
>



-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87

Mime
View raw message