@Override
    public DescriptiveUrl toDownloadUrl(final Path file, final Sharee sharee, CreateDownloadShareRequest options, final PasswordCallback callback) throws BackgroundException {
        try {
            if(log.isDebugEnabled()) {
                log.debug(String.format("Create download share for %s", file));
            }
            if(null == options) {
                options = new CreateDownloadShareRequest();
                log.warn(String.format("Use default share options %s", options));
            }
            final Long fileid = Long.parseLong(nodeid.getVersionId(file));
            final Host bookmark = session.getHost();
            if(new SDSTripleCryptEncryptorFeature(session, nodeid).isEncrypted(file)) {
                // get existing file key associated with the sharing user
                final FileKey key = new NodesApi(session.getClient()).requestUserFileKey(fileid, null, null);
                final EncryptedFileKey encFileKey = TripleCryptConverter.toCryptoEncryptedFileKey(key);
                final UserKeyPairContainer keyPairContainer = session.getKeyPairForFileKey(encFileKey.getVersion());
                final UserKeyPair userKeyPair = TripleCryptConverter.toCryptoUserKeyPair(keyPairContainer);
                final Credentials passphrase = new TripleCryptKeyPair().unlock(callback, bookmark, userKeyPair);

                final PlainFileKey plainFileKey = Crypto.decryptFileKey(encFileKey, userKeyPair.getUserPrivateKey(), passphrase.getPassword().toCharArray());
                // encrypt file key with a new key pair
                final UserKeyPair pair;
                if(null == options.getPassword()) {
                    pair = Crypto.generateUserKeyPair(session.requiredKeyPairVersion(), callback.prompt(
                            bookmark, LocaleFactory.localizedString("Passphrase", "Cryptomator"),
                            LocaleFactory.localizedString("Provide additional login credentials", "Credentials"), new LoginOptions().icon(session.getHost().getProtocol().disk())
                    ).getPassword().toCharArray());
                }
                else {
                    pair = Crypto.generateUserKeyPair(session.requiredKeyPairVersion(), options.getPassword().toCharArray());
                }
                final EncryptedFileKey encryptedFileKey = Crypto.encryptFileKey(plainFileKey, pair.getUserPublicKey());
                options.setPassword(null);
                options.setKeyPair(TripleCryptConverter.toSwaggerUserKeyPairContainer(pair));
                options.setFileKey(TripleCryptConverter.toSwaggerFileKey(encryptedFileKey));
            }
            final DownloadShare share = new SharesApi(session.getClient()).createDownloadShare(
                    options.nodeId(fileid), StringUtils.EMPTY, null);
            final String help;
            if(null == share.getExpireAt()) {
                help = MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"));
            }
            else {
                final long expiry = share.getExpireAt().getMillis();
                help = MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
                        UserDateFormatterFactory.get().getShortFormat(expiry * 1000)
                );
            }
            final Matcher matcher = Pattern.compile(SDSSession.VERSION_REGEX).matcher(session.softwareVersion().getRestApiVersion());
            if(matcher.matches()) {
                if(new Version(matcher.group(1)).compareTo(new Version("4.26")) < 0) {
                    return new DescriptiveUrl(URI.create(String.format("%s://%s/#/public/shares-downloads/%s",
                            bookmark.getProtocol().getScheme(),
                            bookmark.getHostname(),
                            share.getAccessKey())),
                            DescriptiveUrl.Type.signed, help);
                }
            }
            return new DescriptiveUrl(URI.create(String.format("%s://%s/public/download-shares/%s",
                    bookmark.getProtocol().getScheme(),
                    bookmark.getHostname(),
                    share.getAccessKey())),
                    DescriptiveUrl.Type.signed, help);
        }
        catch(ApiException e) {
            throw new SDSExceptionMappingService(nodeid).map(e);
        }
        catch(CryptoException e) {
            throw new TripleCryptExceptionMappingService().map(e);
        }
    }
@Test(expected = LoginCanceledException.class)
    public void testEncryptedMissingPassword() throws Exception {
        final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
        final Path room = new SDSDirectoryFeature(session, nodeid).createRoom(
                new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
        final Path test = new SDSTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        try {
            final DescriptiveUrl url = new SDSShareFeature(session, nodeid).toDownloadUrl(test,
                    Share.Sharee.world, new CreateDownloadShareRequest()
                            .expiration(new ObjectExpiration().enableExpiration(false))
                            .notifyCreator(false)
                            .sendMail(false)
                            .sendSms(false)
                            .password(null)
                            .mailRecipients(null)
                            .mailSubject(null)
                            .mailBody(null)
                            .maxDownloads(null), new DisabledPasswordCallback());
        }
        finally {
            new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
        }
    }