Skip to content

Commit 095c7ee

Browse files
authored
Managed Identity dev experience improvements (#1936)
* New MSI logic with azure identity * Added new MSI tests * Added DefaultAzureCredential support * Amended MSI exception msg * DefaultAzureCredential tests * Removed deprecated APIs * Major version bump * Revert "Removed deprecated APIs" This reverts commit ecd0a2a. * PR comment changes * Code review changes * Additional CR comment changes; Deprecated get/set msiClientId; Using user property for managed identity client ID * Updated tests * Additonal PR comments * Formatting changes
1 parent bf7adc0 commit 095c7ee

19 files changed

+393
-325
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
apply plugin: 'java'
1313

14-
version = '11.3.0-SNAPSHOT'
14+
version = '12.1.0-SNAPSHOT'
1515
def jreVersion = ""
1616
def testOutputDir = file("build/classes/java/test")
1717
def archivesBaseName = 'mssql-jdbc'

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.microsoft.sqlserver</groupId>
88
<artifactId>mssql-jdbc</artifactId>
9-
<version>11.3.0-SNAPSHOT</version>
9+
<version>12.1.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Microsoft JDBC Driver for SQL Server</name>
@@ -64,7 +64,7 @@
6464
<!-- Driver Dependencies -->
6565
<org.osgi.core.version>6.0.0</org.osgi.core.version>
6666
<azure-security-keyvault-keys.version>4.4.4</azure-security-keyvault-keys.version>
67-
<azure-identity.version>1.5.3</azure-identity.version>
67+
<azure-identity.version>1.7.0-beta.2</azure-identity.version>
6868
<msal.version>1.13.0</msal.version>
6969
<org.osgi.compendium.version>5.0.0</org.osgi.compendium.version>
7070
<antlr-runtime.version>4.9.3</antlr-runtime.version>

src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ final class TDS {
201201
static final int TDS_FEDAUTH_LIBRARY_RESERVED = 0x7F;
202202
static final byte ADALWORKFLOW_ACTIVEDIRECTORYPASSWORD = 0x01;
203203
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTEGRATED = 0x02;
204-
static final byte ADALWORKFLOW_ACTIVEDIRECTORYMSI = 0x03;
204+
static final byte ADALWORKFLOW_ACTIVEDIRECTORYMANAGEDIDENTITY = 0x03;
205205
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTERACTIVE = 0x03;
206+
static final byte ADALWORKFLOW_DEFAULTAZURECREDENTIAL = 0x03;
206207
static final byte ADALWORKFLOW_ACTIVEDIRECTORYSERVICEPRINCIPAL = 0x01; // Using the Password byte as that is the
207208
// closest we have.
208209
static final byte FEDAUTH_INFO_ID_STSURL = 0x01; // FedAuthInfoData is token endpoint URL from which to acquire fed

src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,35 +391,34 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
391391
* boolean value for 'delayLoadingLobs'.
392392
*/
393393
void setDelayLoadingLobs(boolean delayLoadingLobs);
394-
394+
395395
/**
396396
* Sets the name of the preferred type of IP Address.
397397
*
398398
* @param iPAddressPreference
399399
* A String that contains the preferred type of IP Address.
400400
*/
401401
void setIPAddressPreference(String iPAddressPreference);
402-
402+
403403
/**
404404
* Gets the name of the preferred type of IP Address.
405405
*
406406
* @return IPAddressPreference
407-
* A String that contains the preferred type of IP Address.
407+
* A String that contains the preferred type of IP Address.
408408
*/
409409
String getIPAddressPreference();
410410

411411
/**
412-
* Gets the time-to-live for the the cached MSI token
413-
*
414-
* @return time-to-live for the cached MSI token
412+
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
413+
* This method will always return 0 and is for backwards compatibility only.
415414
*/
415+
@Deprecated
416416
int getMsiTokenCacheTtl();
417417

418418
/**
419-
* Sets time-to-live for the the cached MSI token
420-
*
421-
* @param timeToLive
422-
* Changes the setting as per description
419+
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
420+
* This method is a no-op for backwards compatibility only.
423421
*/
422+
@Deprecated
424423
void setMsiTokenCacheTtl(int timeToLive);
425424
}

src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -932,18 +932,24 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
932932
void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert);
933933

934934
/**
935-
* Sets the client id to be used to retrieve access token from MSI EndPoint.
935+
* This method is deprecated. Use {@link ISQLServerDataSource#setUser(String user)} instead.
936+
*
937+
* Sets the client id to be used to retrieve the access token for a user-assigned Managed Identity.
936938
*
937-
* @param msiClientId
938-
* Client ID of User Assigned Managed Identity
939+
* @param managedIdentityClientId
940+
* Client ID of the user-assigned Managed Identity.
939941
*/
940-
void setMSIClientId(String msiClientId);
942+
@Deprecated
943+
void setMSIClientId(String managedIdentityClientId);
941944

942945
/**
946+
* This method is deprecated. Use {@link ISQLServerDataSource#getUser()} instead.
947+
*
943948
* Returns the value for the connection property 'msiClientId'.
944949
*
945950
* @return msiClientId property value
946951
*/
952+
@Deprecated
947953
String getMSIClientId();
948954

949955
/**
@@ -1129,7 +1135,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
11291135
/**
11301136
* Sets the 'AADSecurePrincipalId' connection property used for Active Directory Service Principal authentication.
11311137
*
1132-
* @deprecated Use {@link ISQLServerDataSource#setUser(String password)} instead
1138+
* @deprecated Use {@link ISQLServerDataSource#setUser(String user)} instead
11331139
* @param AADSecurePrincipalId
11341140
* Active Directory Service Principal Id.
11351141
*/
@@ -1208,17 +1214,16 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
12081214
String getPrepareMethod();
12091215

12101216
/**
1211-
* Sets time-to-live for the the cached MSI token
1212-
*
1213-
* @param timeToLive
1214-
* Changes the setting as per description
1217+
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
1218+
* This method is a no-op for backwards compatibility only.
12151219
*/
1220+
@Deprecated
12161221
void setMsiTokenCacheTtl(int timeToLive);
12171222

12181223
/**
1219-
* Gets the time-to-live for the the cached MSI token
1220-
*
1221-
* @return time-to-live for the cached MSI token
1224+
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
1225+
* This method will always return 0 and is for backwards compatibility only.
12221226
*/
1227+
@Deprecated
12231228
int getMsiTokenCacheTtl();
12241229
}

src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
package com.microsoft.sqlserver.jdbc;
77

88
final class SQLJdbcVersion {
9-
static final int major = 11;
10-
static final int minor = 3;
9+
static final int major = 12;
10+
static final int minor = 1;
1111
static final int patch = 0;
1212
static final int build = 0;
1313
/*

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(TokenCredential tokenCrede
274274
* @throws SQLServerException
275275
* when an error occurs
276276
*/
277+
@Deprecated
277278
public SQLServerColumnEncryptionAzureKeyVaultProvider(
278279
SQLServerKeyVaultAuthenticationCallback authenticationCallback) throws SQLServerException {
279280
if (null == authenticationCallback) {

0 commit comments

Comments
 (0)