Skip to content

Commit

Permalink
Merge branch 'RTW_6.2.0' into metadataCaching
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasSQL authored Jun 16, 2017
2 parents 38da794 + 1da02b5 commit 24913f0
Show file tree
Hide file tree
Showing 53 changed files with 2,539 additions and 677 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
- mssql_jdbc_logging='true'
# Enabling logging with console / file handler for JUnit Test Framework.
#- mssql_jdbc_logging_handler='console'|'file'

#Cache the .m2 folder
cache:
directories:
- $HOME/.m2

install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41
Expand Down
674 changes: 674 additions & 0 deletions AppVeyorJCE/LICENSE

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions AppVeyorJCE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# JCE chocolatey package

### Disclaimers:
1. All contents within this directory originate from [this GitHub project](https://github.com/TobseF/jce-chocolatey-package). This project was added to allow us to test the Always Encrypted feature on AppVeyor builds.

2. This is not an official project of Oracle. It\`s only easy of the manual installation: It downloads the JCE from oracle.com and unpacks it to the installed JDK.


[Chocolatey](https://chocolatey.org/) package for the [JCE (Unlimited Strength Java Cryptography Extension Policy Files)](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html)

This chocolatey package adds the JCE to latest installed Java SDK. The The `JAVA_HOME` environment variable has to point to the JDK. If `JAVA_HOME` is not set, nothing will be changed. The original files are backuped (renamed to `*_old`) and can be reverted at any time. This package is a perfect addion to the [JDK8 package](https://chocolatey.org/packages/jdk8).

#### Install with [Chocolatey](https://chocolatey.org/)
```PowerShell
choco install jce -y
```

#### Build from source:
1. Install [Chocolatey](https://chocolatey.org/).
2. Open cmd with admin rights in jce package directory.
3. Pack NuGet Package (.nupkg).
```PowerShell
cpack
```
4. Install JCE NuGet Package.
```PowerShell
choco install jce -fdv -s . -y
```



28 changes: 28 additions & 0 deletions AppVeyorJCE/jce.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
<id>jce</id>
<title>JCE (Java Cryptography Extension)</title>
<version>7.0.0</version>
<authors>Sun Microsystems/Oracle Corporation</authors>
<owners>Tobse Fritz</owners>
<summary>Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7</summary>
<description>Downloads and installs the Java Cryptography Extension (JCE) to the lastest JDK. The The JAVA_HOME environment variable has to point to the JDK. If JAVA_HOME is not set, nothing will be changed. The original files are backuped (renamed to *_old) and can be reverted at any time.</description>
<projectUrl>https://github.com/TobseF/jce-chocolatey-package</projectUrl>
<tags>java jce admin</tags>
<copyright></copyright>
<licenseUrl>http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>http://cdn.rawgit.com/chocolatey/chocolatey-coreteampackages/50fd97744110dcbce1acde889c0870599c9d5584/icons/java.svg</iconUrl>
<!--<dependencies>
<dependency id="" version="__VERSION__" />
<dependency id="" />
</dependencies>-->
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
15 changes: 15 additions & 0 deletions AppVeyorJCE/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$common = $(Join-Path $script_path "common.ps1")
. $common

#installs JCE
try {
chocolatey-install
} catch {
if ($_.Exception.InnerException) {
$msg = $_.Exception.InnerException.Message
} else {
$msg = $_.Exception.Message
}
throw
}
14 changes: 14 additions & 0 deletions AppVeyorJCE/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$common = $(Join-Path $script_path "common.ps1")
. $common

function Uninstall-ChocolateyPath {
param(
[string] $pathToUninstall,
[System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User
)
Write-Debug "Running 'Uninstall-ChocolateyPath' with pathToUninstall:`'$pathToUninstall`'";

#get the PATH variable
$envPath = $env:PATH
}
85 changes: 85 additions & 0 deletions AppVeyorJCE/tools/common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
$jce_version = '7'
$zipFolder = 'UnlimitedJCEPolicy'
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)

function has_file($filename) {
return Test-Path $filename
}

function download-from-oracle($url, $output_filename) {
if (!(has_file($output_fileName))) {
Write-Host "Downloading JCE from $url"

try {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
$client = New-Object Net.WebClient
$dummy = $client.Headers.Add('Cookie', 'gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie')
$dummy = $client.DownloadFile($url, $output_filename)
} finally {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
}
}
}

function download-jce-file($url, $output_filename) {
$dummy = download-from-oracle $url $output_filename
}

function download-jce() {
$filename = "UnlimitedJCEPolicyJDK$jce_version.zip"
$url = "http://download.oracle.com/otn-pub/java/jce/$jce_version/$filename"
$output_filename = Join-Path $script_path $filename
If(!(Test-Path $output_filename)){
$dummy = download-jce-file $url $output_filename
}
return $output_filename
}

function get-java-home(){
return Get-EnvironmentVariable 'JAVA_HOME' -Scope 'Machine' -PreserveVariables
}

function get-jce-dir($java_home) {
return Join-Path $java_home 'jre\lib\security'
}

function chocolatey-install() {
$java_home = get-java-home
if (!$java_home) {
Write-Host "Couldnt find JAVA_HOME environment variable"
Write-Host "Skipping installation"
}else{
$jce_dir = get-jce-dir $java_home
$already_patched_file = Join-Path $jce_dir 'local_policy_old.jar'

If(Test-Path $already_patched_file){
Write-Host "JCE already installed: $jce_dir"
Write-Host "Skipping installation"
}else{
Write-Host "JCE is not installed ($already_patched_file) is not present"
Write-Host "Starting installation"
install-jce $jce_dir
}
}
}

function install-jce($jce_dir) {
$jce_zip_file = download-jce
$temp_dir = Get-EnvironmentVariable 'TEMP' -Scope User -PreserveVariables
$local_policy = Join-Path $jce_dir 'local_policy.jar'
$export_policy = Join-Path $jce_dir 'US_export_policy.jar'

Write-Host "Downloading JCE ($jce_zip_file)"
Install-ChocolateyZipPackage -PackageName 'jce7' -Url $jce_zip_file -UnzipLocation $temp_dir

If(Test-Path $local_policy){
Rename-Item -Path $local_policy -NewName 'local_policy_old.jar' -Force
}

If(Test-Path $export_policy){
Rename-Item -Path $export_policy -NewName 'US_export_policy_old.jar' -Force
}

$unzippedFolder = Join-Path $temp_dir $zipFolder
Copy-Item $unzippedFolder\*.jar $jce_dir -force
}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SQL Server Team
## Take our survey

Let us know how you think we're doing.

<a href="https://www.surveybuilder.com/s/9TQ1T"><img style="float: right;" height="67" width="156" src="https://meetsstorenew.blob.core.windows.net/contianerhd/survey.png?st=2017-02-17T22%3A03%3A00Z&se=2100-02-18T22%3A03%3A00Z&sp=rl&sv=2015-12-11&sr=b&sig=DJSFoihBptSvO%2BjvWzwpHecf8o5yfAbJoD2qW5oB8tc%3D"></a>

## Status of Most Recent Builds
Expand All @@ -27,10 +28,10 @@ Let us know how you think we're doing.
What's coming next? We will look into adding a more comprehensive set of tests, improving our javadocs, and start developing the next set of features.

## Get Started
* [**Ubuntu + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-ubuntu)
* [**Red Hat + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-rhel)
* [**Mac + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-mac)
* [**Windows + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-windows)
* [**Ubuntu + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java/ubuntu)
* [**Red Hat + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java/rhel)
* [**Mac + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java/mac)
* [**Windows + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java/windows)

## Build
### Prerequisites
Expand Down
13 changes: 12 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ environment:

services:
- mssql2016

install:
- ps: Write-Host 'Installing JCE with powershell'
- ps: cd AppVeyorJCE
- ps: choco pack
- ps: choco install jce -fdv -s . -y -failonstderr
- ps: cd..

cache:
- C:\Users\appveyor\.m2 -> pom.xml

build_script:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42

test_script:
- mvn test -B -Pbuild41
- mvn test -B -Pbuild42
- mvn test -B -Pbuild42
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.8-SNAPSHOT</version>
<version>6.2.0-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/AE.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

package com.microsoft.sqlserver.jdbc;

import java.util.Vector;
import java.util.ArrayList;
import java.util.List;

/**
* Represents a single encrypted value for a CEK. It contains the encrypted CEK,the store type, name,the key path and encryption algorithm.
Expand Down Expand Up @@ -45,19 +46,19 @@ class EncryptionKeyInfo {

/**
* Represents a unique CEK as an entry in the CekTable. A unique (plaintext is unique) CEK can have multiple encrypted CEKs when using multiple CMKs.
* These encrypted CEKs are represented by a member vector.
* These encrypted CEKs are represented by a member ArrayList.
*/
class CekTableEntry {
static final private java.util.logging.Logger aeLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.AE");

Vector<EncryptionKeyInfo> columnEncryptionKeyValues;
List<EncryptionKeyInfo> columnEncryptionKeyValues;
int ordinal;
int databaseId;
int cekId;
int cekVersion;
byte[] cekMdVersion;

Vector<EncryptionKeyInfo> getColumnEncryptionKeyValues() {
List<EncryptionKeyInfo> getColumnEncryptionKeyValues() {
return columnEncryptionKeyValues;
}

Expand Down Expand Up @@ -87,7 +88,7 @@ byte[] getCekMdVersion() {
cekId = 0;
cekVersion = 0;
cekMdVersion = null;
columnEncryptionKeyValues = new Vector<EncryptionKeyInfo>();
columnEncryptionKeyValues = new ArrayList<EncryptionKeyInfo>();
}

int getSize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package com.microsoft.sqlserver.jdbc;

import java.util.logging.Level;

class FedAuthDllInfo {
byte[] accessTokenBytes = null;
long expiresIn = 0;
Expand Down Expand Up @@ -102,7 +104,9 @@ byte[] GenerateClientContext(byte[] pin,
int failure = SNISecGenClientContext(sniSec, sniSecLen, pin, pin.length, pOut, outsize, done, DNSName, port, null, null, authLogger);

if (failure != 0) {
authLogger.warning(toString() + " Authentication failed code : " + failure);
if (authLogger.isLoggable(Level.WARNING)) {
authLogger.warning(toString() + " Authentication failed code : " + failure);
}
con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), linkError);
}
// allocate space based on the size returned
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ else if (SSType.SMALLDATETIME == basicSSType)
return JDBCType.GUID;
if (SSType.VARCHARMAX == basicSSType)
return JDBCType.LONGVARCHAR;
return jdbcType;

default:
return jdbcType;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static final Object convertLongToObject(long longVal,
return new Float(longVal);
case BINARY:
byte[] convertedBytes = convertLongToBytes(longVal);
int bytesToReturnLength = 0;
int bytesToReturnLength;
byte[] bytesToReturn;

switch (baseSSType) {
Expand Down Expand Up @@ -467,7 +467,7 @@ static final Object convertBytesToObject(byte[] bytesValue,

if ((SSType.BINARY == baseTypeInfo.getSSType()) && (str.length() < (baseTypeInfo.getPrecision() * 2))) {

StringBuffer strbuf = new StringBuffer(str);
StringBuilder strbuf = new StringBuilder(str);

while (strbuf.length() < (baseTypeInfo.getPrecision() * 2)) {
strbuf.append('0');
Expand Down Expand Up @@ -781,7 +781,7 @@ static final Object convertTemporalToObject(JDBCType jdbcType,
// For other data types, the date and time parts are assumed to be relative to the local time zone.
TimeZone componentTimeZone = (SSType.DATETIMEOFFSET == ssType) ? UTC.timeZone : localTimeZone;

int subSecondNanos = 0;
int subSecondNanos;

// The date and time parts assume a Gregorian calendar with Gregorian leap year behavior
// over the entire supported range of values. Create and initialize such a calendar to
Expand Down Expand Up @@ -909,7 +909,7 @@ static final Object convertTemporalToObject(JDBCType jdbcType,
default:
throw new AssertionError("Unexpected SSType: " + ssType);
}
int localMillisOffset = 0;
int localMillisOffset;
if (null == timeZoneCalendar) {
TimeZone tz = TimeZone.getDefault();
GregorianCalendar _cal = new GregorianCalendar(componentTimeZone, Locale.US);
Expand Down
Loading

0 comments on commit 24913f0

Please sign in to comment.