Search in sources :

Example 6 with KeyStoreConfiguration

use of com.microsoft.identity.common.internal.providers.keys.KeyStoreConfiguration in project microsoft-authentication-library-common-for-android by AzureAD.

the class CertificateCredentialBuilder method test_CertificateBuilder_LookupCertificate_IsCorrect.

@Test
public void test_CertificateBuilder_LookupCertificate_IsCorrect() throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, NoSuchProviderException, IOException, CertificateException {
    PowerMockito.mockStatic(KeyStore.class);
    when(KeyStore.getInstance(WINDOWS_MY_KEYSTORE, WINDOWS_KEYSTORE_PROVIDER)).thenReturn(keyStoreMock);
    CertificateCredential cred = new CertificateCredential.CertificateCredentialBuilder(CLIENT_ID).keyStoreConfiguration(new KeyStoreConfiguration(WINDOWS_MY_KEYSTORE, WINDOWS_KEYSTORE_PROVIDER, null)).clientCertificateMetadata(new ClientCertificateMetadata(CERTIFICATE_ALIAS, null)).build();
    assertEquals(privateKey, cred.getPrivateKey());
    assertEquals(certificate, cred.getPublicCertificate());
    assertEquals(CLIENT_ID, cred.getClientId());
}
Also used : CertificateCredential(com.microsoft.identity.common.internal.providers.keys.CertificateCredential) ClientCertificateMetadata(com.microsoft.identity.common.internal.providers.keys.ClientCertificateMetadata) KeyStoreConfiguration(com.microsoft.identity.common.internal.providers.keys.KeyStoreConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with KeyStoreConfiguration

use of com.microsoft.identity.common.internal.providers.keys.KeyStoreConfiguration in project microsoft-authentication-library-common-for-android by AzureAD.

the class CertificateCredentialBuilder method test_CertificateBuilder_NoKeyStoreConfiguration_ExpectException.

@Test(expected = IllegalArgumentException.class)
public void test_CertificateBuilder_NoKeyStoreConfiguration_ExpectException() throws CertificateException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, NoSuchProviderException, IOException {
    PowerMockito.mockStatic(KeyStore.class);
    when(KeyStore.getInstance(WINDOWS_MY_KEYSTORE, WINDOWS_KEYSTORE_PROVIDER)).thenReturn(keyStoreMock);
    CertificateCredential cred = new CertificateCredential.CertificateCredentialBuilder(CLIENT_ID).keyStoreConfiguration(new KeyStoreConfiguration(WINDOWS_MY_KEYSTORE, WINDOWS_KEYSTORE_PROVIDER, null)).build();
}
Also used : CertificateCredential(com.microsoft.identity.common.internal.providers.keys.CertificateCredential) KeyStoreConfiguration(com.microsoft.identity.common.internal.providers.keys.KeyStoreConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

CertificateCredential (com.microsoft.identity.common.internal.providers.keys.CertificateCredential)7 KeyStoreConfiguration (com.microsoft.identity.common.internal.providers.keys.KeyStoreConfiguration)7 Test (org.junit.Test)6 ClientCertificateMetadata (com.microsoft.identity.common.internal.providers.keys.ClientCertificateMetadata)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 MicrosoftClientAssertion (com.microsoft.identity.common.internal.providers.microsoft.MicrosoftClientAssertion)3 ClientException (com.microsoft.identity.common.exception.ClientException)2 MicrosoftStsTokenRequest (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsTokenRequest)2 OAuth2Strategy (com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy)2 OAuth2StrategyParameters (com.microsoft.identity.common.internal.providers.oauth2.OAuth2StrategyParameters)2 TokenRequest (com.microsoft.identity.common.internal.providers.oauth2.TokenRequest)2 TokenResult (com.microsoft.identity.common.internal.providers.oauth2.TokenResult)2 AzureActiveDirectoryOAuth2Configuration (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryOAuth2Configuration)1 AzureActiveDirectoryOAuth2Strategy (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryOAuth2Strategy)1 AzureActiveDirectoryTokenRequest (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryTokenRequest)1 MicrosoftStsOAuth2Configuration (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Configuration)1 MicrosoftStsOAuth2Strategy (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy)1