class AzureClientIdCertificateCredentialFactoryImpl implements AsymmetricKeyCredentialFactory {

    @Override
    public AsymmetricKeyCredential create(String resource) throws GeneralSecurityException {
        // We don't care about the resource in our scenario, so we will ignore it.
        KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());

        try (FileInputStream inputStream = new FileInputStream(
            this.keyStorePath)) {
            keyStore.load(inputStream, this.keyStorePassword.toCharArray());
            // Assuming there is only one entry here.
            String alias = keyStore.aliases().nextElement();
            KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry)keyStore.getEntry(alias,
                new KeyStore.PasswordProtection(this.certificatePassword.toCharArray()));
            AsymmetricKeyCredential credential = AsymmetricKeyCredential.create(
                this.clientId, privateKeyEntry.getPrivateKey(),
                (X509Certificate)privateKeyEntry.getCertificate());
            return credential;
        } catch (IOException e) {
            throw new GeneralSecurityException("Could not load KeyStore file", e);
        }
    }

    public  AzureClientIdCertificateCredentialFactoryImpl(String clientId, String keyStorePath,
                                                         String keyStorePassword,
                                                         String certificatePassword);

}