@Test public void requestsAuthorization() throws Exception { final String[] hosts = { "example.com", "maven.s3auth.com", }; for (final String name : hosts) { try { new SecuredHost( new HostMocker().mock(), HttpRequestMocker.toRequest( String.format("GET / HTTP/1.1\nHost: %s\n\n", name) ) ).fetch(URI.create("/"), Range.ENTIRE, Version.LATEST); Assert.fail("exception expected"); } catch (final HttpException ex) { MatcherAssert.assertThat( HttpResponseMocker.toString(ex.response()), Matchers.allOf( Matchers.containsString(HttpHeaders.WWW_AUTHENTICATE), Matchers.containsString( String.format("Basic realm=\"%s\"", name) ) ) ); } } }
@Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats(); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats();  }