diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 04d1cd88f..da8a64a46 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -172,11 +172,9 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial private String clientKeyPassword = ""; /** AAD principal id */ - @Deprecated private String aadPrincipalID = ""; /** AAD principal secret */ - @Deprecated private String aadPrincipalSecret = ""; /** sendTemporalDataTypesAsStringForBulkCopy flag */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 32f11171a..ab93a1d8f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -376,9 +376,7 @@ enum SQLServerDriverStringProperty { CLIENT_CERTIFICATE("clientCertificate", ""), CLIENT_KEY("clientKey", ""), CLIENT_KEY_PASSWORD("clientKeyPassword", ""), - @Deprecated AAD_SECURE_PRINCIPAL_ID("AADSecurePrincipalId", ""), - @Deprecated AAD_SECURE_PRINCIPAL_SECRET("AADSecurePrincipalSecret", ""), MAX_RESULT_BUFFER("maxResultBuffer", "-1"); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java index de29d9158..53f34adb6 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java @@ -47,6 +47,9 @@ public class FedauthCommon extends AbstractTest { static boolean enableADIntegrated = false; + static String hostNameInCertificate = null; + static String applicationName = null; + static String kustoServer = null; static String spn = null; static String stsurl = null; static String fedauthClientId = null; @@ -140,6 +143,9 @@ public static void getConfigs() throws Exception { fedauthJksPaths = getConfiguredProperty("fedauthJksPaths", "").split(Constants.SEMI_COLON); fedauthJavaKeyAliases = getConfiguredProperty("fedauthJavaKeyAliases", "").split(Constants.SEMI_COLON); + hostNameInCertificate = getConfiguredProperty("hostNameInCertificate"); + applicationName = getConfiguredProperty("applicationName"); + kustoServer = getConfiguredProperty("kustoServer"); spn = getConfiguredProperty("spn"); stsurl = getConfiguredProperty("stsurl"); fedauthClientId = getConfiguredProperty("fedauthClientId"); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java index 8d8cb5b5d..6a6d16ef9 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java @@ -246,6 +246,29 @@ public void testCorrectAccessTokenDS() throws SQLException { } } + /** + * Test AAD Password Authentication using username/password in connection string, data source and SSL + * encryption, in addition to application name in order to use different authorities. + * + * @throws Exception + * if an exception occurs + */ + @Test + public void testAADPasswordApplicationName() throws Exception { + String url = "jdbc:sqlserver://" + kustoServer + ";database=" + azureDatabase + ";user=" + azureUserName + + ";password=" + azurePassword + ";Authentication=" + + SqlAuthentication.ActiveDirectoryPassword.toString() + ";hostNameInCertificate=" + + hostNameInCertificate + ";applicationName=" + applicationName + + ";encrypt=true;trustServerCertificate=true;"; + SQLServerDataSource ds = new SQLServerDataSource(); + ds.setURL(url); + + try (Connection con = ds.getConnection()) { + } catch (Exception e) { + fail(e.getMessage()); + } + } + /** * Test AAD Service Principal Authentication using AADSecurePrincipalId/AADSecurePrincipalSecret in connection * string, data source and SSL encryption.