Class ClientAuthenticationUtils
java.lang.Object
org.apache.arrow.driver.jdbc.client.utils.ClientAuthenticationUtils
Utils for
FlightClientHandler
authentication.-
Method Summary
Modifier and TypeMethodDescriptionstatic CredentialCallOption
getAuthenticate
(FlightClient client, String username, String password, ClientIncomingAuthHeaderMiddleware.Factory factory, CallOption... options) Gets theCredentialCallOption
for the provided authentication info.static CredentialCallOption
getAuthenticate
(FlightClient client, CredentialCallOption credential, CallOption... options) Gets theCredentialCallOption
for the provided authentication info.static InputStream
getCertificateInputStreamFromSystem
(String password) It gets the trusted certificate based on the operating system and loads all the certificate into aInputStream
.static InputStream
getCertificateStream
(String keyStorePath, String keyStorePass) Generates anInputStream
that contains certificates for a private key.static InputStream
getClientCertificateStream
(String clientCertificatePath) Generates anInputStream
that contains certificates for a path-based mTLS Client Certificate.static InputStream
getClientKeyStream
(String clientKeyPath) Generates anInputStream
that contains certificates for a path-based mTLS Client Key.static InputStream
getTlsRootCertificatesStream
(String tlsRootsCertificatesPath) Generates anInputStream
that contains certificates for path-based TLS Root Certificates.static boolean
isMac()
Check if the operating system running the software is Mac.static boolean
Check if the operating system running the software is Windows.
-
Method Details
-
getAuthenticate
public static CredentialCallOption getAuthenticate(FlightClient client, CredentialCallOption credential, CallOption... options) Gets theCredentialCallOption
for the provided authentication info.- Parameters:
client
- the client.credential
- the credential as CallOptions.options
- theCallOption
s to use.- Returns:
- the credential call option.
-
getAuthenticate
public static CredentialCallOption getAuthenticate(FlightClient client, String username, String password, ClientIncomingAuthHeaderMiddleware.Factory factory, CallOption... options) Gets theCredentialCallOption
for the provided authentication info.- Parameters:
client
- the client.username
- the username.password
- the password.factory
- theClientIncomingAuthHeaderMiddleware.Factory
to use.options
- theCallOption
s to use.- Returns:
- the credential call option.
-
isWindows
public static boolean isWindows()Check if the operating system running the software is Windows.- Returns:
- whether is the windows system.
-
isMac
public static boolean isMac()Check if the operating system running the software is Mac.- Returns:
- whether is the mac system.
-
getCertificateInputStreamFromSystem
public static InputStream getCertificateInputStreamFromSystem(String password) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException It gets the trusted certificate based on the operating system and loads all the certificate into aInputStream
.- Returns:
- An input stream with all the certificates.
- Throws:
KeyStoreException
- if a key store could not be loaded.CertificateException
- if a certificate could not be found.IOException
- if it fails reading the file.NoSuchAlgorithmException
-
getCertificateStream
public static InputStream getCertificateStream(String keyStorePath, String keyStorePass) throws GeneralSecurityException, IOException Generates anInputStream
that contains certificates for a private key.- Parameters:
keyStorePath
- The path of the KeyStore.keyStorePass
- The password of the KeyStore.- Returns:
- a new {code InputStream} containing the certificates.
- Throws:
GeneralSecurityException
- on error.IOException
- on error.
-
getTlsRootCertificatesStream
public static InputStream getTlsRootCertificatesStream(String tlsRootsCertificatesPath) throws GeneralSecurityException, IOException Generates anInputStream
that contains certificates for path-based TLS Root Certificates.- Parameters:
tlsRootsCertificatesPath
- The path of the TLS Root Certificates.- Returns:
- a new {code InputStream} containing the certificates.
- Throws:
GeneralSecurityException
- on error.IOException
- on error.
-
getClientCertificateStream
public static InputStream getClientCertificateStream(String clientCertificatePath) throws GeneralSecurityException, IOException Generates anInputStream
that contains certificates for a path-based mTLS Client Certificate.- Parameters:
clientCertificatePath
- The path of the mTLS Client Certificate.- Returns:
- a new {code InputStream} containing the certificates.
- Throws:
GeneralSecurityException
- on error.IOException
- on error.
-
getClientKeyStream
public static InputStream getClientKeyStream(String clientKeyPath) throws GeneralSecurityException, IOException Generates anInputStream
that contains certificates for a path-based mTLS Client Key.- Parameters:
clientKeyPath
- The path of the mTLS Client Key.- Returns:
- a new {code InputStream} containing the certificates.
- Throws:
GeneralSecurityException
- on error.IOException
- on error.
-