AsymmetricKeyCredential Class

  • java.lang.Object
    • com.microsoft.aad.adal4j.AsymmetricKeyCredential

public class AsymmetricKeyCredential

Credential type containing X509 public certificate and RSA private key.

Field Summary

Modifier and Type Field and Description
final int MIN_KEYSIZE_IN_BITS

Method Summary

Modifier and Type Method and Description
AsymmetricKeyCredential create(final String clientId, final InputStream pkcs12Certificate, final String password)

Static method to create KeyCredential instance.

AsymmetricKeyCredential create(final String clientId, final PrivateKey key, final X509Certificate publicCertificate)

Static method to create KeyCredential instance.

String getClientId()

Gets the identifier of the client requesting the token.

PrivateKey getKey()

Returns private key of the credential.

String getPublicCertificate()

Base64 encoded public certificate.

String getPublicCertificateHash()

Base64 encoded hash of the the public certificate.

Field Details

MIN_KEYSIZE_IN_BITS

public static final int MIN_KEYSIZE_IN_BITS= 2048

Method Details

create

public static AsymmetricKeyCredential create(final String clientId, final InputStream pkcs12Certificate, final String password)

Static method to create KeyCredential instance.

Parameters:

clientId - Identifier of the client requesting the token.
pkcs12Certificate - PKCS12 certificate stream containing public and private key. Caller is responsible for handling the input stream.
password - certificate password

Returns:

KeyCredential instance

Throws:

KeyStoreException -

KeyStoreException

NoSuchProviderException -

NoSuchProviderException

NoSuchAlgorithmException -

NoSuchAlgorithmException

CertificateException -

CertificateException

IOException -

IOException

UnrecoverableKeyException -

UnrecoverableKeyException

create

public static AsymmetricKeyCredential create(final String clientId, final PrivateKey key, final X509Certificate publicCertificate)

Static method to create KeyCredential instance.

Parameters:

clientId - Identifier of the client requesting the token.
key - RSA private key to sign the assertion.
publicCertificate - Public certificate used for thumb print.

Returns:

KeyCredential instance

getClientId

public String getClientId()

Gets the identifier of the client requesting the token.

Returns:

string value

getKey

public PrivateKey getKey()

Returns private key of the credential.

Returns:

private key.

getPublicCertificate

public String getPublicCertificate()

Base64 encoded public certificate.

Returns:

base64 encoded string

Throws:

CertificateEncodingException - if an encoding error occurs

getPublicCertificateHash

public String getPublicCertificateHash()

Base64 encoded hash of the the public certificate.

Returns:

base64 encoded string

Throws:

CertificateEncodingException - if an encoding error occurs
NoSuchAlgorithmException - if requested algorithm is not available in the environment

Applies to