@Override
    public Name getLocation(final Path file) throws BackgroundException {
        if(StringUtils.isNotBlank(session.getHost().getRegion())) {
            return new S3Region(session.getHost().getRegion());
        }
        final Path bucket = containerService.getContainer(file);
        return this.getLocation(bucket.isRoot() ? StringUtils.EMPTY : bucket.getName());
    }
@Test
    public void testForbidden() throws Exception {
        final Host host = new Host(new S3Protocol(), "dist.springframework.org.s3.amazonaws.com", new Credentials(
            PreferencesFactory.get().getProperty("connection.login.anon.name"), null
        ));
        final S3Session session = new S3Session(host);
        final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
            @Override
            public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
                fail(reason);
                return null;
            }
        }, new DisabledHostKeyCallback(),
            new DisabledPasswordStore(), new DisabledProgressListener());
        login.check(session, new DisabledCancelCallback());
        final RegionEndpointCache cache = session.getClient().getRegionEndpointCache();
        assertEquals(unknown, new S3LocationFeature(session, cache).getLocation(new Path("/", EnumSet.of(Path.Type.directory))));
        assertNull(cache.getRegionForBucketName(""));
        assertNull(cache.getRegionForBucketName("dist.springframework.org"));
        session.close();
    }