Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App veyor jce #328

Merged
merged 6 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ 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