Skip to content

Commit

Permalink
Renamed driver DefaultAzureCredential authentication to ActiveDirecto…
Browse files Browse the repository at this point in the history
…ryDefault (#2055)
  • Loading branch information
tkyc authored Jan 26, 2023
1 parent 19fe301 commit d842883
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ final class TDS {
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTEGRATED = 0x02;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYMANAGEDIDENTITY = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTERACTIVE = 0x03;
static final byte ADALWORKFLOW_DEFAULTAZURECREDENTIAL = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYDEFAULT = 0x03;
static final byte ADALWORKFLOW_ACCESSTOKENCALLBACK = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYSERVICEPRINCIPAL = 0x01; // Using the Password byte as that is the
// closest we have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ class FederatedAuthenticationFeatureExtensionData implements Serializable {
case "ACTIVEDIRECTORYMANAGEDIDENTITY":
this.authentication = SqlAuthentication.ACTIVE_DIRECTORY_MANAGED_IDENTITY;
break;
case "DEFAULTAZURECREDENTIAL":
this.authentication = SqlAuthentication.DEFAULT_AZURE_CREDENTIAL;
case "ACTIVEDIRECTORYDEFAULT":
this.authentication = SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT;
break;
case "ACTIVEDIRECTORYSERVICEPRINCIPAL":
this.authentication = SqlAuthentication.ACTIVE_DIRECTORY_SERVICE_PRINCIPAL;
Expand Down Expand Up @@ -2467,7 +2467,7 @@ Connection connectInternal(Properties propsIn,
}
authenticationString = SqlAuthentication.valueOfString(sPropValue).toString().trim();

if (authenticationString.equalsIgnoreCase(SqlAuthentication.DEFAULT_AZURE_CREDENTIAL.toString())
if (authenticationString.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT.toString())
&& (!activeConnectionProperties.getProperty(SQLServerDriverStringProperty.PASSWORD.toString())
.isEmpty())) {
MessageFormat form = new MessageFormat(
Expand Down Expand Up @@ -4816,8 +4816,8 @@ int writeFedAuthFeatureRequest(boolean write, /* if false just calculates the le
case ACTIVE_DIRECTORY_MANAGED_IDENTITY:
workflow = TDS.ADALWORKFLOW_ACTIVEDIRECTORYMANAGEDIDENTITY;
break;
case DEFAULT_AZURE_CREDENTIAL:
workflow = TDS.ADALWORKFLOW_DEFAULTAZURECREDENTIAL;
case ACTIVE_DIRECTORY_DEFAULT:
workflow = TDS.ADALWORKFLOW_ACTIVEDIRECTORYDEFAULT;
break;
case ACTIVE_DIRECTORY_INTERACTIVE:
workflow = TDS.ADALWORKFLOW_ACTIVEDIRECTORYINTERACTIVE;
Expand Down Expand Up @@ -5042,7 +5042,7 @@ private void logon(LogonCommand command) throws SQLServerException {
|| ((authenticationString.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_INTEGRATED.toString())
|| authenticationString
.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_MANAGED_IDENTITY.toString())
|| authenticationString.equalsIgnoreCase(SqlAuthentication.DEFAULT_AZURE_CREDENTIAL.toString())
|| authenticationString.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT.toString())
|| authenticationString
.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_SERVICE_PRINCIPAL.toString())
|| authenticationString
Expand Down Expand Up @@ -5778,7 +5778,7 @@ private SqlAuthenticationToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw

// Break out of the retry loop in successful case.
break;
} else if (authenticationString.equalsIgnoreCase(SqlAuthentication.DEFAULT_AZURE_CREDENTIAL.toString())) {
} else if (authenticationString.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT.toString())) {
String managedIdentityClientId = activeConnectionProperties
.getProperty(SQLServerDriverStringProperty.USER.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum SqlAuthentication {
ACTIVE_DIRECTORY_MANAGED_IDENTITY("ActiveDirectoryManagedIdentity"),
ACTIVE_DIRECTORY_SERVICE_PRINCIPAL("ActiveDirectoryServicePrincipal"),
ACTIVE_DIRECTORY_INTERACTIVE("ActiveDirectoryInteractive"),
DEFAULT_AZURE_CREDENTIAL("DefaultAzureCredential");
ACTIVE_DIRECTORY_DEFAULT("ActiveDirectoryDefault");

private final String name;

Expand Down Expand Up @@ -109,8 +109,8 @@ static SqlAuthentication valueOfString(String value) throws SQLServerException {
.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_INTERACTIVE.toString())) {
method = SqlAuthentication.ACTIVE_DIRECTORY_INTERACTIVE;
} else if (value.toLowerCase(Locale.US)
.equalsIgnoreCase(SqlAuthentication.DEFAULT_AZURE_CREDENTIAL.toString())) {
method = SqlAuthentication.DEFAULT_AZURE_CREDENTIAL;
.equalsIgnoreCase(SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT.toString())) {
method = SqlAuthentication.ACTIVE_DIRECTORY_DEFAULT;
} else {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidConnectionSetting"));
Object[] msgArgs = {"authentication", value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ public void testDSManagedIdentityAuthWithManagedIdentityClientId() throws SQLExc
@Tag(Constants.xSQLv14)
@Tag(Constants.xSQLv15)
@Test
public void testDefaultAzureCredentialAuth() throws SQLException {
public void testActiveDirectoryDefaultAuth() throws SQLException {
String connStr = connectionString;
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.USER, managedIdentityClientId);
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.PASSWORD, "");
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "DefaultAzureCredential");
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "ActiveDirectoryDefault");

// With Managed Identity client ID
try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(connStr)) {}
Expand All @@ -189,13 +189,13 @@ public void testDefaultAzureCredentialAuth() throws SQLException {
@Tag(Constants.xSQLv14)
@Tag(Constants.xSQLv15)
@Test
public void testDefaultAzureCredentialAuthDS() throws SQLException {
public void testActiveDirectoryDefaultAuthDS() throws SQLException {
String connStr = connectionString;
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.USER, "");
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.PASSWORD, "");

SQLServerDataSource ds = new SQLServerDataSource();
ds.setAuthentication("DefaultAzureCredential");
ds.setAuthentication("ActiveDirectoryDefault");
ds.setMSIClientId(managedIdentityClientId);
AbstractTest.updateDataSource(connStr, ds);

Expand Down

0 comments on commit d842883

Please sign in to comment.