class AuthHelper {

    public static FtpProduct fromCurrentSubject() {
        final BackendNodePrincipal principal = JaasUtils.getPrincipal(BackendNodePrincipal.class);
        final BackendNodePasswordCredential credential = JaasUtils
                .getPrivateCredential(BackendNodePasswordCredential.class);
        if (JaasUtils.hasPrincipal(PrivateKeyPrincipal.class)) {
            PrivateKeyPrincipal keyPrincipal = JaasUtils.getPrincipal(PrivateKeyPrincipal.class);
            return KeyCryptoBuilder.getBuilder().setKeySalt(credential.getPassword())
                    .setPrivateKey(URI.create(keyPrincipal.getName()))
                    .setServerAddress(URI.create(principal.getHostname())).setUsername(principal.getUsername()).build();
        }
        return UserPassBuilder.getBuilder().setServerAddress(URI.create(principal.getHostname()))
                .setUsername(principal.getUsername()).setPassword(credential.getPassword()).build();
    }

    private  AuthHelper();

}