I have a java program to download file from sharepoint 2010 with NTLM Authentication, it worked well. But when I use this code to download another file from a sharepoint online site, it throws following exception. Does someone have any idea? Thanks.
2021-11-22 10:46:16,269 INFO [org.apache.http.impl.execchain.RetryExec:96] - I/O exception (java.net.SocketException) caught when processing request to {s}->https://xxx.sharepoint.com:443: Connection reset
2021-11-22 10:46:16,269 INFO [org.apache.http.impl.execchain.RetryExec:112] - Retrying request to {s}->https://xxx.sharepoint.com:443
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
Hi
@Ye, Peng
,
NTLM Authentication only support sharepoint on-premise but not sharepoint online. Please refer to following document.
https://learn.microsoft.com/en-us/sharepoint/security-for-sharepoint-server/plan-user-authentication
Since java is out of support scope. I can only provide some similar issue for you:
https://techcommunity.microsoft.com/t5/sharepoint-developer/how-to-connect-to-sharepoint-online-site-to-upload-and-download/m-p/1090942
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our
documentation
to enable e-mail notifications if you want to receive the related email notification for this thread.