@Test public void testReadMicrosoft() throws Exception { final Host host = new Host(new DAVProtocol(), "winbuild.iterate.ch", new Credentials( System.getProperties().getProperty("webdav.iis.user"), System.getProperties().getProperty("webdav.iis.password") )); host.setDefaultPath("/WebDAV"); final DAVSession session = new DAVSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); session.getFeature(Touch.class).touch(test, new TransferStatus()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final byte[] content = new RandomStringGenerator.Builder().build().generate(1000).getBytes(); final OutputStream out = local.getOutputStream(false); assertNotNull(out); IOUtils.write(content, out); out.close(); new DAVUploadFeature(new DAVWriteFeature(session)).upload( test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus().length(content.length), new DisabledConnectionCallback()); assertTrue(new MicrosoftIISDAVFindFeature(session).find(test)); assertEquals(content.length, new MicrosoftIISDAVListService(session, new MicrosoftIISDAVAttributesFinderFeature(session)).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L); final TransferStatus status = new TransferStatus(); status.setLength(-1L); final InputStream in = new MicrosoftIISDAVReadFeature(session).read(test, status, new DisabledConnectionCallback()); assertNotNull(in); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length); new StreamCopier(status, status).transfer(in, buffer); final byte[] reference = new byte[content.length]; System.arraycopy(content, 0, reference, 0, content.length); assertArrayEquals(reference, buffer.toByteArray()); in.close(); new DAVDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { return super.read(file, status, callback); } catch(AccessDeniedException e) { headers.clear(); return super.read(file, status, callback); } }
MicrosoftIISDAVReadFeature extends DAVReadFeature { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { return super.read(file, status, callback); } catch(AccessDeniedException e) { headers.clear(); return super.read(file, status, callback); } } }
MicrosoftIISDAVReadFeature extends DAVReadFeature { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { return super.read(file, status, callback); } catch(AccessDeniedException e) { headers.clear(); return super.read(file, status, callback); } } MicrosoftIISDAVReadFeature(final DAVSession session); }
MicrosoftIISDAVReadFeature extends DAVReadFeature { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { return super.read(file, status, callback); } catch(AccessDeniedException e) { headers.clear(); return super.read(file, status, callback); } } MicrosoftIISDAVReadFeature(final DAVSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Set<Header> headers(); }
MicrosoftIISDAVReadFeature extends DAVReadFeature { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { return super.read(file, status, callback); } catch(AccessDeniedException e) { headers.clear(); return super.read(file, status, callback); } } MicrosoftIISDAVReadFeature(final DAVSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Set<Header> headers();  }