@Override
    public void login(final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
        final Credentials credentials = authorizationService.validate();
        try {
            final StringBuilder url = new StringBuilder();
            url.append(host.getProtocol().getScheme().toString()).append("://");
            url.append(host.getProtocol().getDefaultHostname());
            if(!(host.getProtocol().getScheme().getPort() == host.getPort())) {
                url.append(":").append(host.getPort());
            }
            final String context = PathNormalizer.normalize(host.getProtocol().getContext());
            // Custom authentication context
            url.append(context);
            // Determine RestFS URL from service discovery
            final HttpGet request = new HttpGet(url.toString());
            final CloseableHttpResponse response = client.execute(request);
            switch(response.getStatusLine().getStatusCode()) {
                case HttpStatus.SC_OK:
                    final JsonElement element = JsonParser.parseReader(new InputStreamReader(response.getEntity().getContent()));
                    if(element.isJsonObject()) {
                        final JsonObject json = element.getAsJsonObject();
                        final URI uri = URI.create(json.getAsJsonObject("serviceTarget").getAsJsonPrimitive("uri").getAsString());
                        if(log.isInfoEnabled()) {
                            log.info(String.format("Set base path to %s", url));
                        }
                        this.setBasePath(uri.toString());
                    }
                    break;
                default:
                    throw new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(
                            response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()));
            }
            credentials.setUsername(new UserInfoApi(new EueApiClient(this))
                    .userinfoGet(null, null).getAccount().getOsServiceId());
            if(StringUtils.isNotBlank(host.getProperty("pacs.url"))) {
                try {
                    client.execute(new HttpPost(host.getProperty("pacs.url")));
                }
                catch(IOException e) {
                    log.warn(String.format("Ignore failure %s running Personal Agent Context Service (PACS) request", e));
                }
            }
            if(StringUtils.isNotBlank(new HostPreferences(host).getProperty("cryptomator.vault.name.default"))) {
                final Path vault = new Path(new HostPreferences(host).getProperty("cryptomator.vault.name.default"), EnumSet.of(Path.Type.directory));
                try {
                    vaultResourceId = new EueAttributesFinderFeature(this, resourceid).find(vault).getFileId();
                    host.setProperty("cryptomator.enable", String.valueOf(true));
                }
                catch(NotfoundException e) {
                    log.warn(String.format("Disable vault features with no existing vault found at %s", vault));
                    // Disable vault features
                    host.setProperty("cryptomator.enable", String.valueOf(false));
                }
            }
            userShares.set(this.userShares());
        }
        catch(ApiException e) {
            throw new EueExceptionMappingService().map(e);
        }
        catch(HttpResponseException e) {
            throw new DefaultHttpResponseExceptionMappingService().map(e);
        }
        catch(IOException e) {
            throw new DefaultIOExceptionMappingService().map(e);
        }
    }
@Test
    public void testLogin() throws Exception {
        assertNotEquals(StringUtils.EMPTY, session.getHost().getCredentials().getUsername());
    }