Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always Encrypted Usability Modifications #902

Merged
merged 5 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,28 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
* @return msiClientId property value
*/
public String getMSIClientId();

/**
* Sets the Azure Key Vault (AKV) Provider Client Id to provided value to be used for column encryption.
*
* @param keyVaultProviderClientId
* Client Id of Azure Key Vault (AKV) Provider to be used for column encryption.
*/
public void setKeyVaultProviderClientId(String keyVaultProviderClientId);

/**
* Returns the value for the connection property 'keyVaultProviderClientId'.
*
* @return keyVaultProviderClientId
*/
public String getKeyVaultProviderClientId();

/**
* Sets the Azure Key Vault (AKV) Provider Client Key to provided value to be used for column encryption.
*
* @param keyVaultProviderClientKey
* Client Key of Azure Key Vault (AKV) Provider to be used for column encryption.
*/
public void setKeyVaultProviderClientKey(String keyVaultProviderClientKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,24 @@ Connection connectInternal(Properties propsIn,

registerKeyStoreProviderOnConnection(keyStoreAuthentication, keyStoreSecret, keyStoreLocation);

if (null == globalCustomColumnEncryptionKeyStoreProviders) {
sPropKey = SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (null != sPropValue) {
String keyVaultColumnEncryptionProviderClientId = sPropValue;
sPropKey = SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_KEY.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (null != sPropValue) {
String keyVaultColumnEncryptionProviderClientKey = sPropValue;
SQLServerColumnEncryptionAzureKeyVaultProvider akvProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(
keyVaultColumnEncryptionProviderClientId, keyVaultColumnEncryptionProviderClientKey);
Map<String, SQLServerColumnEncryptionKeyStoreProvider> keyStoreMap = new HashMap<String, SQLServerColumnEncryptionKeyStoreProvider>();
keyStoreMap.put(akvProvider.getName(), akvProvider);
registerColumnEncryptionKeyStoreProviders(keyStoreMap);
}
}
}

sPropKey = SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (sPropValue == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,24 @@ public String getMSIClientId() {
SQLServerDriverStringProperty.MSI_CLIENT_ID.getDefaultValue());
}

@Override
public void setKeyVaultProviderClientId(String keyVaultProviderClientId) {
setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.toString(),
keyVaultProviderClientId);
}

@Override
public String getKeyVaultProviderClientId() {
return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.toString(),
SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.getDefaultValue());
}

@Override
public void setKeyVaultProviderClientKey(String keyVaultProviderClientKey) {
setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_KEY.toString(),
keyVaultProviderClientKey);
}

/**
* Sets a property string value.
*
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ enum SQLServerDriverStringProperty {
KEY_STORE_SECRET("keyStoreSecret", ""),
KEY_STORE_LOCATION("keyStoreLocation", ""),
SSL_PROTOCOL("sslProtocol", SSLProtocol.TLS.toString()),
MSI_CLIENT_ID("msiClientId", ""),;
MSI_CLIENT_ID("msiClientId", ""),
KEY_VAULT_PROVIDER_CLIENT_ID("keyVaultProviderClientId", ""),
KEY_VAULT_PROVIDER_CLIENT_KEY("keyVaultProviderClientKey", "");

private final String name;
private final String defaultValue;
Expand Down Expand Up @@ -516,7 +518,11 @@ public final class SQLServerDriver implements java.sql.Driver {
Boolean.toString(SQLServerDriverBooleanProperty.USE_BULK_COPY_FOR_BATCH_INSERT.getDefaultValue()),
false, TRUE_FALSE),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.MSI_CLIENT_ID.toString(),
SQLServerDriverStringProperty.MSI_CLIENT_ID.getDefaultValue(), false, null),};
SQLServerDriverStringProperty.MSI_CLIENT_ID.getDefaultValue(), false, null),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.toString(),
SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_ID.getDefaultValue(), false, null),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_KEY.toString(),
SQLServerDriverStringProperty.KEY_VAULT_PROVIDER_CLIENT_KEY.getDefaultValue(), false, null)};

/**
* Properties that can only be set by using Properties. Cannot set in connection string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ protected Object[][] getContents() {
{"R_illegalWKT", "Illegal Well-Known text. Please make sure Well-Known text is valid."},
{"R_illegalTypeForGeometry", "{0} is not supported for Geometry."},
{"R_illegalWKTposition", "Illegal character in Well-Known text at position {0}."},
{"R_keyVaultProviderClientIdPropertyDescription",
"The client ID used to access the Key Vault where the column encryption master key is stored."},
{"R_keyVaultProviderClientKeyPropertyDescription",
"The client key used to access the Key Vault where the column encryption master key is stored."},
{"R_ADALMissing", "Failed to load ADAL4J Java library for performing {0} authentication."},
{"R_DLLandADALMissing",
"Failed to load both sqljdbc_auth.dll and ADAL4J Java library for performing {0} authentication. Please install one of them to proceed."},
Expand Down