Top Description Fields Constructors Methods
com.oracle.bmc.auth.internal

public Class AuthUtils

extends Object
Class Inheritance
Imports
com.oracle.bmc.InternalSdk, com.oracle.bmc.auth.exception.InstancePrincipalUnavailableException, com.oracle.bmc.http.client.Serializer, com.oracle.bmc.http.client.pki.Pem, com.oracle.bmc.util.internal.Validate, org.slf4j.Logger, java.io.IOException, java.math.BigInteger, java.nio.charset.StandardCharsets, java.security.KeyFactory, .MessageDigest, .NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, .X509Certificate, java.security.interfaces.RSAPrivateKey, .RSAPublicKey, java.security.spec.RSAPublicKeySpec, java.util.Base64, .Optional, javax.naming.NamingEnumeration, .NamingException, javax.naming.directory.Attribute, javax.naming.ldap.LdapName, .Rdn, javax.security.auth.x500.X500Principal

Utilities dealing with authorization.

Field Summary

Modifier and TypeField and Description
private static final char[]
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

decoded bytes
base64Decode
(String
base64 string
base64
)

Decode the base64 string.

public static String

Returns:

Base64 representation
base64EncodeNoChunking
(RSAPublicKey
The public key
publicKey
)

Base64 encodes a public key with no chunking.

public static String

Returns:

Base64 representation
base64EncodeNoChunking
(X509Certificate
The certificate
certificate
)

Base64 encodes a X509Certificate with no chunking.

private static String
private static byte[]
pack-priv static byte[]
getEncodedCertificateFromPem(String pemEncodedCertificate)

public static String

Returns:

Fingerprint of the certificate
getFingerPrint
(X509Certificate
the certificate
certificate
)

Gets the fingerprint of a certificate using Sha256.

private static String
getHex(byte[] bytes)

Computes the hex representation of a byte array.

public static String

Returns:

the tenant id.
getTenantIdFromCertificate
(X509Certificate
the given certificate.
certificate
)

Get the tenant id from the given certificate.

private static Optional<String>
getValue(String name, String type, String key)

public static byte[]

Returns:

A new input stream
toByteArrayFromRSAPrivateKey
(RSAPrivateKey
The key to convert.
key
)

Converts a private key back to a PEM formatted input stream.

public static Optional<JWK>

Returns:

Optional of JWK
toJwk
(String
the json string
json
)

Convert JSON string into JWK.

public static Optional<RSAPublicKey>
toPublicKeyFromJson(String json)

Convert JWK JSON string into a RSAPublicKey.

public static Optional<RSAPublicKey>

Returns:

Optional of RSAPublicKey
toPublicKeyFromJwk
(final JWK
the jwk object
jwk
)

Convert JWK into RSAPublicKey.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEX_ARRAYback to summary
private static final char[] HEX_ARRAY
LOGback to summary
private static final Logger LOG

Constructor Detail

AuthUtilsback to summary
private AuthUtils()

Method Detail

base64Decodeback to summary
public static byte[] base64Decode(String base64)

Decode the base64 string. This supports both '+' and '/' as well as '-' and '_'.

Parameters
base64:String

base64 string

Returns:byte[]

decoded bytes

base64EncodeNoChunkingback to summary
public static String base64EncodeNoChunking(RSAPublicKey publicKey)

Base64 encodes a public key with no chunking.

Parameters
publicKey:RSAPublicKey

The public key

Returns:String

Base64 representation

base64EncodeNoChunkingback to summary
public static String base64EncodeNoChunking(X509Certificate certificate) throws CertificateEncodingException

Base64 encodes a X509Certificate with no chunking.

Parameters
certificate:X509Certificate

The certificate

Returns:String

Base64 representation

formatStringWithSeparatorback to summary
private static String formatStringWithSeparator(String fingerprint)
getEncodedCertificateback to summary
private static byte[] getEncodedCertificate(X509Certificate certificate) throws CertificateEncodingException
getEncodedCertificateFromPemback to summary
pack-priv static byte[] getEncodedCertificateFromPem(String pemEncodedCertificate)
getFingerPrintback to summary
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:X509Certificate

the certificate

Returns:String

Fingerprint of the certificate

Exceptions
Error:
if there is an error
getHexback to summary
private static String getHex(byte[] bytes)

Computes the hex representation of a byte array.

getTenantIdFromCertificateback to summary
public static String getTenantIdFromCertificate(X509Certificate certificate)

Get the tenant id from the given certificate.

Parameters
certificate:X509Certificate

the given certificate.

Returns:String

the tenant id.

getValueback to summary
private static Optional<String> getValue(String name, String type, String key)
toByteArrayFromRSAPrivateKeyback to summary
public static byte[] toByteArrayFromRSAPrivateKey(RSAPrivateKey key)

Converts a private key back to a PEM formatted input stream.

Parameters
key:RSAPrivateKey

The key to convert.

Returns:byte[]

A new input stream

Annotations
@InternalSdk
backwardCompatibilityRequired:true
toJwkback to summary
public static Optional<JWK> toJwk(String json)

Convert JSON string into JWK.

Parameters
json:String

the json string

Returns:Optional<JWK>

Optional of JWK

toPublicKeyFromJsonback to summary
public static Optional<RSAPublicKey> toPublicKeyFromJson(String json)

Convert JWK JSON string into a RSAPublicKey.

toPublicKeyFromJwkback to summary
public static Optional<RSAPublicKey> toPublicKeyFromJwk(final JWK jwk)

Convert JWK into RSAPublicKey.

Parameters
jwk:JWK

the jwk object

Returns:Optional<RSAPublicKey>

Optional of RSAPublicKey