を私がこのクラスを定義することによって、作業何かを持っているに近いだそうです:。
class WindowsStoreCertificateCredentials(clientId: String, certificate: X509Certificate, privateKey: PrivateKey) extends KeyVaultCredentials {
def getAuthResult(authority: String, resource: String): AuthenticationResult = {
val service = Executors.newFixedThreadPool(1)
val context = new AuthenticationContext(authority, false, service)
val certificateCredentials = AsymmetricKeyCredential.create(clientId, privateKey, certificate)
val authResultFuture = context.acquireToken(resource, certificateCredentials, null)
authResultFuture.get
}
override def doAuthenticate (authority: String, resource: String, scope: String): String = {
getAuthResult(authority, resource).getAccessToken
}
}
そして、それを使用しようとjava.security.KeyStoreクラスを使用して証明書X509Certificateオブジェクトと秘密鍵を取得した後:
val client = new KeyVaultClient(new WindowsStoreCertificateCredentials(
id, privateKey, certificate,))
val test = client.getSecret("https:/...")
残念ながら、それは例外が発生します:
sun.security.mscapi.RSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateKey java.lang.ClassCastException: sun.security.mscapi.RSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateKey
私は
編集... /紺碧-のActiveDirectory-ライブラリ用-javaのgithubのAzureAD上の問題を開き、継続する、それを修正するためにプル要求を提案した。これは今では固定されています。 AzureAD/azure-activedirectory-library-for-javaのバージョン1.2.0。
Azureアプリケーションがないので、このコンストラクタを使用できないようです。 Azureのドキュメントを具体的に指すには、https://docs.microsoft.com/en-us/azure/key-vault/key-vault-use-from-web-applicationと同じ操作をしようとしています。クライアントシークレットの代わりに証明書で認証する " – CanardMoussant