public class org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy extends org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.AuthenticationStrategy
{
private final java.lang.String privateKeyVaultReference;
private final java.lang.String passPhraseVaultReference;
private final java.lang.String publicUserName;
public void <init>(java.lang.String, java.lang.String, java.lang.String)
{
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
java.lang.String v, v, v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v := @parameter: java.lang.String;
v := @parameter: java.lang.String;
v := @parameter: java.lang.String;
specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.AuthenticationStrategy: void <init>()>();
v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String privateKeyVaultReference> = v;
v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String passPhraseVaultReference> = v;
v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String publicUserName> = v;
return;
}
public org.eclipse.collections.api.tuple.Pair handleConnection(java.lang.String, java.util.Properties, org.finos.legend.engine.plan.execution.stores.relational.connection.driver.DatabaseManager)
{
org.finos.legend.engine.plan.execution.stores.relational.connection.driver.DatabaseManager v;
java.util.Properties v, v;
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential v;
java.security.PrivateKey v;
java.lang.String v, v, v, v, v;
org.eclipse.collections.api.tuple.Pair v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v := @parameter: java.lang.String;
v := @parameter: java.util.Properties;
v := @parameter: org.finos.legend.engine.plan.execution.stores.relational.connection.driver.DatabaseManager;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String privateKeyVaultReference>;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String passPhraseVaultReference>;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String publicUserName>;
v = specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential resolveCredential(java.util.Properties,java.lang.String,java.lang.String,java.lang.String)>(v, v, v, v);
v = new java.util.Properties;
specialinvoke v.<java.util.Properties: void <init>()>();
virtualinvoke v.<java.util.Properties: void putAll(java.util.Map)>(v);
v = virtualinvoke v.<org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential: java.security.PrivateKey getPrivateKey()>();
virtualinvoke v.<java.util.Properties: java.lang.Object put(java.lang.Object,java.lang.Object)>("privateKey", v);
v = virtualinvoke v.<org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential: java.lang.String getUser()>();
virtualinvoke v.<java.util.Properties: java.lang.Object put(java.lang.Object,java.lang.Object)>("user", v);
v = staticinvoke <org.eclipse.collections.impl.tuple.Tuples: org.eclipse.collections.api.tuple.Pair pair(java.lang.Object,java.lang.Object)>(v, v);
return v;
}
public java.sql.Connection getConnectionImpl(org.finos.legend.engine.plan.execution.stores.relational.connection.ds.DataSourceWithStatistics, org.finos.legend.engine.shared.core.identity.Identity) throws org.finos.legend.engine.plan.execution.stores.relational.connection.ConnectionException
{
org.finos.legend.engine.shared.core.identity.Identity v;
java.sql.SQLException v;
java.sql.Connection v;
org.finos.legend.engine.plan.execution.stores.relational.connection.ds.DataSourceWithStatistics v;
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
javax.sql.DataSource v;
org.finos.legend.engine.plan.execution.stores.relational.connection.ConnectionException v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v := @parameter: org.finos.legend.engine.plan.execution.stores.relational.connection.ds.DataSourceWithStatistics;
v := @parameter: org.finos.legend.engine.shared.core.identity.Identity;
label:
v = virtualinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.ds.DataSourceWithStatistics: javax.sql.DataSource getDataSource()>();
v = interfaceinvoke v.<javax.sql.DataSource: java.sql.Connection getConnection()>();
label:
return v;
label:
v := @caughtexception;
v = new org.finos.legend.engine.plan.execution.stores.relational.connection.ConnectionException;
specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.ConnectionException: void <init>(java.lang.Exception)>(v);
throw v;
catch java.sql.SQLException from label to label with label;
}
public org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.keys.AuthenticationStrategyKey getKey()
{
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.keys.SnowflakePublicAuthenticationStrategyKey v;
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
java.lang.String v, v, v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v = new org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.keys.SnowflakePublicAuthenticationStrategyKey;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String privateKeyVaultReference>;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String passPhraseVaultReference>;
v = v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.lang.String publicUserName>;
specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.keys.SnowflakePublicAuthenticationStrategyKey: void <init>(java.lang.String,java.lang.String,java.lang.String)>(v, v, v);
return v;
}
private org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential resolveCredential(java.util.Properties, java.lang.String, java.lang.String, java.lang.String)
{
java.util.Properties v;
org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager v;
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential v;
org.finos.legend.engine.shared.core.identity.Credential v;
java.security.PrivateKey v;
java.util.Optional v;
java.lang.String v, v, v;
org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.IdentityState v;
boolean v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v := @parameter: java.util.Properties;
v := @parameter: java.lang.String;
v := @parameter: java.lang.String;
v := @parameter: java.lang.String;
v = staticinvoke <org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager: org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager getInstance()>();
v = virtualinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager: org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.IdentityState getIdentityStateUsing(java.util.Properties)>(v);
v = virtualinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.IdentityState: java.util.Optional getCredentialSupplier()>();
v = virtualinvoke v.<java.util.Optional: boolean isPresent()>();
if v != 0 goto label;
v = specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy: java.security.PrivateKey getEncryptedPrivateKey(java.lang.String,java.lang.String)>(v, v);
v = new org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential;
specialinvoke v.<org.finos.legend.engine.shared.core.identity.credential.PrivateKeyCredential: void <init>(java.lang.String,java.security.PrivateKey)>(v, v);
return v;
label:
v = specialinvoke v.<org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.AuthenticationStrategy: org.finos.legend.engine.shared.core.identity.Credential getDatabaseCredential(org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.IdentityState)>(v);
return v;
}
private java.security.PrivateKey getEncryptedPrivateKey(java.lang.String, java.lang.String)
{
byte[] v;
com.google.common.base.Splitter v;
boolean v, v, v;
org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy v;
net.snowflake.client.jdbc.internal.org.bouncycastle.asn.pkcs.PrivateKeyInfo v;
net.snowflake.client.jdbc.internal.org.bouncycastle.asn.x.AlgorithmIdentifier v;
net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter v, v;
java.lang.Exception v;
java.security.KeyFactory v;
java.security.PrivateKey v, v;
net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder v, v;
javax.crypto.SecretKey v;
java.lang.Throwable v;
org.finos.legend.engine.shared.core.vault.Vault v, v;
java.lang.Iterable v;
javax.crypto.SecretKeyFactory v;
javax.crypto.EncryptedPrivateKeyInfo v;
javax.crypto.spec.PBEKeySpec v;
net.snowflake.client.jdbc.internal.org.bouncycastle.asn.ASN1ObjectIdentifier v;
net.snowflake.client.jdbc.internal.org.bouncycastle.operator.InputDecryptorProvider v;
java.lang.String v, v, v, v, v, v, v, v, v, v, v, v;
java.lang.UnsupportedOperationException v;
java.security.spec.PKCS8EncodedKeySpec v;
net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider v;
java.lang.RuntimeException v, v;
java.io.StringReader v;
char[] v, v;
java.lang.Class v;
java.lang.Object v;
net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser v;
v := @this: org.finos.legend.engine.plan.execution.stores.relational.connection.authentication.strategy.SnowflakePublicAuthenticationStrategy;
v := @parameter: java.lang.String;
v := @parameter: java.lang.String;
v = <org.finos.legend.engine.shared.core.vault.Vault: org.finos.legend.engine.shared.core.vault.Vault INSTANCE>;
v = virtualinvoke v.<org.finos.legend.engine.shared.core.vault.Vault: java.lang.String getValue(java.lang.String)>(v);
v = <org.finos.legend.engine.shared.core.vault.Vault: org.finos.legend.engine.shared.core.vault.Vault INSTANCE>;
v = virtualinvoke v.<org.finos.legend.engine.shared.core.vault.Vault: java.lang.String getValue(java.lang.String)>(v);
if v == null goto label;
if v != null goto label;
label:
v = new java.lang.RuntimeException;
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String,java.lang.String)>(v, v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("Can\'t find the privateKey (\u) or the passPhrase (\u) in the vault");
specialinvoke v.<java.lang.RuntimeException: void <init>(java.lang.String)>(v);
throw v;
label:
v = virtualinvoke v.<java.lang.String: boolean startsWith(java.lang.String)>("-----BEGIN ENCRYPTED PRIVATE KEY-----");
if v != 0 goto label;
v = staticinvoke <com.google.common.base.Splitter: com.google.common.base.Splitter fixedLength(int)>(64);
v = virtualinvoke v.<com.google.common.base.Splitter: java.lang.Iterable split(java.lang.CharSequence)>(v);
v = staticinvoke <org.eclipse.collections.impl.utility.Iterate: java.lang.String makeString(java.lang.Iterable,java.lang.String)>(v, "\n");
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.String)>(v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("-----BEGIN ENCRYPTED PRIVATE KEY-----\n\u0001\n-----END ENCRYPTED PRIVATE KEY-----");
label:
v = new net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser;
v = new java.io.StringReader;
specialinvoke v.<java.io.StringReader: void <init>(java.lang.String)>(v);
specialinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser: void <init>(java.io.Reader)>(v);
label:
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser: java.lang.Object readObject()>();
v = v instanceof net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo;
if v == 0 goto label;
v = "1.2.840.113549.1.5.3";
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo: net.snowflake.client.jdbc.internal.org.bouncycastle.asn.x.AlgorithmIdentifier getEncryptionAlgorithm()>();
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.asn.x.AlgorithmIdentifier: net.snowflake.client.jdbc.internal.org.bouncycastle.asn.ASN1ObjectIdentifier getAlgorithm()>();
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.asn.ASN1ObjectIdentifier: java.lang.String toString()>();
v = virtualinvoke v.<java.lang.String: boolean equals(java.lang.Object)>(v);
if v == 0 goto label;
v = virtualinvoke v.<java.lang.String: java.lang.String replace(java.lang.CharSequence,java.lang.CharSequence)>("-----BEGIN ENCRYPTED PRIVATE KEY-----", "");
v = virtualinvoke v.<java.lang.String: java.lang.String replace(java.lang.CharSequence,java.lang.CharSequence)>("-----END ENCRYPTED PRIVATE KEY-----", "");
v = new javax.crypto.EncryptedPrivateKeyInfo;
v = staticinvoke <org.apache.commons.codec.binary.Base64: byte[] decodeBase64(java.lang.String)>(v);
specialinvoke v.<javax.crypto.EncryptedPrivateKeyInfo: void <init>(byte[])>(v);
v = new javax.crypto.spec.PBEKeySpec;
v = virtualinvoke v.<java.lang.String: char[] toCharArray()>();
specialinvoke v.<javax.crypto.spec.PBEKeySpec: void <init>(char[])>(v);
v = virtualinvoke v.<javax.crypto.EncryptedPrivateKeyInfo: java.lang.String getAlgName()>();
v = staticinvoke <javax.crypto.SecretKeyFactory: javax.crypto.SecretKeyFactory getInstance(java.lang.String)>(v);
v = virtualinvoke v.<javax.crypto.SecretKeyFactory: javax.crypto.SecretKey generateSecret(java.security.spec.KeySpec)>(v);
v = virtualinvoke v.<javax.crypto.EncryptedPrivateKeyInfo: java.security.spec.PKCS8EncodedKeySpec getKeySpec(java.security.Key)>(v);
v = staticinvoke <java.security.KeyFactory: java.security.KeyFactory getInstance(java.lang.String)>("RSA");
v = virtualinvoke v.<java.security.KeyFactory: java.security.PrivateKey generatePrivate(java.security.spec.KeySpec)>(v);
label:
virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser: void close()>();
label:
return v;
label:
v = new net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider;
specialinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider: void <init>()>();
staticinvoke <java.security.Security: int addProvider(java.security.Provider)>(v);
v = new net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder;
specialinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder: void <init>()>();
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder: net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder setProvider(java.lang.String)>("BC");
v = virtualinvoke v.<java.lang.String: char[] toCharArray()>();
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder: net.snowflake.client.jdbc.internal.org.bouncycastle.operator.InputDecryptorProvider build(char[])>(v);
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo: net.snowflake.client.jdbc.internal.org.bouncycastle.asn.pkcs.PrivateKeyInfo decryptPrivateKeyInfo(net.snowflake.client.jdbc.internal.org.bouncycastle.operator.InputDecryptorProvider)>(v);
v = new net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
specialinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter: void <init>()>();
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter: net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter setProvider(java.lang.String)>("BC");
v = virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter: java.security.PrivateKey getPrivateKey(net.snowflake.client.jdbc.internal.org.bouncycastle.asn.pkcs.PrivateKeyInfo)>(v);
label:
virtualinvoke v.<net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser: void close()>();
label:
return v;
label:
v = new java.lang.UnsupportedOperationException;
v = virtualinvoke v.<java.lang.Object: java.lang.Class getClass()>();
v = dynamicinvoke "makeConcatWithConstants" <java.lang.String (java.lang.Class)>(v) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("\u is not supported yet");
specialinvoke v.<java.lang.UnsupportedOperationException: void <init>(java.lang.String)>(v);
throw v;
label:
v := @caughtexception;
throw v;
label:
v := @caughtexception;
v = new java.lang.RuntimeException;
specialinvoke v.<java.lang.RuntimeException: void <init>(java.lang.Throwable)>(v);
throw v;
catch java.lang.Throwable from label to label with label;
catch java.lang.Throwable from label to label with label;
catch java.lang.Exception from label to label with label;
catch java.lang.Exception from label to label with label;
}
}