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

added gradle Build #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.gradle
.idea
build/**
*/build

# Ignore Gradle build output directory
build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
[submodule "ext/globalplatform-exports"]
path = ext/globalplatform-exports
url = https://github.com/OpenJavaCard/globalplatform-exports.git
[submodule "ext/openjavacard-tools"]
path = ext/openjavacard-tools
url = https://github.com/OpenJavaCard/openjavacard-tools.git
104 changes: 63 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,28 @@ as well as for dynamic tags.

For more information about this overall project, see our [website](https://openjavacard.org/).

You can follow us on [Twitter](https://twitter.com/openjavacardorg) and chat with us on [Gitter](https://gitter.im/openjavacard/general).
You can follow us on [Twitter](https://twitter.com/openjavacardorg) and chat with us
on [Gitter](https://gitter.im/openjavacard/general).

### Build

The project includes [ph4r05/javacard-gradle-plugin](https://github.com/ph4r05/javacard-gradle-plugin) Gradle plugin for
building and installing the applets.

Build the applets:

```shell
# clone the submodules
git submodule update --init --recursive
# build the applets
gradlew buildJavaCard
```

install an applet:

1. set your card reader name in `local.properties`
2. change the installation paramaters in `build.gradle` in the applet subproject to update the ndef payload
3. ```gradlew :$variant_subproject:installJavaCard```

### Documentation

Expand All @@ -23,52 +44,52 @@ You can follow us on [Twitter](https://twitter.com/openjavacardorg) and chat wit

### Variants

| Name | Description | Status |
| ------------ | ---------------------------------------------- | ------------ |
| full | Full features (configured on install) | Stable |
| tiny | Tiny feature set (read-only, static content) | Stable |
| advanced | Full plus GlobalPlatform features | Experiment |
| stub | Stub backed by another service | Experiment |
| Name | Description | Status |
|----------|----------------------------------------------|------------|
| full | Full features (configured on install) | Stable |
| tiny | Tiny feature set (read-only, static content) | Stable |
| advanced | Full plus GlobalPlatform features | Experiment |
| stub | Stub backed by another service | Experiment |

### Features

* Decent code quality
* Load size less than 2 kiB, down to about 1 kiB
* Standard-compliant NDEF reading and writing
* Does not require object deletion support
* Configurable at install time
* Preloading of NDEF data (up to about 200 bytes)
* Configuration of data size
* Configuration of access policies
* Useful access policies
* "Contact only" allows limiting writes to contact interface
* "Write once" allows writing the data file once for provisioning
* Proprietary access policies are hidden from the host,
allowing full reader/writer compatibility.
* Up to 32767 bytes of storage (up to 32765 bytes of NDEF data)
* Default size is 256 bytes to save card memory
* Preloading data automatically sets storage size
* Decent code quality
* Load size less than 2 kiB, down to about 1 kiB
* Standard-compliant NDEF reading and writing
* Does not require object deletion support
* Configurable at install time
* Preloading of NDEF data (up to about 200 bytes)
* Configuration of data size
* Configuration of access policies
* Useful access policies
* "Contact only" allows limiting writes to contact interface
* "Write once" allows writing the data file once for provisioning
* Proprietary access policies are hidden from the host,
allowing full reader/writer compatibility.
* Up to 32767 bytes of storage (up to 32765 bytes of NDEF data)
* Default size is 256 bytes to save card memory
* Preloading data automatically sets storage size

### Status

* Works well with some Android apps on a few cards of mine
* Has been reused by other people successfully
* Feature-complete as far as the standard goes
* No systematic testing has been done
* No systematic review has taken place
* No unit tests have been implemented
* Don't be afraid: it's good stuff
* Developed only in spurts: support-it-yourself
* Works well with some Android apps on a few cards of mine
* Has been reused by other people successfully
* Feature-complete as far as the standard goes
* No systematic testing has been done
* No systematic review has taken place
* No unit tests have been implemented
* Don't be afraid: it's good stuff
* Developed only in spurts: support-it-yourself

### History

* Initial development in 2015
* Developed in a project context
* Considered finished at that point
* First re-issue in early 2018
* Result of some on-the-side hacking
* Not as polished as the initial release (yet)
* Several variants and more versatile
* Initial development in 2015
* Developed in a project context
* Considered finished at that point
* First re-issue in early 2018
* Result of some on-the-side hacking
* Not as polished as the initial release (yet)
* Several variants and more versatile

### Related Projects

Expand Down Expand Up @@ -109,6 +130,7 @@ is.
### Standards

The applet is intended to comply with the following standards, where applicable:
* ISO 7816-4 Organization, security and commands for interchange (Release 2013)
* GlobalPlatform Card Specification (Version 2.1)
* NFC Forum Type 4 Tag Operation Specification (Version 2.0)

* ISO 7816-4 Organization, security and commands for interchange (Release 2013)
* GlobalPlatform Card Specification (Version 2.1)
* NFC Forum Type 4 Tag Operation Specification (Version 2.0)
37 changes: 37 additions & 0 deletions applet-advanced/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version '1.0'

def outputCapName = "${rootProject.name}.${project.name}-${this.version}.cap"
def outputCapFile = file("${project.buildDir}/javacard/${outputCapName}")
def cardReaderName = localProperties.get('jc.reader')

def installArgs = [
'-r', cardReaderName
]


javacard {
defaultKey this.defaultKey
config {
jckit jcHome
debugGpPro true
addImplicitJcardSim false
addImplicitJcardSimJunit false
installGpProArgs = installArgs as List<String>
cap {
packageName "${this.group}.${rootProject.name}.${variant}" // 'xyz.wendland.javacard.pki.isoapplet'
version this.version
aid 'D276000085100211040001'
output outputCapName
applet {
className 'NdefApplet'
aid "D2760000850101"
}
}
}

key {
enc defaultKey
kek defaultKey
mac defaultKey
}
}
39 changes: 39 additions & 0 deletions applet-full/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version '1.0'

def outputCapName = "${rootProject.name}.${project.name}-${this.version}.cap"
def outputCapFile = file("${project.buildDir}/javacard/${outputCapName}")
def cardReaderName = localProperties.get('jc.reader')

def installArgs = [
'-r', cardReaderName,
'-params', '810200F182020800' //from :doc:install.md
]


javacard {
defaultKey this.defaultKey
config {
jckit jcHome
debugGpPro true
addImplicitJcardSim false
addImplicitJcardSimJunit false
installGpProArgs = installArgs as List<String>
cap {
packageName "${this.group}.${rootProject.name}.${variant}"
version this.version
aid 'D276000085100211010001'
output outputCapName
applet {
className 'NdefApplet'
aid "D2760000850101"
}
}
}

key {
enc defaultKey
kek defaultKey
mac defaultKey
}

}
38 changes: 38 additions & 0 deletions applet-stub/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version '1.0'

def outputCapName = "${rootProject.name}.${project.name}-${this.version}.cap"
def outputCapFile = file("${project.buildDir}/javacard/${outputCapName}")
def cardReaderName = localProperties.get('jc.reader')

def installArgs = [
'-r', cardReaderName,
'-params', '3FABCDABCD' //from :doc:install.md
]


javacard {
defaultKey this.defaultKey
config {
jckit jcHome
debugGpPro true
addImplicitJcardSim false
addImplicitJcardSimJunit false
installGpProArgs = installArgs as List<String>
cap {
packageName "${this.group}.${rootProject.name}.${variant}" // 'xyz.wendland.javacard.pki.isoapplet'
version this.version
aid 'D276000085100211020001'
output outputCapName
applet {
className 'NdefApplet'
aid "D2760000850101"
}
}
}

key {
enc defaultKey
kek defaultKey
mac defaultKey
}
}
41 changes: 41 additions & 0 deletions applet-tiny/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version '1.0'

def outputCapName = "${rootProject.name}.${project.name}-${this.version}.cap"
def outputCapFile = file("${project.buildDir}/javacard/${outputCapName}")
def cardReaderName = localProperties.get('jc.reader')

def installArgs = [
'-r', cardReaderName,
'-params', '100BD101075402656E54657374' //from :doc:install.md
]

javacard {
defaultKey this.defaultKey
config {
jckit jcHome
debugGpPro true
addImplicitJcardSim false
addImplicitJcardSimJunit false
installGpProArgs = installArgs as List<String>
cap {
packageName "${this.group}.${rootProject.name}.${variant}" // 'xyz.wendland.javacard.pki.isoapplet'
version this.version
aid 'D276000085100211030001'
output outputCapName
applet {
className 'NdefApplet'
aid "D2760000850101"

}
}
}

key {
enc defaultKey
kek defaultKey
mac defaultKey
}

}


66 changes: 66 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.5/samples
*/

buildscript {
repositories {
jcenter()
mavenCentral()

maven { url "https://javacard.pro/maven" }
maven { url "https://deadcode.me/mvn" }
}
dependencies {
classpath 'com.klinec:gradle-javacard:1.8.0'
}
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { localProperties.load(it) }
}

ext.localProperties = localProperties

ext {
jcHome = rootProject.file(localProperties.getProperty('jc.path', System.getenv('JC_HOME'))).absolutePath
defaultKey = localProperties.getProperty('jc.defaultKey')
}

allprojects {
apply plugin: 'groovy'
group 'org.openjavacard'

sourceCompatibility = 1.8

repositories {
mavenCentral()

maven { url "https://dl.bintray.com/ph4r05/jcard" }
maven { url "https://javacard.pro/maven" }
maven { url "https://deadcode.me/mvn" }
}

project.buildDir rootProject.buildDir
}


subprojects {
if (project.name.startsWith('applet-')) {

apply plugin: "com.klinec.gradle.javacard"
ext.variant = project.name.substring('applet-'.length())
afterEvaluate {
tasks.named('listJavaCard').configure {
doFirst {
args = args + ['-r', localProperties.get('jc.reader')]
}
}

}
}
}
12 changes: 12 additions & 0 deletions client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id 'java'
id 'application'
}

dependencies {
implementation rootProject.project(':ext:openjavacard-tools:common')
}

application {
mainClassName = 'org.openjavacard.ndef.client.Main'
}
1 change: 1 addition & 0 deletions ext/openjavacard-tools
Submodule openjavacard-tools added at 477536
Loading