@Override
    protected CloudBlobClient connect(final ProxyFinder proxyfinder, final HostKeyCallback callback, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
        try {
            // Client configured with no credentials
            final URI uri = new URI(String.format("%s://%s", Scheme.https, host.getHostname()));
            final CloudBlobClient client = new CloudBlobClient(uri,
                    new StorageCredentialsAccountAndKey(host.getCredentials().getUsername(), "null"));
            client.setDirectoryDelimiter(String.valueOf(Path.DELIMITER));
            context.setLoggingEnabled(true);
            context.setLogger(LoggerFactory.getLogger(log.getName()));
            context.setUserHeaders(new HashMap<>(Collections.singletonMap(
                    HttpHeaders.USER_AGENT, new PreferencesUseragentProvider().get()))
            );
            context.getSendingRequestEventHandler().addListener(listener = new StorageEvent<SendingRequestEvent>() {
                @Override
                public void eventOccurred(final SendingRequestEvent event) {
                    if(event.getConnectionObject() instanceof HttpsURLConnection) {
                        final HttpsURLConnection connection = (HttpsURLConnection) event.getConnectionObject();
                        connection.setSSLSocketFactory(new CustomTrustSSLProtocolSocketFactory(trust, key));
                        connection.setHostnameVerifier(new DisabledX509HostnameVerifier());
                    }
                }
            });
            final Proxy proxy = proxyfinder.find(new ProxyHostUrlProvider().get(host));
            switch(proxy.getType()) {
                case SOCKS: {
                    if(log.isInfoEnabled()) {
                        log.info(String.format("Configured to use SOCKS proxy %s", proxyfinder));
                    }
                    final java.net.Proxy socksProxy = new java.net.Proxy(
                            java.net.Proxy.Type.SOCKS, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
                    context.setProxy(socksProxy);
                    break;
                }
                case HTTP:
                case HTTPS: {
                    if(log.isInfoEnabled()) {
                        log.info(String.format("Configured to use HTTP proxy %s", proxyfinder));
                    }
                    final java.net.Proxy httpProxy = new java.net.Proxy(
                            java.net.Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
                    context.setProxy(httpProxy);
                    break;
                }
            }
            return client;
        }
        catch(URISyntaxException e) {
            throw new LoginFailureException(e.getMessage(), e);
        }
    }
@Test(expected = LoginCanceledException.class)
    public void testConnectInvalidKey() throws Exception {
        final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials(
                PROPERTIES.get("azure.user"), "6h9BmTcabGajIE/AVGzgu9JcC15JjrzkjdAIe+2daRK8XlyVdYT6zHtFMwXOtrlCw74jX9R0w4GN56vKQjOpVA=="
        ));
        final AzureSession session = new AzureSession(host);
        new LoginConnectionService(new DisabledLoginCallback() {
            @Override
            public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) throws LoginCanceledException {
                assertEquals("Login kahy9boj3eib.blob.core.windows.net", title);
                assertEquals("Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. Please contact your web hosting service provider for assistance.", reason);
                return super.prompt(bookmark, username, title, reason, options);
            }
        }, new DisabledHostKeyCallback(),
                new DisabledPasswordStore(), new DisabledProgressListener()).connect(session, new DisabledCancelCallback());
    }