public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertNotNull(String name,
Object value)
Assert when the value is null
|
static void |
assertStringNotNullOrEmpty(String name,
String value)
Assert when the String is null or Empty
|
static String |
constructAccountUrl(String scheme,
String host,
int port)
Construct account url from input schema, host and port
|
static KeyPair |
createKeyPairFromPrivateKey(PrivateKey privateKey)
Generate key pair object from private key
|
static Properties |
createProperties(Properties inputProp,
boolean sslEnabled)
Create a Properties for snowflake connection
|
static com.codahale.metrics.Timer.Context |
createTimerContext(com.codahale.metrics.Timer timer)
Create a new timer context if input is not null
|
static Properties |
getPropertiesFromJson(com.fasterxml.jackson.databind.node.ObjectNode json)
Get the properties out from a json node
|
static boolean |
isNullOrEmpty(String string)
Utility function to check whether a streing is null or empty
|
static PrivateKey |
parseEncryptedPrivateKey(String key,
String passphrase)
Parse an encrypted private key
|
static PrivateKey |
parsePrivateKey(String key)
Parse an unencrypted private key
|
static byte[] |
toByteArray(int value)
Convert int value to a byte array
|
static byte[] |
toByteArray(long value)
Convert long value to a byte array
|
public static void assertStringNotNullOrEmpty(String name, String value) throws SFException
name - value - SFExceptionpublic static void assertNotNull(String name, Object value) throws SFException
name - value - SFExceptionpublic static Properties createProperties(Properties inputProp, boolean sslEnabled)
inputProp - input property mapsslEnabled - if ssl is enabledpublic static String constructAccountUrl(String scheme, String host, int port)
public static Properties getPropertiesFromJson(com.fasterxml.jackson.databind.node.ObjectNode json)
public static PrivateKey parsePrivateKey(String key)
key - unencrypted private keypublic static PrivateKey parseEncryptedPrivateKey(String key, String passphrase)
key - encrypted private keypassphrase - private key phrasepublic static KeyPair createKeyPairFromPrivateKey(PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException
privateKey - private keyNoSuchAlgorithmException - if can't create key factory by using RSA algorithmInvalidKeySpecException - if private key or public key is invalidpublic static com.codahale.metrics.Timer.Context createTimerContext(com.codahale.metrics.Timer timer)
public static byte[] toByteArray(long value)
public static byte[] toByteArray(int value)
public static boolean isNullOrEmpty(String string)
Copyright © 2022. All rights reserved.