GithubHelp home page GithubHelp logo

bertrandmartel / javacard-gradle-plugin Goto Github PK

View Code? Open in Web Editor NEW
32.0 10.0 13.0 149 KB

:key: Gradle plugin for JavaCard development

License: MIT License

Groovy 100.00%
javacard gradle-plugin groovy smartcard jcardsim gradle javacard-applet javacard-project

javacard-gradle-plugin's Introduction

JavaCard Gradle plugin

Build Status Download Maven Central Coverage Status Javadoc License

A Gradle plugin for building JavaCard applets.

This plugin is a wrapper on ant-javacard and Global Platform Pro, it is inspired by gradle-javacard

Features

  • build JavaCard applets (with the same capabilities as ant-javacard)
  • install cap files
  • list applets
  • write quick testing scripts used to send apdu in a configurable way
  • expose GpExec task type that enables usage of Global Platform Pro tool inside Gradle
  • include jcardsim 3.0.4 and JUnit 4.12 test dependency (clear distinction between JavaCard SDK & jcardsim SDK)
  • ability to specify key for delete/install/list tasks
  • possibility to add dependency between modules (exp & jar imported automatically)

Usage

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'fr.bmartel:gradle-javacard:1.5.6'
    }
}

apply plugin: 'javacard'

dependencies {
    compile 'com.github.martinpaljak:globalplatformpro:18.09.14'
}

javacard {

    config {
        
        cap {
            packageName 'fr.bmartel.javacard'
            version '0.1'
            aid '01:02:03:04:05:06:07:08:09'
            output 'applet.cap'
            applet {
                className 'fr.bmartel.javacard.HelloWorld'
                aid '01:02:03:04:05:06:07:08:09:01:02'
            }
        }
    }
          
    scripts {
        script {
            name 'select'
            apdu '00:A4:04:00:0A:01:02:03:04:05:06:07:08:09:01:00'
        }
        script {
            name 'hello'
            apdu '00:40:00:00:00'
        }
        task {
            name 'sendHello'
            scripts 'select', 'hello'
        }
    }
}

plugin is available from jcenter() or mavenCentral()

Check this project for more usage examples

JavaCard SDK path

The path to JavaCard SDK can be specified through :

  • use jc.home properties in local.properties file located in your project root (in the same way as Android projects) :
    • in project root : echo "jc.home=$PWD/oracle_javacard_sdks/jc222_kit" >> local.properties
  • using jckit attribute (see ant-javacard)
  • JC_HOME global environment variable, for instance using : export JC_HOME="$PWD/sdks/jck222_kit"

Tasks

task name description
buildJavaCard build JavaCard cap files
installJavaCard delete existing aid & install all JavaCard cap files (gp --delete XXXX --install file.cap)
listJavaCard list applets (gp -l)

It's possible to create custom tasks that will send series of custom apdu :

scripts {
    script {
        name 'select'
        apdu '00:A4:04:00:0A:01:02:03:04:05:06:07:08:09:01:00'
    }
    script {
        name 'hello'
        apdu '00:40:00:00:00'
    }
    task {
        name 'sendHello'
        scripts 'select', 'hello'
    }
}

The above will create task sendHello that will select applet ID 01:02:03:04:05:06:07:08:09:01 and send the apdu 00:40:00:00:00.
The order of the scripts's apdu in task.scripts is respected.
00:A4:04:00:0A:01:02:03:04:05:06:07:08:09:01:00 or '00A404000A0102030405060708090100' are valid apdu.

Custom Global Platform Pro task

You can build custom tasks that launch Global Platform Pro tool :

task displayHelp(type: fr.bmartel.javacard.gp.GpExec) {
    description = 'display Global Platform pro help'
    group = 'help'
    args '-h'
}

More complex example

apply plugin: 'javacard'

dependencies {
    compile 'com.github.martinpaljak:globalplatformpro:18.09.14'
}

repositories {
    maven {
        url 'http://dl.bintray.com/bertrandmartel/maven'
    }
}

javacard {

    config {
        jckit '../oracle_javacard_sdks/jc222_kit'
        cap {
            packageName 'fr.bmartel.javacard'
            version '0.1'
            aid '01:02:03:04:05:06:07:08:09'
            output 'applet1.cap'
            applet {
                className 'fr.bmartel.javacard.HelloSmartcard'
                aid '01:02:03:04:05:06:07:08:09:01:02'
            }
            applet {
                className 'fr.bmartel.javacard.GoodByeSmartCard'
                aid '01:02:03:04:05:06:07:08:09:01:03'
            }
        }
        cap {
            packageName 'fr.bmartel.javacard'
            version '0.1'
            aid '01:02:03:04:05:06:07:08:0A'
            output 'applet2.cap'
            applet {
                className 'fr.bmartel.javacard.SomeOtherClass'
                aid '01:02:03:04:05:06:07:08:09:01:04'
            }
            dependencies {
                local {
                    jar '/path/to/dependency.jar'
                    exps '/path/to/expfolder'
                }
                remote 'fr.bmartel:gplatform:2.1.1'
            }
        }
    }
    
    defaultKey '40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F'
    // or 
    /*
    key {
        enc '40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F'
        kek '40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F' 
        mac '40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F' 
    }
    */

    scripts {
        script {
            name 'select'
            apdu '00:A4:04:00:0A:01:02:03:04:05:06:07:08:09:01:00'
        }
        script {
            name 'hello'
            apdu '00:40:00:00:00'
        }
        task {
            name 'sendHello'
            scripts 'select', 'hello'
        }
    }
}

Note1 : the remote dependency will automatically download the jar (the jar file must include the exp file)
Note2 : you can add as many local or remote dependency as you want

Syntax

  • javacard [Closure]
    • config [Closure] - object that holds build configuration Required
      • jckit [String] - path to the JavaCard SDK that is used if individual cap does not specify one. Optional if cap defines one, required otherwise. The path is relative to the module
      • logLevel [String] - log level of ant-javacard task ("VERBOSE","DEBUG","INFO","WARN","ERROR"). default : "INFO"
      • cap [Closure] - construct a CAP file Required
        • jckit [String] - path to the JavaCard SDK to be used for this CAP. Optional if javacard defines one, required otherwise
        • sources [String] - path to Java source code, to be compiled against the current JavaCard SDK. Required
        • findSources [boolean] - default:true, if true the sources are determined automatically. The first existing source dir in source sets is taken
        • defaultSources [boolean] - default:true, if true the first source dir from the source set is used. Otherwise the most recet (last)
        • classes [String] - path to pre-compiled class files to be assembled into a CAP file. If both classes and sources are specified, compiled class files will be put to classes folder, which is created if missing
        • packageName [String] - name of the package of the CAP file. Optional - set to the parent package of the applet class if left unspecified.
        • version [String] - version of the package. Optional - defaults to 0.0 if left unspecified.
        • aid [String] - AID (hex) of the package. Recommended - or set to the 5 first bytes of the applet AID if left unspecified.
        • output [String] - path where to save the generated CAP file. if a filename or a non-absolute path is referenced, the output will be in build/javacard/{output} Required
        • export [String] - path (folder) where to place the JAR and generated EXP file. Default output directory is build/javacard. Filename depends on output filename if referenced. Optional.
        • jca [String] - path where to save the generated JavaCard Assembly (JCA) file. Default output directory is build/javacard. Filename depends on output filename if referenced. Optional.
        • verify [boolean] - if set to false, disables verification of the resulting CAP file with offcardeverifier. Optional.
        • debug [boolean] - if set to true, generates debug CAP components. Optional.
        • ints [boolean] - if set to true, enables support for 32 bit int type. Optional.
        • applet [Closure] - for creating an applet inside the CAP
          • className [String] - class of the Applet where install() method is defined. Required
          • aid [String] - AID (hex) of the applet. Recommended - or set to package aid+i where i is index of the applet definition in the build.xml instruction
        • dependencies [Closure] - for linking against external components/libraries, like GPSystem or OPSystem
          • local [Closure] local dependencies must include absolute path to exp/jar
            • exps [String] - path to the folder keeping .exp files. Required
            • jar [String] - path to the JAR file for compilation. Optional - only required if using sources mode and not necessary with classes mode if java code is already compiled
          • remote [String] remote dependencies (ex: "group:module:1.0").the remote repository (maven repo) must be included in the project
    • key [Closure] key configuration (if not defined the default keys will be used)
      • enc [String] ENC key
      • kek [String] KEK key
      • mac [String] MAC key
    • defaultKey [String] default key used (will be used for enc, kek and mac key if not specified in key closure)
    • scripts [Closure] - object that holds the configurable scripts to send apdu
      • script [Closure] - a script referenced by name/apdu value to be sent
        • name [String] - script name (ex: select)
        • apdu [String] - apdu value to be sent (it can hold ":" to separate bytes)
      • task [Closure] - gradle task to create that will map the specified list of apdu to send
        • name [String] - task name
        • scripts [String...] - list of script's name
    • test [Closure] - additional configuration for tests(*)
      • dependencies [Closure] - holds test dependencies
        • compile [String] - add a dependencies (ex: 'junit:junit:4.12')

(*) If you specify at least one dependency, jcardsim & junit won't be automatically added so you will need to add them manually if you need them for example :

test {
    dependencies {
        compile 'junit:junit:4.12'
        compile 'com.licel:jcardsim:3.0.4'
    }
}

Compatibility

This plugin has been tested on following IDE :

  • IntelliJ IDEA
  • Android Studio
  • Eclipse

Recommended IDE : IntelliJ IDEA or Android Studio

License

The MIT License (MIT) Copyright (c) 2017-2018 Bertrand Martel

javacard-gradle-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javacard-gradle-plugin's Issues

Depend on another module

How can I build an applet that depends on sources in a different module?

dependencies {
    compile project(':common')
} 

This works fine when running the applet in the simulator but cannot find symbols (in common) when building a cap file.

Alternatively: How do build a java card library with export files as a module in gradle?

GPTool task ClassNotFoundException: com.payneteasy.tlv.BerTlvParser error

Hi,

I have started working with this gradle plugin and I must say, it's great. Compiling CAP files within IntelliJ is a breeze.

One issue I have come across though with 1.6.1 which I see both yourself and ph4r05 work on together is that GPTool task do run run with the following error

Exception in thread "main" java.lang.NoClassDefFoundError: com/payneteasy/tlv/BerTlvParser
	at pro.javacard.gp.GlobalPlatform.discover(GlobalPlatform.java:148)
	at pro.javacard.gp.GPTool.main(GPTool.java:373)
Caused by: java.lang.ClassNotFoundException: com.payneteasy.tlv.BerTlvParser
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

After checking the gradle-javacard-1.6.1.jar file I do see that indeed the class is missing. Checking a local build of GPTool myself and the BerTlvParser classes are bundles inside GPTool.

Thanks
CCob

Deprecated gradle features

Running gradle --warning-mode all build shows:

$ gradle --warning-mode all

> Configure project :
The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.6.1/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
The testCompile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the testImplementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.6.1/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations

On my side I changed the dependencies to compileOnly instead and the warning persists.

package version build error

can not build with package version 3.11 but it build with package version 3.9 or 3.8........
javacard {

config {
    jckit './ext/java_card_kit-2_2_2-linux/java_card_kit-2_2_2'
    cap {
        packageName 'com.sample'
        version '3.11'
        aid 'A0:00:00:01:51:41:43:4C:00:FF:FF:89:4D:53:53:00'
        output 'applet.cap'
        applet {
            className 'com.sample.MyApplet'
            aid 'A0:00:00:01:51:41:43:4C:00:FF:FF:89:4D:53:53:01'
        }
        dependencies {
            local {
                exps './ext/exps'
                jar './ext/lib/sim_v5.6.0.jar'
            }
        }
    }
}

}

return Incorrect package version: 3.11

Dependencies not working

I am trying to use your plugin in favor of the fidesmo one because yours supports library dependencies.

Unfortunately, this does not seem to be working. I have declared two libraries and one applet with some simple dependencies between them. The builds for all of them do not seem to have correct build dependencies, so the build fails unless it is executed specifically in dependency order.

My project can be found here:
https://github.com/OpenJavaCard/openjavacard-coap

There are several problems with this build:

  • the "build" target does not depend on "buildJavaCard"
  • the varios "buildJavaCard" targets do not reflect project dependencies

The following will not build JavaCard files:
$ ./gradlew clean build

The following will fail because of missing library dependencies:
$ ./gradlew clean buildJavaCard

The following does work:
$ ./gradlew clean library-core:buildJavaCard library-server:buildJavaCard applet-server-tiny:buildJavaCard

Am I doing something wrong?

Symbol conflict (?) between api_classic.jar and jcardsim.jar

When using jcardsim (latest master 3.0.5-SNAPSHOT) with javacard-gradle-plugin's :test task, all cases fail with weird reflection error like this:

java.lang.RuntimeException: Internal reflection error
	at com.licel.jcardsim.base.SimulatorRuntime.<init>(SimulatorRuntime.java:95)
	at com.licel.jcardsim.base.SimulatorRuntime.<init>(SimulatorRuntime.java:75)
	at com.licel.jcardsim.smartcardio.CardSimulator.<init>(CardSimulator.java:44)
	at illegal.security.chip.TestSuite.setup(TestSuite.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.licel.jcardsim.base.SimulatorRuntime.<init>(SimulatorRuntime.java:85)
	... 43 more

Quick search on their issue tracker and found this: licel/jcardsim#143. Looks like there are some conflicting issues going on.

Does not support javacard.security.Signature.ALG_ECDSA_SHA_256?

I want to crypto test using ALG_ECDSA_SHA_256.
However, TestSuite.setup failed when the flag included.

18:30:13.895 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class test.javacard.TestSuite
18:30:13.896 [DEBUG] [TestEventLogger]
18:30:13.896 [DEBUG] [TestEventLogger] test.javacard.TestSuite STARTED
18:30:14.108 [DEBUG] [TestEventLogger]
18:30:14.108 [DEBUG] [TestEventLogger] test.javacard.TestSuite > classMethod STARTED
18:30:14.109 [INFO] [org.gradle.api.internal.tasks.testing.worker.TestWorker] Gradle Test Executor 1 finished executing tests.
18:30:14.111 [DEBUG] [org.gradle.process.internal.worker.child.ActionExecutionWorker] Completed Gradle Test Executor 1.
18:30:14.124 [DEBUG] [TestEventLogger]
18:30:14.124 [DEBUG] [TestEventLogger] test.javacard.TestSuite > classMethod FAILED
18:30:14.124 [DEBUG] [TestEventLogger]     javacard.framework.SystemException
18:30:14.125 [DEBUG] [TestEventLogger]         at javacard.framework.SystemException.throwIt(Unknown Source)
18:30:14.125 [DEBUG] [TestEventLogger]         at com.licel.jcardsim.base.Simulator.createApplet(Simulator.java:179)
18:30:14.125 [DEBUG] [TestEventLogger]         at com.licel.jcardsim.base.Simulator.installApplet(Simulator.java:219)
18:30:14.125 [DEBUG] [TestEventLogger]         at com.licel.jcardsim.base.Simulator.installApplet(Simulator.java:195)
18:30:14.125 [DEBUG] [TestEventLogger]         at test.javacard.TestSuite.setup(TestSuite.java:105)
18:30:14.125 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:30:14.125 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:30:14.125 [DEBUG] [TestEventLogger]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:30:14.126 [DEBUG] [TestEventLogger]         at java.lang.reflect.Method.invoke(Method.java:498)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
18:30:14.126 [DEBUG] [TestEventLogger]         at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
18:30:14.127 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:30:14.127 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:30:14.127 [DEBUG] [TestEventLogger]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:30:14.127 [DEBUG] [TestEventLogger]         at java.lang.reflect.Method.invoke(Method.java:498)
18:30:14.127 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
18:30:14.127 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
18:30:14.127 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
18:30:14.127 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
18:30:14.127 [DEBUG] [TestEventLogger]         at com.sun.proxy.$Proxy3.processTestClass(Unknown Source)
18:30:14.128 [DEBUG] [TestEventLogger]         at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
18:30:14.128 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:30:14.128 [DEBUG] [TestEventLogger]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:30:14.128 [DEBUG] [TestEventLogger]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:30:14.128 [DEBUG] [TestEventLogger]         at java.lang.reflect.Method.invoke(Method.java:498)
18:30:14.128 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
18:30:14.128 [DEBUG] [TestEventLogger]         at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
18:30:14.128 [DEBUG] [TestEventLogger]         at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
18:30:14.129 [DEBUG] [TestEventLogger]         at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
18:30:14.129 [DEBUG] [TestEventLogger]         at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
18:30:14.129 [DEBUG] [TestEventLogger]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
18:30:14.129 [DEBUG] [TestEventLogger]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
18:30:14.129 [DEBUG] [TestEventLogger]         at java.lang.Thread.run(Thread.java:748)
18:30:14.129 [DEBUG] [TestEventLogger]
18:30:14.129 [DEBUG] [TestEventLogger] test.javacard.TestSuite FAILED```

Do you know something it?

Feature request: publish CAP and EXP files in appropriate places

I would like for the EXP and CAP to be handled differently.

First, the name for the CAP should be derived automatically from the archivesBaseName and project version.

The CAP file should be published as a project artifact so it can be used for automation.

The EXP file should also be published, however it should be included with the project output JAR as it is effectively metadata for the class files. This also makes sense because using the EXP generally requires the class files.

Gradle error: Could not find method compile() for arguments [com.github.martinpaljak:globalplatformpro:18.09.14]

Gradle version: 8.0

Having an error while trying to build.

./gradlew

Error message:

Could not find method compile() for arguments [com.github.martinpaljak:globalplatformpro:18.09.14] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Contents of build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'fr.bmartel:gradle-javacard:1.5.6'
    }
}

apply plugin: 'javacard'

dependencies {
    compile 'com.github.martinpaljak:globalplatformpro:18.09.14'
}

javacard {
    config {
        cap {
            packageName 'com.smartcard.sign'
            version '0.1'
            aid 'a0:00:00:11:22'
            output 'applet.cap'
            applet {
                className 'com.smartcard.sign.Sign'
                aid 'a0:00:00:11:22:01:01'
            }
        }
    }

    scripts {
        script {
            name 'select'
            apdu '00:A4:04:00:0A:01:02:03:04:05:06:07:08:09:01:00'
        }
        script {
            name 'hello'
            apdu '00:40:00:00:00'
        }
        task {
            name 'sendHello'
            scripts 'select', 'hello'
        }
    }
}

Update to latest version of ant-javacard

I found that the 18.07.12 version of ant-javacard is having issues with importing external jar/exp files. The following configuration is unable to locate the .exp file.

        cap {
            ...
            dependencies {
                local {
                    jar 'build/javacard/tlv.jar'
                    exps 'build/javacard/'
                }
            }
        }

Similarly, if I make the equivalent tags in build.xml, ant-javacard-18.07.12 can't locate the exp. But if I update to 19.05.06 it all works great :)

Use JCDK's simulator to run APDU tasks

Hi everyone!

First, thanks so much for this astonishing and incredibly useful repository! I recently started getting into JavaCard/SIM development, and without open source projects like this, I would definitely be completely lost.

Currently, I am trying out the examples from your javacard-tutorial repository. The CAP file generation and everything else before it runs perfectly fine, but, as I don't have a physical smart card and reader yet, I'd like to try it out on a simulator. The JavaCard Development Kit by Oracle comes with the cref utility; that should be the simulator, right? Sadly, it comes as a Windows EXE file only, so one will need to use wine to execute it on Mac/Linux (I tried it and it works).

Still, it seems like currently, the Gradle plugin cannot use it yet. When I try something like gradle sendHello in the other repository, I get an error message like:

> Task :jc101-1c:sendHello FAILED
gp [-d, -a, 00A404000A01020304050607080901, -a, 0040000000]
GlobalPlatformPro unknown-development
Running on Linux 4.15.0-38-generic amd64, Java 1.8.0_181 by Oracle Corporation
Exception in thread "main" jnasmartcardio.Smartcardio$EstablishContextException: jnasmartcardio.Smartcardio$JnaPCSCException: SCardEstablishContext got response 0x8010001d (SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
        at jnasmartcardio.Smartcardio$JnaTerminalFactorySpi.engineTerminals(Smartcardio.java:81)
        at javax.smartcardio.TerminalFactory.terminals(TerminalFactory.java:351)
        at pro.javacard.gp.GPTool.main(GPTool.java:344)
Caused by: jnasmartcardio.Smartcardio$JnaPCSCException: SCardEstablishContext got response 0x8010001d (SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
        at jnasmartcardio.Smartcardio.check(Smartcardio.java:960)
        at jnasmartcardio.Smartcardio.check(Smartcardio.java:951)
        at jnasmartcardio.Smartcardio.access$000(Smartcardio.java:34)
        at jnasmartcardio.Smartcardio$JnaTerminalFactorySpi.engineTerminals(Smartcardio.java:79)
        ... 2 more

And, well, the message The Smart card resource manager is not running. is a fairly clear indication of what's going on. So, does anyone know how I can use the simulator here?

Regarding my system setup: I'm using Ubuntu 16.04 with OpenJDK 1.8.0_181. My JavaCard Development Kit version is 3.0.5u3.

Share common project (dependency,library) in two other project problem

I'm not experienced in javacard development
In our business we have two separate javacard projects that generate two .cap files according to customer's request or his/her smartcard datasheet specs , but there are some common java classes that are used in both of them!

with dependency handling explained in #1, it seems we have one applet.cap + one common.cap that first common.cap must be installed and then applet.cap must be installed.
Is there any solution in this plugin that we could install only one applet on smartcard and we have common source and applet source separately (good dependency handling and management) ?

Error: "attempt to instantiate an abstract class"

My card has some special api baked in, to access them, the vendor provided me with a jar and a exp (the jar file consists of a few java files, which has empty implementation, sort like a header file).

I have added both to my depencies, like so:

local {
jar rootPath + '/sdk/special.jar'
exps rootPath + '/sdk'
}

but now I am getting an error [ant:convert] NEW: attempt to instantiate an abstract class

any idea?

all the best

Your repository is unavailable

Hey! There is a problem with the availability of your proxy repository!
Execution failed for task ':compileTestJava'.

Could not resolve all files for configuration ':jcardsim'.
Could not resolve com.licel:jcardsim:3.0.4.
Required by:
project :
> Could not resolve com.licel:jcardsim:3.0.4.
> Could not get resource 'http://dl.bintray.com/bertrandmartel/maven/com/licel/jcardsim/3.0.4/jcardsim-3.0.4.pom'.
> Could not GET 'http://dl.bintray.com/bertrandmartel/maven/com/licel/jcardsim/3.0.4/jcardsim-3.0.4.pom'. Received status code 403 from server: Forbidden

Specify install() parameter

Is it possible to specify an install APDU that is passed to install() on the Applet?
Like --params in gp.

If it is not possible ATM would you consider accepting a PR implementing this?

Feature request: targetsdk support

One of the capabilities ant-javacard has is to specify a "target SDK". This lets a converter from a more modern SDK be used while targeting an older SDK, which can fix some compilation issues.

It would be nice if the javacard gradle plugin had this functionality as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.