Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgreenbird committed Feb 11, 2021
2 parents 0c9a08c + 9030d88 commit ab9b2f2
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 77 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)

## [9.2.0] Stable Release
### Added
- Added logic to handle multi-factor authentication timeouts during ActiveDirectoryInteractive authentication [#1488](https://github.com/microsoft/mssql-jdbc/pull/1488)

### Fixed issues
- Fixed an issue with high memory allocation during bulk copy [#1475](https://github.com/microsoft/mssql-jdbc/pull/1475)

## [9.1.1] Preview Release
### Added
- Added maxResultBuffer connection property [1431](https://github.com/microsoft/mssql-jdbc/pull/1431)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.4.1.jre14</version>
<version>9.2.0.jre15</version>
</dependency>
```
The driver can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=868287).
Expand Down Expand Up @@ -127,7 +127,7 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.1.1.jre15-preview</version>
<version>9.2.0.jre15-preview</version>
<scope>compile</scope>
</dependency>

Expand All @@ -145,7 +145,7 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.1.1.jre15-preview</version>
<version>9.2.0.jre15-preview</version>
<scope>compile</scope>
</dependency>

Expand All @@ -172,7 +172,7 @@ When setting 'useFmtOnly' property to 'true' for establishing a connection or cr
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.1.1.jre15-preview</version>
<version>9.2.0.jre15-preview</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -212,7 +212,7 @@ Preview releases happen approximately monthly between stable releases. This give
You can see what is going into a future release by monitoring [Milestones](https://github.com/Microsoft/mssql-jdbc/milestones) in the repository.

### Version conventions
Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4, 7.0, 7.2, 7.4, 8.2, 8.4. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5, 7.1, 7.3, 8.1 and so on
Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4, 7.0, 7.2, 7.4, 8.2, 8.4, 9.2. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5, 7.1, 7.3, 8.1 and so on

## Contributors
Special thanks to everyone who has contributed to the project.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

apply plugin: 'java'

version = '9.2.0-SNAPSHOT'
version = '9.3.0-SNAPSHOT'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
Expand Down Expand Up @@ -75,7 +75,7 @@ if(hasProperty('buildProfile') && buildProfile == "jre8") {
}
}

jar.archiveFileName = "${archivesBaseName}-${version}.${jreVersion}.jar"
jar.archiveFileName = "${archivesBaseName}-${version}.${jreVersion}-preview.jar"
jar {
manifest {
attributes 'Title': "Microsoft JDBC Driver ${version} for SQL Server",
Expand Down
2 changes: 1 addition & 1 deletion mssql-jdbc_auth_LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MICROSOFT SOFTWARE LICENSE TERMS
MICROSOFT JDBC DRIVER 9.1 FOR SQL SERVER
MICROSOFT JDBC DRIVER 9.2 FOR SQL SERVER

These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.2.0-SNAPSHOT</version>
<version>9.3.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -57,7 +57,7 @@
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth</excludedGroups>

<!-- Use -preview for preview release, leave empty for official release.-->
<releaseExt></releaseExt>
<releaseExt>-preview</releaseExt>

<!-- Driver Dependencies -->
<azure.keyvault.version>4.2.1</azure.keyvault.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/
@Immutable
class KeyVaultTokenCredential implements TokenCredential {
private static final String NULL_VALUE = "R_NullValue";

private final String clientId;
private final String clientSecret;
private final SQLServerKeyVaultAuthenticationCallback authenticationCallback;
Expand All @@ -48,13 +50,13 @@ class KeyVaultTokenCredential implements TokenCredential {
*/
KeyVaultTokenCredential(String clientId, String clientSecret) throws SQLServerException {
if (null == clientId || clientId.isEmpty()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client ID"};
throw new SQLServerException(form.format(msgArgs1), null);
}

if (null == clientSecret || clientSecret.isEmpty()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client Secret"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand Down Expand Up @@ -116,19 +118,19 @@ KeyVaultTokenCredential setAuthorization(String authorization) {
*/
private ConfidentialClientApplication getConfidentialClientApplication() {
if (null == clientId) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client ID"};
throw new IllegalArgumentException(form.format(msgArgs1), null);
}

if (null == authorization) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Authorization"};
throw new IllegalArgumentException(form.format(msgArgs1), null);
}

if (null == clientSecret) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client Secret"};
throw new IllegalArgumentException(form.format(msgArgs1), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

final class SQLJdbcVersion {
static final int major = 9;
static final int minor = 2;
static final int minor = 3;
static final int patch = 0;
static final int build = 0;
/*
* Used to load mssql-jdbc_auth DLL.
* 1. Set to "-preview" for preview release.
* 2. Set to "" (empty String) for official release.
*/
static final String releaseExt = "";
static final String releaseExt = "-preview";
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
private static final int KEY_NAME_INDEX = 4;
private static final int KEY_URL_SPLIT_LENGTH_WITH_VERSION = 6;
private static final String KEY_URL_DELIMITER = "/";
private static final String NULL_VALUE = "R_NullValue";

private HttpPipeline keyVaultPipeline;
private KeyVaultTokenCredential keyVaultTokenCredential;

Expand Down Expand Up @@ -102,12 +104,12 @@ public String getName() {
*/
public SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId, String clientKey) throws SQLServerException {
if (null == clientId || clientId.isEmpty()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client ID"};
throw new SQLServerException(form.format(msgArgs1), null);
}
if (null == clientKey || clientKey.isEmpty()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client Key"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand Down Expand Up @@ -141,7 +143,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId, String cl
*/
SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId) throws SQLServerException {
if (null == clientId || clientId.isEmpty()) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Client ID"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand All @@ -160,7 +162,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId, String cl
*/
public SQLServerColumnEncryptionAzureKeyVaultProvider(TokenCredential tokenCredential) throws SQLServerException {
if (null == tokenCredential) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Token Credential"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand All @@ -183,7 +185,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(TokenCredential tokenCrede
public SQLServerColumnEncryptionAzureKeyVaultProvider(
SQLServerKeyVaultAuthenticationCallback authenticationCallback) throws SQLServerException {
if (null == authenticationCallback) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"SQLServerKeyVaultAuthenticationCallback"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand All @@ -202,7 +204,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(
*/
private void setCredential(TokenCredential credential) throws SQLServerException {
if (null == credential) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
MessageFormat form = new MessageFormat(SQLServerException.getErrString(NULL_VALUE));
Object[] msgArgs1 = {"Credential"};
throw new SQLServerException(form.format(msgArgs1), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2366,8 +2366,9 @@ private void login(String primary, String primaryInstanceName, int primaryPortNu
+ " Timeout Unit Interval: " + timeoutUnitInterval);
}

boolean isInteractive = (null == authenticationString) ? false : authenticationString
.equalsIgnoreCase(SqlAuthentication.ActiveDirectoryInteractive.toString());
// Returns false if authenticationString is null
boolean isInteractive = SqlAuthentication.ActiveDirectoryInteractive.toString()
.equalsIgnoreCase(authenticationString);

// Initialize loop variables
int attemptNumber = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
class SQLServerMSAL4JUtils {

static final String REDIRECTURI = "http://localhost";
private static final String SLASH_DEFAULT = "/.default";

static final private java.util.logging.Logger logger = java.util.logging.Logger
private static final java.util.logging.Logger logger = java.util.logging.Logger
.getLogger("com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils");

static SqlFedAuthToken getSqlFedAuthToken(SqlFedAuthInfo fedAuthInfo, String user, String password,
Expand All @@ -53,7 +54,7 @@ static SqlFedAuthToken getSqlFedAuthToken(SqlFedAuthInfo fedAuthInfo, String use
.builder(ActiveDirectoryAuthentication.JDBC_FEDAUTH_CLIENT_ID).executorService(executorService)
.authority(fedAuthInfo.stsurl).build();
final CompletableFuture<IAuthenticationResult> future = pca.acquireToken(UserNamePasswordParameters
.builder(Collections.singleton(fedAuthInfo.spn + "/.default"), user, password.toCharArray())
.builder(Collections.singleton(fedAuthInfo.spn + SLASH_DEFAULT), user, password.toCharArray())
.build());

final IAuthenticationResult authenticationResult = future.get();
Expand All @@ -71,10 +72,10 @@ static SqlFedAuthToken getSqlFedAuthTokenPrincipal(SqlFedAuthInfo fedAuthInfo, S
String aadPrincipalSecret, String authenticationString) throws SQLServerException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
String defaultScopeSuffix = "/.default";
String defaultScopeSuffix = SLASH_DEFAULT;
String scope = fedAuthInfo.spn.endsWith(defaultScopeSuffix) ? fedAuthInfo.spn
: fedAuthInfo.spn + defaultScopeSuffix;
Set<String> scopes = new HashSet<String>();
Set<String> scopes = new HashSet<>();
scopes.add(scope);
IClientCredential credential = ClientCredentialFactory.createFromSecret(aadPrincipalSecret);
ConfidentialClientApplication clientApplication = ConfidentialClientApplication
Expand Down Expand Up @@ -114,7 +115,7 @@ static SqlFedAuthToken getSqlFedAuthTokenIntegrated(SqlFedAuthInfo fedAuthInfo,
.authority(fedAuthInfo.stsurl).build();
final CompletableFuture<IAuthenticationResult> future = pca
.acquireToken(IntegratedWindowsAuthenticationParameters
.builder(Collections.singleton(fedAuthInfo.spn + "/.default"), user).build());
.builder(Collections.singleton(fedAuthInfo.spn + SLASH_DEFAULT), user).build());

final IAuthenticationResult authenticationResult = future.get();
return new SqlFedAuthToken(authenticationResult.accessToken(), authenticationResult.expiresOnDate());
Expand All @@ -135,7 +136,7 @@ static SqlFedAuthToken getSqlFedAuthTokenInteractive(SqlFedAuthInfo fedAuthInfo,
PublicClientApplication pca = PublicClientApplication
.builder(ActiveDirectoryAuthentication.JDBC_FEDAUTH_CLIENT_ID).executorService(executorService)
.setTokenCacheAccessAspect(PersistentTokenCacheAccessAspect.getInstance())
.authority(fedAuthInfo.stsurl).logPii((logger.isLoggable(Level.FINE)) ? true : false).build();
.authority(fedAuthInfo.stsurl).logPii((logger.isLoggable(Level.FINE))).build();

CompletableFuture<IAuthenticationResult> future = null;
IAuthenticationResult authenticationResult = null;
Expand All @@ -150,7 +151,7 @@ static SqlFedAuthToken getSqlFedAuthTokenInteractive(SqlFedAuthInfo fedAuthInfo,
logger.fine(logger.toString() + "Silent authentication for user:" + user);
}
SilentParameters silentParameters = SilentParameters
.builder(Collections.singleton(fedAuthInfo.spn + "/.default"), account).build();
.builder(Collections.singleton(fedAuthInfo.spn + SLASH_DEFAULT), account).build();

future = pca.acquireTokenSilently(silentParameters);
}
Expand All @@ -169,7 +170,7 @@ static SqlFedAuthToken getSqlFedAuthTokenInteractive(SqlFedAuthInfo fedAuthInfo,
InteractiveRequestParameters parameters = InteractiveRequestParameters.builder(new URI(REDIRECTURI))
.systemBrowserOptions(SystemBrowserOptions.builder()
.htmlMessageSuccess(SQLServerResource.getResource("R_MSALAuthComplete")).build())
.loginHint(user).scopes(Collections.singleton(fedAuthInfo.spn + "/.default")).build();
.loginHint(user).scopes(Collections.singleton(fedAuthInfo.spn + SLASH_DEFAULT)).build();

future = pca.acquireToken(parameters);
authenticationResult = future.get();
Expand Down
8 changes: 4 additions & 4 deletions src/samples/adaptive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre10</version>
<version>9.2.0.jre15</version>
</dependency>
</dependencies>
<profiles>
Expand Down Expand Up @@ -74,14 +74,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
Expand Down
8 changes: 4 additions & 4 deletions src/samples/alwaysencrypted/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre10</version>
<version>9.2.0.jre15</version>
</dependency>
</dependencies>
<profiles>
Expand All @@ -42,14 +42,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
Expand Down
8 changes: 4 additions & 4 deletions src/samples/azureactivedirectoryauthentication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre10</version>
<version>9.2.0.jre15</version>
</dependency>
</dependencies>
<profiles>
Expand All @@ -41,14 +41,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit ab9b2f2

Please sign in to comment.