Skip to content

Commit

Permalink
Make adal4j test dependency only (#1447)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulvii authored Oct 15, 2020
1 parent 4595495 commit af76d7a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<!-- Driver Dependencies -->
<azure.keyvault.version>4.2.1</azure.keyvault.version>
<azure.identity.version>1.1.3</azure.identity.version>
<azure.adal4j.version>1.6.5</azure.adal4j.version>
<osgi.core.version>6.0.0</osgi.core.version>
<osgi.comp.version>5.0.0</osgi.comp.version>
<antlr.runtime.version>4.7.2</antlr.runtime.version>
Expand All @@ -71,6 +70,7 @@
<bouncycastle.bcpkix.version>1.65</bouncycastle.bcpkix.version>

<!-- JUnit Test Dependencies -->
<azure.adal4j.version>1.6.5</azure.adal4j.version>
<junit.platform.version>[1.3.2, 1.5.2]</junit.platform.version>
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<hikaricp.version>3.4.2</hikaricp.version>
Expand All @@ -89,11 +89,13 @@
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-keys</artifactId>
<version>${azure.keyvault.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>${azure.identity.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>stax</groupId>
Expand All @@ -102,13 +104,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>${azure.adal4j.version}</version>
<optional>true</optional>
</dependency>

<!-- dependencies for ANTLR -->
<dependency>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -152,6 +147,12 @@
</dependency>

<!-- dependencies for running tests -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>${azure.adal4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-console</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ public String toString() {
class ActiveDirectoryAuthentication {
static final String JDBC_FEDAUTH_CLIENT_ID = "7f98cb04-cd1e-40df-9140-3bf7e2cea4db";
static final String AZURE_REST_MSI_URL = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01";
static final String ADAL_GET_ACCESS_TOKEN_FUNCTION_NAME = "ADALGetAccessToken";
static final String ACCESS_TOKEN_IDENTIFIER = "\"access_token\":\"";
static final String ACCESS_TOKEN_EXPIRES_IN_IDENTIFIER = "\"expires_in\":\"";
static final String ACCESS_TOKEN_EXPIRES_ON_IDENTIFIER = "\"expires_on\":\"";
Expand Down Expand Up @@ -4441,7 +4440,7 @@ private SqlFedAuthToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throws SQLSe
while (true) {
if (authenticationString.equalsIgnoreCase(SqlAuthentication.ActiveDirectoryPassword.toString())) {
if (!msalContextExists()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_MSALLMissing"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_MSALMissing"));
throw new SQLServerException(form.format(new Object[] {authenticationString}), null, 0, null);
}
fedAuthToken = SQLServerMSAL4JUtils.getSqlFedAuthToken(fedAuthInfo, user,
Expand Down Expand Up @@ -4505,7 +4504,7 @@ private SqlFedAuthToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throws SQLSe
SQLServerException middleException = new SQLServerException(form.format(msgArgs1),
adalException);

form = new MessageFormat(SQLServerException.getErrString("R_ADALExecution"));
form = new MessageFormat(SQLServerException.getErrString("R_MSALExecution"));
Object[] msgArgs = {user, authenticationString};
throw new SQLServerException(form.format(msgArgs), null, 0, middleException);
}
Expand All @@ -4532,7 +4531,7 @@ private SqlFedAuthToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throws SQLSe
else {
// Check if MSAL4J library is available
if (!msalContextExists()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_DLLandMSALLMissing"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_DLLandMSALMissing"));
Object[] msgArgs = {SQLServerDriver.AUTH_DLL_NAME, authenticationString};
throw new SQLServerException(form.format(msgArgs), null, 0, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ protected Object[][] getContents() {
{"R_keyVaultProviderClientKeyPropertyDescription",
"The client key used to access the Key Vault where the column encryption master key is stored."},
{"R_keyStorePrincipalIdPropertyDescription", "Principal Id of Azure Active Directory."},
{"R_MSALLMissing", "Failed to load MSAL4J Java library for performing {0} authentication."},
{"R_DLLandMSALLMissing",
{"R_MSALMissing", "Failed to load MSAL4J Java library for performing {0} authentication."},
{"R_DLLandMSALMissing",
"Failed to load both {0} and MSAL4J Java library for performing {1} authentication. Please install one of them to proceed."},
{"R_MSITokenFailureImds", "MSI Token failure: Failed to acquire access token from IMDS"},
{"R_MSITokenFailureImdsClientId",
Expand Down

0 comments on commit af76d7a

Please sign in to comment.