All Projects → ph4r05 → javacard-gradle-template

ph4r05 / javacard-gradle-template

Licence: MIT License
JavaCard project template for building CAP and running JCardSim with gradle + coverage

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to javacard-gradle-template

javacard-gradle-plugin
🔑 Gradle plugin for JavaCard development
Stars: ✭ 24 (-11.11%)
Mutual labels:  javacard, javacard-applet, jcardsim, javacard-project
Generate
A new command line tool and developer framework for scaffolding out GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.
Stars: ✭ 238 (+781.48%)
Mutual labels:  project-template, project
Kordamp Gradle Plugins
A collection of Gradle plugins
Stars: ✭ 100 (+270.37%)
Mutual labels:  gradle, project
Projectmaker
A Sublime Text 2/3 plugin to allow creating any kind of project from your own custom templates
Stars: ✭ 233 (+762.96%)
Mutual labels:  project-template, project
Gogradle
A Gradle Plugin Providing Full Support for Go
Stars: ✭ 712 (+2537.04%)
Mutual labels:  coverage, gradle
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (+433.33%)
Mutual labels:  coverage, gradle
go-echo-boilerplate
The fastest way to build a restful API with golang and echo framework. Includes common required features for modern web applications. A boilerplate project with golang and Echo.
Stars: ✭ 53 (+96.3%)
Mutual labels:  coverage, project
project-template
📂 A template for open source projects.
Stars: ✭ 12 (-55.56%)
Mutual labels:  project-template, project
Markdown-Templates
bgoonz.github.io/markdown-templates/
Stars: ✭ 16 (-40.74%)
Mutual labels:  project
HospitalManagementSystem
Hospital management System python
Stars: ✭ 74 (+174.07%)
Mutual labels:  project
SetupBuilder
Gradle plugin for building setups for different platforms.
Stars: ✭ 75 (+177.78%)
Mutual labels:  gradle
TJAPlayer3
A .tja file player.(feat. DTXMania & TJAPlayer2 forPC)
Stars: ✭ 104 (+285.19%)
Mutual labels:  simulator
kotlin multiplatform gradle demo
My attempt to get Gradle to work with multiplatform Kotlin while using subprojects.
Stars: ✭ 24 (-11.11%)
Mutual labels:  gradle
Android-GradlePlugin-Demo
Android Studio 自定义 Gradle Plugin
Stars: ✭ 27 (+0%)
Mutual labels:  gradle
firmware-analysis-plus
Simulate firmware with one click of firmadyne (使用 firmadyne 一键模拟固件)
Stars: ✭ 84 (+211.11%)
Mutual labels:  simulator
spring-boot-angular2-starter
Starter application. Spring Boot, Angular 2, TypeScript, Gulp, Gradle, SCSS.
Stars: ✭ 35 (+29.63%)
Mutual labels:  gradle
Entitas-Java
Entity Component System (ECS) in Java 8
Stars: ✭ 37 (+37.04%)
Mutual labels:  gradle
covviz
Multi-sample genome coverage viewer to observe large, coverage-based anomalies alongside annotations and sample metadata
Stars: ✭ 42 (+55.56%)
Mutual labels:  coverage
AndroidDevTools
收集整理Android开发所需的Android SDK、开发中用到的工具、Android开发教程、Android设计规范,免费的设计素材等。
Stars: ✭ 7,284 (+26877.78%)
Mutual labels:  gradle
springtricks
Sample Project for _40 Tips and Tricks for Spring in IntelliJ IDEA_
Stars: ✭ 37 (+37.04%)
Mutual labels:  intellij-idea

JavaCard Template project with Gradle

Build Status

This is simple JavaCard project template using Gradle build system.

You can develop your JavaCard applets and build cap files with the Gradle! Moreover the project template enables you to test the applet with JCardSim or on the physical cards.

Gradle project contains one module:

  • applet: contains the javacard applet. Can be used both for testing and building CAP

Features:

  • Gradle build (CLI / IntelliJ Idea)
  • Build CAP for applets
  • Test applet code in JCardSim / physical cards
  • IntelliJ Idea: Coverage
  • Travis support

Template

The template contains simple Hello World applet generating random bytes on any APDU message received. There is also implemented very simple test that sends static APDU command to this applet - in JCardSim.

The Gradle project can be opened and run in the IntelliJ Idea.

Running in IntelliJ Idea gives you a nice benefit: Coverage!

How to use

  • Clone this template repository:
git clone --recursive https://github.com/ph4r05/javacard-gradle-template.git
  • Implement your applet in the applet module.

  • Run Gradle wrapper ./gradlew on Unix-like system or ./gradlew.bat on Windows to build the project for the first time (Gradle will be downloaded if not installed).

Building cap

  • Setup your Applet ID (AID) in the ./applet/build.gradle.

  • Run the buildJavaCard task:

./gradlew buildJavaCard  --info --rerun-tasks

Generates a new cap file ./applet/out/cap/applet.cap

Note: --rerun-tasks is to force re-run the task even though the cached input/output seems to be up to date.

Typical output:

[ant:cap] [ INFO: ] Converter [v3.0.5]
[ant:cap] [ INFO: ]     Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
[ant:cap]     
[ant:cap]     
[ant:cap] [ INFO: ] conversion completed with 0 errors and 0 warnings.
[ant:verify] XII 10, 2017 10:45:05 ODP.  
[ant:verify] INFO: Verifier [v3.0.5]
[ant:verify] XII 10, 2017 10:45:05 ODP.  
[ant:verify] INFO:     Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
[ant:verify]     
[ant:verify]     
[ant:verify] XII 10, 2017 10:45:05 ODP.  
[ant:verify] INFO: Verifying CAP file /Users/dusanklinec/workspace/jcard/applet/out/cap/applet.cap
[ant:verify] javacard/framework/Applet
[ant:verify] XII 10, 2017 10:45:05 ODP.  
[ant:verify] INFO: Verification completed with 0 warnings and 0 errors.

Installation on a card

./gradlew installJavaCard

Or inspect already installed applets:

./gradlew listJavaCard

Running tests

./gradlew test --info --rerun-tasks

Output:

Running test: Test method hello(AppletTest)

Gradle suite > Gradle test > AppletTest.hello STANDARD_OUT
    Connecting to card... Done.
    --> [00C00000080000000000000000] 13
    <-- 51373E8B6FDEC284DB569204CA13D2CAA23BD1D85DCAB02A0E3D50461E73F1BB 9000 (32)
    ResponseAPDU: 34 bytes, SW=9000

Dependencies

This project uses mainly:

Kudos for a great work!

JavaCard support

Thanks to Martin Paljak's ant-javacard and oracle_javacard_sdks we support:

  • JavaCard 2.1.2
  • JavaCard 2.2.1
  • JavaCard 2.2.2
  • JavaCard 3.0.3
  • JavaCard 3.0.4
  • JavaCard 3.0.5u1
  • JavaCard 3.1.0b43

Supported Java versions

Java 8-u271 is the minimal version supported.

Make sure you have up to date java version (-u version) as older java 8 versions have problems with recognizing some certificates as valid.

Only some Java versions are supported by the JavaCard SDKs. Check the following compatibility table for more info: https://github.com/martinpaljak/ant-javacard/wiki/Version-compatibility

Coverage

This is a nice benefit of the IntelliJ Idea - gives you coverage results out of the box.

You can see the test coverage on your applet code.

  • Go to Gradle plugin in IntelliJ Idea
  • Tasks -> verification -> test
  • Right click - run with coverage.

Coverage summary: coverage summary

Coverage code: coverage code

Troubleshooting

If you experience the following error:

java.lang.VerifyError: Expecting a stackmap frame at branch target 19
    Exception Details:
      Location:
        javacard/framework/APDU.<init>(Z)V @11: ifeq
      Reason:
        Expected stackmap frame at this location.

Then try running JVM with -noverify option.

In the IntelliJ Idea this can be configured in the top tool bar with run configurations combo box -> click -> Edit Configurations -> VM Options.

However, the com.klinec:jcardsim:3.0.5.11 should not need the -noverify.

Invalid APDU loaded

You may experience error like this: Invalid APDU loaded. You may have JC API in your classpath before JCardSim. Classpath:

This error is thrown by JCardSim which tries to load APDU class augmented with another methods. The augmented APDU version is contained in the JCardSim JAR. However, if api_class.jar from the JavaCard SDK is on the classpath before the JCardSim, this problem occurs. The classpath ordering causes non-augmented version is loaded which prevents JCardSim from correct function.

gradle-javacard-plugin v1.7.4 should fix this error.

If you still experience this in IntelliJ Idea try: open project structure settings -> modules -> applet_test and move JCardSim to the top so it appears first on the classpath. This has to be done with each project reload from the Gradle.

Roadmap

TODOs for this project:

  • Polish Gradle build scripts
  • Add basic libraries as maven dependency.

Contributions

Community feedback is highly appreciated - pull requests are welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].