Package com.oracle.bmc.auth.internal
Class AuthUtils
- java.lang.Object
-
- com.oracle.bmc.auth.internal.AuthUtils
-
public class AuthUtils extends Object
Utilities dealing with authorization.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
base64Decode(String base64)
Decode the base64 string.static String
base64EncodeNoChunking(X509Certificate certificate)
Base64 encodes a X509Certificate with no chunking.static String
base64EncodeNoChunking(RSAPublicKey publicKey)
Base64 encodes a public key with no chunking.static String
getFingerPrint(X509Certificate certificate)
Gets the fingerprint of a certificate using Sha256.static String
getTenantIdFromCertificate(X509Certificate certificate)
Get the tenant id from the given certificate.static byte[]
toByteArrayFromRSAPrivateKey(RSAPrivateKey key)
Converts a private key back to a PEM formatted input stream.static Optional<JWK>
toJwk(String json)
Convert JSON string intoJWK
.static Optional<RSAPublicKey>
toPublicKeyFromJson(String json)
Convert JWK JSON string into aRSAPublicKey
.static Optional<RSAPublicKey>
toPublicKeyFromJwk(JWK jwk)
ConvertJWK
intoRSAPublicKey
.
-
-
-
Method Detail
-
getFingerPrint
public static String getFingerPrint(X509Certificate certificate)
Gets the fingerprint of a certificate using Sha256.This is the same value that you would get by running,
openssl x509 -in certificate.pem -noout -fingerprint
- Parameters:
certificate
- the certificate- Returns:
- Fingerprint of the certificate
- Throws:
Error
- if there is an error
-
toPublicKeyFromJson
public static Optional<RSAPublicKey> toPublicKeyFromJson(String json)
Convert JWK JSON string into aRSAPublicKey
.- Returns:
-
toJwk
public static Optional<JWK> toJwk(String json)
Convert JSON string intoJWK
.- Parameters:
json
- the json string- Returns:
- Optional of JWK
-
toPublicKeyFromJwk
public static Optional<RSAPublicKey> toPublicKeyFromJwk(JWK jwk)
ConvertJWK
intoRSAPublicKey
.- Parameters:
jwk
- the jwk object- Returns:
- Optional of RSAPublicKey
-
toByteArrayFromRSAPrivateKey
public static byte[] toByteArrayFromRSAPrivateKey(RSAPrivateKey key)
Converts a private key back to a PEM formatted input stream.- Parameters:
key
- The key to convert.- Returns:
- A new input stream
-
base64EncodeNoChunking
public static String base64EncodeNoChunking(RSAPublicKey publicKey)
Base64 encodes a public key with no chunking.- Parameters:
publicKey
- The public key- Returns:
- Base64 representation
-
base64EncodeNoChunking
public static String base64EncodeNoChunking(X509Certificate certificate) throws CertificateEncodingException
Base64 encodes a X509Certificate with no chunking.- Parameters:
certificate
- The certificate- Returns:
- Base64 representation
- Throws:
CertificateEncodingException
-
base64Decode
public static byte[] base64Decode(String base64)
Decode the base64 string.This supports both ‘+’ and ‘/’ as well as ‘-’ and ‘_’.
- Parameters:
base64
- base64 string- Returns:
- decoded bytes
-
getTenantIdFromCertificate
public static String getTenantIdFromCertificate(X509Certificate certificate)
Get the tenant id from the given certificate.- Parameters:
certificate
- the given certificate.- Returns:
- the tenant id.
-
-