Class CertificateUtils
dw.crypto
Class CertificateUtils
Object
dw.crypto.CertificateUtils
Utilities for managing certificates and keys.
Constructor Summary
Method Summary
static getCertificate(certificateRef : CertificateRef) : X509Certificate
Gets the certificate from the given certificate reference.
static getCertificate(keyRef : KeyRef) : X509Certificate
Gets the public certificate from the given private key reference.
static getEncodedCertificate(certificateRef : CertificateRef) : String
Encode the certificate to the base64-encoded DER format.
static getEncodedPublicKey(certificateRef : CertificateRef) : String
Gets the public key from the given certificate reference.
static parseEncodedCertificate(certificate : String) : CertificateRef
Parse the certificate from the base64-encoded DER format.
static parseEncodedPublicKey(algorithm : String, encodedKey : String) : CertificateRef
Parse the public key from the given key in X.509 SubjectPublicKeyInfo format.
static parsePublicKeyFromJWK(jwk : String) : CertificateRef
Parse the public key from the given base64-encoded JWK string.
Constructor Detail
CertificateUtils
public CertificateUtils()

Method Detail
getCertificate
static getCertificate(certificateRef : CertificateRef) : X509Certificate
Gets the certificate from the given certificate reference.
Parameters:
certificateRef - the certificate reference
Returns:
The X509Certificate
Throws:
Exception - if the reference is invalid or does not refer to an X.509 certificate

getCertificate
static getCertificate(keyRef : KeyRef) : X509Certificate
Gets the public certificate from the given private key reference.
Parameters:
keyRef - the key reference
Returns:
The X509Certificate
Throws:
Exception - if the reference is invalid or there is no X.509 certificate

getEncodedCertificate
static getEncodedCertificate(certificateRef : CertificateRef) : String
Encode the certificate to the base64-encoded DER format.
Parameters:
certificateRef - the certificate to encode
Returns:
base64-encoded DER certificate

getEncodedPublicKey
static getEncodedPublicKey(certificateRef : CertificateRef) : String
Gets the public key from the given certificate reference.

It is exported in the standard X.509 SubjectPublicKeyInfo format and base64-encoded.

Parameters:
certificateRef - the certificate reference with the public key to encode
Returns:
The encoded public key

parseEncodedCertificate
static parseEncodedCertificate(certificate : String) : CertificateRef
Parse the certificate from the base64-encoded DER format.
Parameters:
certificate - The encoded certificate
Returns:
Reference to the parsed certificate

parseEncodedPublicKey
static parseEncodedPublicKey(algorithm : String, encodedKey : String) : CertificateRef
Parse the public key from the given key in X.509 SubjectPublicKeyInfo format.

The resulting reference contains only the public key. It can be used for cryptographic operations, but not anything that requires the full certificate.

Parameters:
algorithm - The public key algorithm, either EC or RSA
encodedKey - The encoded key
Returns:
Reference to the public key

parsePublicKeyFromJWK
static parsePublicKeyFromJWK(jwk : String) : CertificateRef
Parse the public key from the given base64-encoded JWK string.

This returns the public key portion of the JWK, not the x5c certificate chain.

Only RSA and EC keys are supported.

The resulting reference contains only the public key. It can be used for cryptographic operations, but not anything that requires the full certificate.

Parameters:
jwk - Encoded JWK
Returns:
Reference to the public key