Implemented Android Smart Card Emulator
Includes jCardSim to emulate the following Java Card Applets in Android's host card emulation: - jCardSim Team's Hello World Applet - Philip Wendland's ISO Applet - Yubico's OpenPGP Applet - Yubico's OATH Applet
12
.gitmodules
vendored
@@ -2,3 +2,15 @@
|
|||||||
path = npa/src/opensc
|
path = npa/src/opensc
|
||||||
url = git://github.com/OpenSC/OpenSC.git
|
url = git://github.com/OpenSC/OpenSC.git
|
||||||
ignore = dirty
|
ignore = dirty
|
||||||
|
[submodule "ACardEmulator/app/src/main/external/ykneo-openpgp"]
|
||||||
|
path = ACardEmulator/app/src/main/external/ykneo-openpgp
|
||||||
|
url = https://github.com/Yubico/ykneo-openpgp.git
|
||||||
|
[submodule "ACardEmulator/app/src/main/external/ykneo-oath"]
|
||||||
|
path = ACardEmulator/app/src/main/external/ykneo-oath
|
||||||
|
url = https://github.com/Yubico/ykneo-oath.git
|
||||||
|
[submodule "ACardEmulator/app/src/main/external/IsoApplet"]
|
||||||
|
path = ACardEmulator/app/src/main/external/IsoApplet
|
||||||
|
url = https://github.com/frankmorgner/IsoApplet.git
|
||||||
|
[submodule "ACardEmulator/app/src/main/external/jcardsim"]
|
||||||
|
path = ACardEmulator/app/src/main/external/jcardsim
|
||||||
|
url = https://github.com/frankmorgner/jcardsim.git
|
||||||
|
|||||||
6
ACardEmulator/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/libraries
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
23
ACardEmulator/.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
3
ACardEmulator/.idea/copyright/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
5
ACardEmulator/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||||
|
</project>
|
||||||
|
|
||||||
19
ACardEmulator/.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="LOCAL" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.2.1" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
13
ACardEmulator/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<entry_points version="2.0" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="SvnBranchConfigurationManager">
|
||||||
|
<option name="mySupportsUserInfoFilter" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
10
ACardEmulator/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/ACardEmulator.iml" filepath="$PROJECT_DIR$/ACardEmulator.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
5
ACardEmulator/.idea/scopes/scope_settings.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="DependencyValidationManager">
|
||||||
|
<state>
|
||||||
|
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
7
ACardEmulator/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
19
ACardEmulator/ACardEmulator.iml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="java-gradle" name="Java-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
674
ACardEmulator/COPYING
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
1
ACardEmulator/app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
99
ACardEmulator/app/app.iml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="ACardEmulator" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="android-gradle" name="Android-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="android" name="Android">
|
||||||
|
<configuration>
|
||||||
|
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||||
|
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||||
|
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||||
|
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||||
|
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
||||||
|
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
|
||||||
|
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
|
||||||
|
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||||
|
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||||
|
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||||
|
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||||
|
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/external/jcardsim/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/external/IsoApplet/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/external/android-scio/src/main" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/external/ykneo-openpgp/applet/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/external/ykneo-oath/applet/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="core-1.51.0.0" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
34
ACardEmulator/app/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 21
|
||||||
|
buildToolsVersion "21.1.2"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.vsmartcard.acardemulator"
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 21
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/external/jcardsim/src/main/java'
|
||||||
|
main.java.exclude('**/APDUScriptTool.java')
|
||||||
|
main.java.srcDirs += 'src/main/external/IsoApplet/src'
|
||||||
|
main.java.srcDirs += 'src/main/external/android-scio/src/main'
|
||||||
|
main.java.srcDirs += 'src/main/external/ykneo-openpgp/applet/src'
|
||||||
|
main.java.srcDirs += 'src/main/external/ykneo-oath/applet/src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||||
|
compile group: 'com.madgag.spongycastle', name: 'core', version: '1.51.0.0'
|
||||||
|
}
|
||||||
35
ACardEmulator/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.vsmartcard.acardemulator" >
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
|
<uses-feature android:name="android.hardware.nfc" android:required="true" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme" >
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service android:name=".SimulatorService"
|
||||||
|
android:exported="true"
|
||||||
|
android:permission="android.permission.BIND_NFC_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="android.nfc.cardemulation.host_apdu_service"
|
||||||
|
android:resource="@xml/aid_list"/>
|
||||||
|
</service>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
1
ACardEmulator/app/src/main/external/IsoApplet
vendored
Submodule
18
ACardEmulator/app/src/main/external/android-scio/pom.xml
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.openecard.ifd</groupId>
|
||||||
|
<artifactId>scio-backend</artifactId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.openecard.ifd.scio-backend</groupId>
|
||||||
|
<artifactId>android-scio</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>SmartcardIO for Android</name>
|
||||||
|
|
||||||
|
</project>
|
||||||
165
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/ATR.java
vendored
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Smart Card's answer-to-reset bytes. A Card's ATR object can be obtained
|
||||||
|
* by calling {@linkplain Card#getATR}.
|
||||||
|
* This class does not attempt to verify that the ATR encodes a semantically
|
||||||
|
* valid structure.
|
||||||
|
*
|
||||||
|
* <p>Instances of this class are immutable. Where data is passed in or out
|
||||||
|
* via byte arrays, defensive cloning is performed.
|
||||||
|
*
|
||||||
|
* @see Card#getATR
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public final class ATR implements java.io.Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6695383790847736493L;
|
||||||
|
|
||||||
|
private byte[] atr;
|
||||||
|
|
||||||
|
private transient int startHistorical, nHistorical;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an ATR from a byte array.
|
||||||
|
*
|
||||||
|
* @param atr the byte array containing the answer-to-reset bytes
|
||||||
|
* @throws NullPointerException if <code>atr</code> is null
|
||||||
|
*/
|
||||||
|
public ATR(byte[] atr) {
|
||||||
|
this.atr = atr.clone();
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parse() {
|
||||||
|
if (atr.length < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((atr[0] != 0x3b) && (atr[0] != 0x3f)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int t0 = (atr[1] & 0xf0) >> 4;
|
||||||
|
int n = atr[1] & 0xf;
|
||||||
|
int i = 2;
|
||||||
|
while ((t0 != 0) && (i < atr.length)) {
|
||||||
|
if ((t0 & 1) != 0) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if ((t0 & 2) != 0) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if ((t0 & 4) != 0) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if ((t0 & 8) != 0) {
|
||||||
|
if (i >= atr.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
t0 = (atr[i++] & 0xf0) >> 4;
|
||||||
|
} else {
|
||||||
|
t0 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int k = i + n;
|
||||||
|
if ((k == atr.length) || (k == atr.length - 1)) {
|
||||||
|
startHistorical = i;
|
||||||
|
nHistorical = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the bytes in this ATR.
|
||||||
|
*
|
||||||
|
* @return a copy of the bytes in this ATR.
|
||||||
|
*/
|
||||||
|
public byte[] getBytes() {
|
||||||
|
return atr.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the historical bytes in this ATR.
|
||||||
|
* If this ATR does not contain historical bytes, an array of length
|
||||||
|
* zero is returned.
|
||||||
|
*
|
||||||
|
* @return a copy of the historical bytes in this ATR.
|
||||||
|
*/
|
||||||
|
public byte[] getHistoricalBytes() {
|
||||||
|
byte[] b = new byte[nHistorical];
|
||||||
|
System.arraycopy(atr, startHistorical, b, 0, nHistorical);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this ATR.
|
||||||
|
*
|
||||||
|
* @return a String representation of this ATR.
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return "ATR: " + atr.length + " bytes";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the specified object with this ATR for equality.
|
||||||
|
* Returns true if the given object is also an ATR and its bytes are
|
||||||
|
* identical to the bytes in this ATR.
|
||||||
|
*
|
||||||
|
* @param obj the object to be compared for equality with this ATR
|
||||||
|
* @return true if the specified object is equal to this ATR
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof ATR == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ATR other = (ATR)obj;
|
||||||
|
return Arrays.equals(this.atr, other.atr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hash code value for this ATR.
|
||||||
|
*
|
||||||
|
* @return the hash code value for this ATR.
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return Arrays.hashCode(atr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readObject(java.io.ObjectInputStream in)
|
||||||
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
|
atr = (byte[])in.readUnshared();
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
167
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/Card.java
vendored
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Smart Card with which a connection has been established. Card objects
|
||||||
|
* are obtained by calling {@link CardTerminal#connect CardTerminal.connect()}.
|
||||||
|
*
|
||||||
|
* @see CardTerminal
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public abstract class Card {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new Card object.
|
||||||
|
*
|
||||||
|
* <p>This constructor is called by subclasses only. Application should
|
||||||
|
* call the {@linkplain CardTerminal#connect CardTerminal.connect()}
|
||||||
|
* method to obtain a Card
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
protected Card() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ATR of this card.
|
||||||
|
*
|
||||||
|
* @return the ATR of this card.
|
||||||
|
*/
|
||||||
|
public abstract ATR getATR();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the protocol in use for this card.
|
||||||
|
*
|
||||||
|
* @return the protocol in use for this card, for example "T=0" or "T=1"
|
||||||
|
*/
|
||||||
|
public abstract String getProtocol();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CardChannel for the basic logical channel. The basic
|
||||||
|
* logical channel has a channel number of 0.
|
||||||
|
*
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
* @throws IllegalStateException if this card object has been disposed of
|
||||||
|
* via the {@linkplain #disconnect disconnect()} method
|
||||||
|
*/
|
||||||
|
public abstract CardChannel getBasicChannel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a new logical channel to the card and returns it. The channel is
|
||||||
|
* opened by issuing a <code>MANAGE CHANNEL</code> command that should use
|
||||||
|
* the format <code>[00 70 00 00 01]</code>.
|
||||||
|
*
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
* @throws CardException is a new logical channel could not be opened
|
||||||
|
* @throws IllegalStateException if this card object has been disposed of
|
||||||
|
* via the {@linkplain #disconnect disconnect()} method
|
||||||
|
*/
|
||||||
|
public abstract CardChannel openLogicalChannel() throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests exclusive access to this card.
|
||||||
|
*
|
||||||
|
* <p>Once a thread has invoked <code>beginExclusive</code>, only this
|
||||||
|
* thread is allowed to communicate with this card until it calls
|
||||||
|
* <code>endExclusive</code>. Other threads attempting communication
|
||||||
|
* will receive a CardException.
|
||||||
|
*
|
||||||
|
* <p>Applications have to ensure that exclusive access is correctly
|
||||||
|
* released. This can be achieved by executing
|
||||||
|
* the <code>beginExclusive()</code> and <code>endExclusive</code> calls
|
||||||
|
* in a <code>try ... finally</code> block.
|
||||||
|
*
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
* @throws CardException if exclusive access has already been set
|
||||||
|
* or if exclusive access could not be established
|
||||||
|
* @throws IllegalStateException if this card object has been disposed of
|
||||||
|
* via the {@linkplain #disconnect disconnect()} method
|
||||||
|
*/
|
||||||
|
public abstract void beginExclusive() throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the exclusive access previously established using
|
||||||
|
* <code>beginExclusive</code>.
|
||||||
|
*
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
* @throws IllegalStateException if the active Thread does not currently have
|
||||||
|
* exclusive access to this card or
|
||||||
|
* if this card object has been disposed of
|
||||||
|
* via the {@linkplain #disconnect disconnect()} method
|
||||||
|
* @throws CardException if the operation failed
|
||||||
|
*/
|
||||||
|
public abstract void endExclusive() throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmits a control command to the terminal device.
|
||||||
|
*
|
||||||
|
* <p>This can be used to, for example, control terminal functions like
|
||||||
|
* a built-in PIN pad or biometrics.
|
||||||
|
*
|
||||||
|
* @param controlCode the control code of the command
|
||||||
|
* @param command the command data
|
||||||
|
*
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
* @throws NullPointerException if command is null
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
* @throws IllegalStateException if this card object has been disposed of
|
||||||
|
* via the {@linkplain #disconnect disconnect()} method
|
||||||
|
*/
|
||||||
|
public abstract byte[] transmitControlCommand(int controlCode,
|
||||||
|
byte[] command) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects the connection with this card. After this method returns,
|
||||||
|
* calling methods on this object or in CardChannels associated with this
|
||||||
|
* object that require interaction with the card will raise an
|
||||||
|
* IllegalStateException.
|
||||||
|
*
|
||||||
|
* @param reset whether to reset the card after disconnecting.
|
||||||
|
*
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
*/
|
||||||
|
public abstract void disconnect(boolean reset) throws CardException;
|
||||||
|
|
||||||
|
}
|
||||||
184
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/CardChannel.java
vendored
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.nio.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A logical channel connection to a Smart Card. It is used to exchange APDUs
|
||||||
|
* with a Smart Card.
|
||||||
|
* A CardChannel object can be obtained by calling the method
|
||||||
|
* {@linkplain Card#getBasicChannel} or {@linkplain Card#openLogicalChannel}.
|
||||||
|
*
|
||||||
|
* @see Card
|
||||||
|
* @see CommandAPDU
|
||||||
|
* @see ResponseAPDU
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public abstract class CardChannel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardChannel object.
|
||||||
|
*
|
||||||
|
* <p>This constructor is called by subclasses only. Application should
|
||||||
|
* call the {@linkplain Card#getBasicChannel} and
|
||||||
|
* {@linkplain Card#openLogicalChannel} methods to obtain a CardChannel
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
protected CardChannel() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Card this channel is associated with.
|
||||||
|
*
|
||||||
|
* @return the Card this channel is associated with
|
||||||
|
*/
|
||||||
|
public abstract Card getCard();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the channel number of this CardChannel. A channel number of
|
||||||
|
* 0 indicates the basic logical channel.
|
||||||
|
*
|
||||||
|
* @return the channel number of this CardChannel.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if this channel has been
|
||||||
|
* {@linkplain #close closed} or if the corresponding Card has been
|
||||||
|
* {@linkplain Card#disconnect disconnected}.
|
||||||
|
*/
|
||||||
|
public abstract int getChannelNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmits the specified command APDU to the Smart Card and returns the
|
||||||
|
* response APDU.
|
||||||
|
*
|
||||||
|
* <p>The CLA byte of the command APDU is automatically adjusted to
|
||||||
|
* match the channel number of this CardChannel.
|
||||||
|
*
|
||||||
|
* <p>Note that this method cannot be used to transmit
|
||||||
|
* <code>MANAGE CHANNEL</code> APDUs. Logical channels should be managed
|
||||||
|
* using the {@linkplain Card#openLogicalChannel} and {@linkplain
|
||||||
|
* CardChannel#close CardChannel.close()} methods.
|
||||||
|
*
|
||||||
|
* <p>Implementations should transparently handle artifacts
|
||||||
|
* of the transmission protocol.
|
||||||
|
* For example, when using the T=0 protocol, the following processing
|
||||||
|
* should occur as described in ISO/IEC 7816-4:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li><p>if the response APDU has an SW1 of <code>61</code>, the
|
||||||
|
* implementation should issue a <code>GET RESPONSE</code> command
|
||||||
|
* using <code>SW2</code> as the <code>Le</code>field.
|
||||||
|
* This process is repeated as long as an SW1 of <code>61</code> is
|
||||||
|
* received. The response body of these exchanges is concatenated
|
||||||
|
* to form the final response body.
|
||||||
|
*
|
||||||
|
* <li><p>if the response APDU is <code>6C XX</code>, the implementation
|
||||||
|
* should reissue the command using <code>XX</code> as the
|
||||||
|
* <code>Le</code> field.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>The ResponseAPDU returned by this method is the result
|
||||||
|
* after this processing has been performed.
|
||||||
|
*
|
||||||
|
* @param command the command APDU
|
||||||
|
* @return the response APDU received from the card
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if this channel has been
|
||||||
|
* {@linkplain #close closed} or if the corresponding Card has been
|
||||||
|
* {@linkplain Card#disconnect disconnected}.
|
||||||
|
* @throws IllegalArgumentException if the APDU encodes a
|
||||||
|
* <code>MANAGE CHANNEL</code> command
|
||||||
|
* @throws NullPointerException if command is null
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public abstract ResponseAPDU transmit(CommandAPDU command) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmits the command APDU stored in the command ByteBuffer and receives
|
||||||
|
* the reponse APDU in the response ByteBuffer.
|
||||||
|
*
|
||||||
|
* <p>The command buffer must contain valid command APDU data starting
|
||||||
|
* at <code>command.position()</code> and the APDU must be
|
||||||
|
* <code>command.remaining()</code> bytes long.
|
||||||
|
* Upon return, the command buffer's position will be equal
|
||||||
|
* to its limit; its limit will not have changed. The output buffer
|
||||||
|
* will have received the response APDU bytes. Its position will have
|
||||||
|
* advanced by the number of bytes received, which is also the return
|
||||||
|
* value of this method.
|
||||||
|
*
|
||||||
|
* <p>The CLA byte of the command APDU is automatically adjusted to
|
||||||
|
* match the channel number of this CardChannel.
|
||||||
|
*
|
||||||
|
* <p>Note that this method cannot be used to transmit
|
||||||
|
* <code>MANAGE CHANNEL</code> APDUs. Logical channels should be managed
|
||||||
|
* using the {@linkplain Card#openLogicalChannel} and {@linkplain
|
||||||
|
* CardChannel#close CardChannel.close()} methods.
|
||||||
|
*
|
||||||
|
* <p>See {@linkplain #transmit transmit()} for a discussion of the handling
|
||||||
|
* of response APDUs with the SW1 values <code>61</code> or <code>6C</code>.
|
||||||
|
*
|
||||||
|
* @param command the buffer containing the command APDU
|
||||||
|
* @param response the buffer that shall receive the response APDU from
|
||||||
|
* the card
|
||||||
|
* @return the length of the received response APDU
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if this channel has been
|
||||||
|
* {@linkplain #close closed} or if the corresponding Card has been
|
||||||
|
* {@linkplain Card#disconnect disconnected}.
|
||||||
|
* @throws NullPointerException if command or response is null
|
||||||
|
* @throws ReadOnlyBufferException if the response buffer is read-only
|
||||||
|
* @throws IllegalArgumentException if command and response are the
|
||||||
|
* same object, if <code>response</code> may not have
|
||||||
|
* sufficient space to receive the response APDU
|
||||||
|
* or if the APDU encodes a <code>MANAGE CHANNEL</code> command
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public abstract int transmit(ByteBuffer command, ByteBuffer response)
|
||||||
|
throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes this CardChannel. The logical channel is closed by issuing
|
||||||
|
* a <code>MANAGE CHANNEL</code> command that should use the format
|
||||||
|
* <code>[xx 70 80 0n]</code> where <code>n</code> is the channel number
|
||||||
|
* of this channel and <code>xx</code> is the <code>CLA</code>
|
||||||
|
* byte that encodes this logical channel and has all other bits set to 0.
|
||||||
|
* After this method returns, calling other
|
||||||
|
* methods in this class will raise an IllegalStateException.
|
||||||
|
*
|
||||||
|
* <p>Note that the basic logical channel cannot be closed using this
|
||||||
|
* method. It can be closed by calling {@link Card#disconnect}.
|
||||||
|
*
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
* @throws IllegalStateException if this CardChannel represents a
|
||||||
|
* connection the basic logical channel
|
||||||
|
*/
|
||||||
|
public abstract void close() throws CardException;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception for errors that occur during communication with the
|
||||||
|
* Smart Card stack or the card itself.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public class CardException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7787607144922050628L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardException with the specified detail message.
|
||||||
|
*
|
||||||
|
* @param message the detail message
|
||||||
|
*/
|
||||||
|
public CardException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardException with the specified cause and a detail message
|
||||||
|
* of <code>(cause==null ? null : cause.toString())</code>.
|
||||||
|
*
|
||||||
|
* @param cause the cause of this exception or null
|
||||||
|
*/
|
||||||
|
public CardException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardException with the specified detail message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message
|
||||||
|
* @param cause the cause of this exception or null
|
||||||
|
*/
|
||||||
|
public CardException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown when an application tries to establish a connection with a
|
||||||
|
* terminal that has no card present.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public class CardNotPresentException extends CardException {
|
||||||
|
|
||||||
|
private final static long serialVersionUID = 1346879911706545215L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardNotPresentException with the specified detail message.
|
||||||
|
*
|
||||||
|
* @param message the detail message
|
||||||
|
*/
|
||||||
|
public CardNotPresentException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardNotPresentException with the specified cause and a detail message
|
||||||
|
* of <code>(cause==null ? null : cause.toString())</code>.
|
||||||
|
*
|
||||||
|
* @param cause the cause of this exception or null
|
||||||
|
*/
|
||||||
|
public CardNotPresentException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardNotPresentException with the specified detail message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message
|
||||||
|
* @param cause the cause of this exception or null
|
||||||
|
*/
|
||||||
|
public CardNotPresentException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
301
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/CardPermission.java
vendored
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import java.security.Permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A permission for Smart Card operations. A CardPermission consists of the
|
||||||
|
* name of the card terminal the permission applies to and a set of actions
|
||||||
|
* that are valid for that terminal.
|
||||||
|
*
|
||||||
|
* <p>A CardPermission with a name of <code>*</code> applies to all
|
||||||
|
* card terminals. The actions string is a comma separated list of the actions
|
||||||
|
* listed below, or <code>*</code> to signify "all actions."
|
||||||
|
*
|
||||||
|
* <p>Individual actions are:
|
||||||
|
* <dl>
|
||||||
|
* <dt>connect
|
||||||
|
* <dd>connect to a card using
|
||||||
|
* {@linkplain CardTerminal#connect CardTerminal.connect()}
|
||||||
|
*
|
||||||
|
* <dt>reset
|
||||||
|
* <dd>reset the card using {@linkplain Card#disconnect Card.disconnect(true)}
|
||||||
|
*
|
||||||
|
* <dt>exclusive
|
||||||
|
* <dd>establish exclusive access to a card using
|
||||||
|
* {@linkplain Card#beginExclusive} and {@linkplain Card#endExclusive
|
||||||
|
* endExclusive()}
|
||||||
|
*
|
||||||
|
* <dt>transmitControl
|
||||||
|
* <dd>transmit a control command using
|
||||||
|
* {@linkplain Card#transmitControlCommand Card.transmitControlCommand()}
|
||||||
|
*
|
||||||
|
* <dt>getBasicChannel
|
||||||
|
* <dd>obtain the basic logical channel using
|
||||||
|
* {@linkplain Card#getBasicChannel}
|
||||||
|
*
|
||||||
|
* <dt>openLogicalChannel
|
||||||
|
* <dd>open a new logical channel using
|
||||||
|
* {@linkplain Card#openLogicalChannel}
|
||||||
|
*
|
||||||
|
* </dl>
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public class CardPermission extends Permission {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7146787880530705613L;
|
||||||
|
|
||||||
|
private final static int A_CONNECT = 0x01;
|
||||||
|
private final static int A_EXCLUSIVE = 0x02;
|
||||||
|
private final static int A_GET_BASIC_CHANNEL = 0x04;
|
||||||
|
private final static int A_OPEN_LOGICAL_CHANNEL = 0x08;
|
||||||
|
private final static int A_RESET = 0x10;
|
||||||
|
private final static int A_TRANSMIT_CONTROL = 0x20;
|
||||||
|
|
||||||
|
// sum of all the actions above
|
||||||
|
private final static int A_ALL = 0x3f;
|
||||||
|
|
||||||
|
private final static int[] ARRAY_MASKS = {
|
||||||
|
A_ALL,
|
||||||
|
A_CONNECT,
|
||||||
|
A_EXCLUSIVE,
|
||||||
|
A_GET_BASIC_CHANNEL,
|
||||||
|
A_OPEN_LOGICAL_CHANNEL,
|
||||||
|
A_RESET,
|
||||||
|
A_TRANSMIT_CONTROL,
|
||||||
|
};
|
||||||
|
|
||||||
|
private final static String S_CONNECT = "connect";
|
||||||
|
private final static String S_EXCLUSIVE = "exclusive";
|
||||||
|
private final static String S_GET_BASIC_CHANNEL = "getBasicChannel";
|
||||||
|
private final static String S_OPEN_LOGICAL_CHANNEL = "openLogicalChannel";
|
||||||
|
private final static String S_RESET = "reset";
|
||||||
|
private final static String S_TRANSMIT_CONTROL = "transmitControl";
|
||||||
|
|
||||||
|
private final static String S_ALL = "*";
|
||||||
|
|
||||||
|
private final static String[] ARRAY_STRINGS = {
|
||||||
|
S_ALL,
|
||||||
|
S_CONNECT,
|
||||||
|
S_EXCLUSIVE,
|
||||||
|
S_GET_BASIC_CHANNEL,
|
||||||
|
S_OPEN_LOGICAL_CHANNEL,
|
||||||
|
S_RESET,
|
||||||
|
S_TRANSMIT_CONTROL,
|
||||||
|
};
|
||||||
|
|
||||||
|
private transient int mask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @serial
|
||||||
|
*/
|
||||||
|
private volatile String actions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardPermission with the specified actions.
|
||||||
|
* <code>terminalName</code> is the name of a CardTerminal or <code>*</code>
|
||||||
|
* if this permission applies to all terminals. <code>actions</code>
|
||||||
|
* contains a comma-separated list of the individual actions
|
||||||
|
* or <code>*</code> to signify all actions. For more information,
|
||||||
|
* see the documentation at the top of this {@linkplain CardPermission
|
||||||
|
* class}.
|
||||||
|
*
|
||||||
|
* @param terminalName the name of the card terminal, or <code>*</code>
|
||||||
|
* @param actions the action string (or null if the set of permitted
|
||||||
|
* actions is empty)
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if terminalName is null
|
||||||
|
* @throws IllegalArgumentException if actions is an invalid actions
|
||||||
|
* specification
|
||||||
|
*/
|
||||||
|
public CardPermission(String terminalName, String actions) {
|
||||||
|
super(terminalName);
|
||||||
|
if (terminalName == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
mask = getMask(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getMask(String actions) {
|
||||||
|
if ((actions == null) || (actions.length() == 0)) {
|
||||||
|
throw new IllegalArgumentException("actions must not be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
// try exact matches for simple actions first
|
||||||
|
for (int i = 0; i < ARRAY_STRINGS.length; i++) {
|
||||||
|
if (actions == ARRAY_STRINGS[i]) {
|
||||||
|
return ARRAY_MASKS[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actions.endsWith(",")) {
|
||||||
|
throw new IllegalArgumentException("Invalid actions: '" + actions + "'");
|
||||||
|
}
|
||||||
|
int mask = 0;
|
||||||
|
String[] split = actions.split(",");
|
||||||
|
outer:
|
||||||
|
for (String s : split) {
|
||||||
|
for (int i = 0; i < ARRAY_STRINGS.length; i++) {
|
||||||
|
if (ARRAY_STRINGS[i].equalsIgnoreCase(s)) {
|
||||||
|
mask |= ARRAY_MASKS[i];
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Invalid action: '" + s + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getActions(int mask) {
|
||||||
|
if (mask == A_ALL) {
|
||||||
|
return S_ALL;
|
||||||
|
}
|
||||||
|
boolean first = true;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < ARRAY_MASKS.length; i++) {
|
||||||
|
int action = ARRAY_MASKS[i];
|
||||||
|
if ((mask & action) == action) {
|
||||||
|
if (first == false) {
|
||||||
|
sb.append(",");
|
||||||
|
} else {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
sb.append(ARRAY_STRINGS[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the canonical string representation of the actions.
|
||||||
|
* It is <code>*</code> to signify all actions defined by this class or
|
||||||
|
* the string concatenation of the comma-separated,
|
||||||
|
* lexicographically sorted list of individual actions.
|
||||||
|
*
|
||||||
|
* @return the canonical string representation of the actions.
|
||||||
|
*/
|
||||||
|
public String getActions() {
|
||||||
|
if (actions == null) {
|
||||||
|
actions = getActions(mask);
|
||||||
|
}
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this CardPermission object implies the specified permission.
|
||||||
|
* That is the case, if and only if
|
||||||
|
* <ul>
|
||||||
|
* <li><p><code>permission</code> is an instance of CardPermission,</p>
|
||||||
|
* <li><p><code>permission</code>'s actions are a proper subset of this
|
||||||
|
* object's actions, and</p>
|
||||||
|
* <li><p>this object's <code>getName()</code> method is either
|
||||||
|
* <code>*</code> or equal to <code>permission</code>'s <code>name</code>.
|
||||||
|
* </p>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param permission the permission to check against
|
||||||
|
* @return true if and only if this CardPermission object implies the
|
||||||
|
* specified permission.
|
||||||
|
*/
|
||||||
|
public boolean implies(Permission permission) {
|
||||||
|
if (permission instanceof CardPermission == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CardPermission other = (CardPermission)permission;
|
||||||
|
if ((this.mask & other.mask) != other.mask) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String thisName = getName();
|
||||||
|
if (thisName.equals("*")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (thisName.equals(other.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the specified object with this CardPermission for equality.
|
||||||
|
* This CardPermission is equal to another Object <code>object</code>, if
|
||||||
|
* and only if
|
||||||
|
* <ul>
|
||||||
|
* <li><p><code>object</code> is an instance of CardPermission,</p>
|
||||||
|
* <li><p><code>this.getName()</code> is equal to
|
||||||
|
* <code>((CardPermission)object).getName()</code>, and</p>
|
||||||
|
* <li><p><code>this.getActions()</code> is equal to
|
||||||
|
* <code>((CardPermission)object).getActions()</code>.</p>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param obj the object to be compared for equality with this CardPermission
|
||||||
|
* @return true if and only if the specified object is equal to this
|
||||||
|
* CardPermission
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof CardPermission == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CardPermission other = (CardPermission)obj;
|
||||||
|
return this.getName().equals(other.getName()) && (this.mask == other.mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hash code value for this CardPermission object.
|
||||||
|
*
|
||||||
|
* @return the hash code value for this CardPermission object.
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return getName().hashCode() + 31 * mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeObject(ObjectOutputStream s) throws IOException {
|
||||||
|
// Write out the actions. The superclass takes care of the name.
|
||||||
|
// Call getActions to make sure actions field is initialized
|
||||||
|
if (actions == null) {
|
||||||
|
getActions();
|
||||||
|
}
|
||||||
|
s.defaultWriteObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readObject(ObjectInputStream s)
|
||||||
|
throws IOException, ClassNotFoundException {
|
||||||
|
// Read in the actions, then restore the mask.
|
||||||
|
s.defaultReadObject();
|
||||||
|
mask = getMask(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
134
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/CardTerminal.java
vendored
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Smart Card terminal, sometimes refered to as a Smart Card Reader.
|
||||||
|
* A CardTerminal object can be obtained by calling
|
||||||
|
* {@linkplain CardTerminals#list}
|
||||||
|
* or {@linkplain CardTerminals#getTerminal CardTerminals.getTerminal()}.
|
||||||
|
*
|
||||||
|
* <p>Note that physical card readers with slots for multiple cards are
|
||||||
|
* represented by one <code>CardTerminal</code> object per such slot.
|
||||||
|
*
|
||||||
|
* @see CardTerminals
|
||||||
|
* @see TerminalFactory
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public abstract class CardTerminal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardTerminal object.
|
||||||
|
*
|
||||||
|
* <p>This constructor is called by subclasses only. Application should
|
||||||
|
* call {@linkplain CardTerminals#list list()}
|
||||||
|
* or {@linkplain CardTerminals#getTerminal getTerminal()}
|
||||||
|
* to obtain a CardTerminal object.
|
||||||
|
*/
|
||||||
|
protected CardTerminal() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unique name of this terminal.
|
||||||
|
*
|
||||||
|
* @return the unique name of this terminal.
|
||||||
|
*/
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establishes a connection to the card.
|
||||||
|
* If a connection has previously established using
|
||||||
|
* the specified protocol, this method returns the same Card object as
|
||||||
|
* the previous call.
|
||||||
|
*
|
||||||
|
* @param protocol the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to
|
||||||
|
* connect using any available protocol.
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if protocol is null
|
||||||
|
* @throws IllegalArgumentException if protocol is an invalid protocol
|
||||||
|
* specification
|
||||||
|
* @throws CardNotPresentException if no card is present in this terminal
|
||||||
|
* @throws CardException if a connection could not be established
|
||||||
|
* using the specified protocol or if a connection has previously been
|
||||||
|
* established using a different protocol
|
||||||
|
* @throws SecurityException if a SecurityManager exists and the
|
||||||
|
* caller does not have the required
|
||||||
|
* {@linkplain CardPermission permission}
|
||||||
|
*/
|
||||||
|
public abstract Card connect(String protocol) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether a card is present in this terminal.
|
||||||
|
*
|
||||||
|
* @return whether a card is present in this terminal.
|
||||||
|
*
|
||||||
|
* @throws CardException if the status could not be determined
|
||||||
|
*/
|
||||||
|
public abstract boolean isCardPresent() throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until a card is present in this terminal or the timeout
|
||||||
|
* expires. If the method returns due to an expired timeout, it returns
|
||||||
|
* false. Otherwise it return true.
|
||||||
|
*
|
||||||
|
* <P>If a card is present in this terminal when this
|
||||||
|
* method is called, it returns immediately.
|
||||||
|
*
|
||||||
|
* @param timeout if positive, block for up to <code>timeout</code>
|
||||||
|
* milliseconds; if zero, block indefinitely; must not be negative
|
||||||
|
* @return false if the method returns due to an expired timeout,
|
||||||
|
* true otherwise.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if timeout is negative
|
||||||
|
* @throws CardException if the operation failed
|
||||||
|
*/
|
||||||
|
public abstract boolean waitForCardPresent(long timeout) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until a card is absent in this terminal or the timeout
|
||||||
|
* expires. If the method returns due to an expired timeout, it returns
|
||||||
|
* false. Otherwise it return true.
|
||||||
|
*
|
||||||
|
* <P>If no card is present in this terminal when this
|
||||||
|
* method is called, it returns immediately.
|
||||||
|
*
|
||||||
|
* @param timeout if positive, block for up to <code>timeout</code>
|
||||||
|
* milliseconds; if zero, block indefinitely; must not be negative
|
||||||
|
* @return false if the method returns due to an expired timeout,
|
||||||
|
* true otherwise.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if timeout is negative
|
||||||
|
* @throws CardException if the operation failed
|
||||||
|
*/
|
||||||
|
public abstract boolean waitForCardAbsent(long timeout) throws CardException;
|
||||||
|
|
||||||
|
}
|
||||||
219
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/CardTerminals.java
vendored
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The set of terminals supported by a TerminalFactory.
|
||||||
|
* This class allows applications to enumerate the available CardTerminals,
|
||||||
|
* obtain a specific CardTerminal, or wait for the insertion or removal of
|
||||||
|
* cards.
|
||||||
|
*
|
||||||
|
* <p>This class is multi-threading safe and can be used by multiple
|
||||||
|
* threads concurrently. However, this object keeps track of the card
|
||||||
|
* presence state of each of its terminals. Multiple objects should be used
|
||||||
|
* if independent calls to {@linkplain #waitForChange} are required.
|
||||||
|
*
|
||||||
|
* <p>Applications can obtain instances of this class by calling
|
||||||
|
* {@linkplain TerminalFactory#terminals}.
|
||||||
|
*
|
||||||
|
* @see TerminalFactory
|
||||||
|
* @see CardTerminal
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public abstract class CardTerminals {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new CardTerminals object.
|
||||||
|
*
|
||||||
|
* <p>This constructor is called by subclasses only. Application should
|
||||||
|
* call {@linkplain TerminalFactory#terminals}
|
||||||
|
* to obtain a CardTerminals object.
|
||||||
|
*/
|
||||||
|
protected CardTerminals() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an unmodifiable list of all available terminals.
|
||||||
|
*
|
||||||
|
* @return an unmodifiable list of all available terminals.
|
||||||
|
*
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public List<CardTerminal> list() throws CardException {
|
||||||
|
return list(State.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an unmodifiable list of all terminals matching the specified
|
||||||
|
* state.
|
||||||
|
*
|
||||||
|
* <p>If state is {@link State#ALL State.ALL}, this method returns
|
||||||
|
* all CardTerminals encapsulated by this object.
|
||||||
|
* If state is {@link State#CARD_PRESENT State.CARD_PRESENT} or
|
||||||
|
* {@link State#CARD_ABSENT State.CARD_ABSENT}, it returns all
|
||||||
|
* CardTerminals where a card is currently present or absent, respectively.
|
||||||
|
*
|
||||||
|
* <p>If state is {@link State#CARD_INSERTION State.CARD_INSERTION} or
|
||||||
|
* {@link State#CARD_REMOVAL State.CARD_REMOVAL}, it returns all
|
||||||
|
* CardTerminals for which an insertion (or removal, respectively)
|
||||||
|
* was detected during the last call to {@linkplain #waitForChange}.
|
||||||
|
* If <code>waitForChange()</code> has not been called on this object,
|
||||||
|
* <code>CARD_INSERTION</code> is equivalent to <code>CARD_PRESENT</code>
|
||||||
|
* and <code>CARD_REMOVAL</code> is equivalent to <code>CARD_ABSENT</code>.
|
||||||
|
* For an example of the use of <code>CARD_INSERTION</code>,
|
||||||
|
* see {@link #waitForChange}.
|
||||||
|
*
|
||||||
|
* @param state the State
|
||||||
|
* @return an unmodifiable list of all terminals matching the specified
|
||||||
|
* attribute.
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if attr is null
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public abstract List<CardTerminal> list(State state) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the terminal with the specified name or null if no such
|
||||||
|
* terminal exists.
|
||||||
|
*
|
||||||
|
* @return the terminal with the specified name or null if no such
|
||||||
|
* terminal exists.
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if name is null
|
||||||
|
*/
|
||||||
|
public CardTerminal getTerminal(String name) {
|
||||||
|
if (name == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (CardTerminal terminal : list()) {
|
||||||
|
if (terminal.getName().equals(name)) {
|
||||||
|
return terminal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (CardException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for card insertion or removal in any of the terminals of this
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* <p>This call is equivalent to calling
|
||||||
|
* {@linkplain #waitForChange(long) waitForChange(0)}.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if this <code>CardTerminals</code>
|
||||||
|
* object does not contain any terminals
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public void waitForChange() throws CardException {
|
||||||
|
waitForChange(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for card insertion or removal in any of the terminals of this
|
||||||
|
* object or until the timeout expires.
|
||||||
|
*
|
||||||
|
* <p>This method examines each CardTerminal of this object.
|
||||||
|
* If a card was inserted into or removed from a CardTerminal since the
|
||||||
|
* previous call to <code>waitForChange()</code>, it returns
|
||||||
|
* immediately.
|
||||||
|
* Otherwise, or if this is the first call to <code>waitForChange()</code>
|
||||||
|
* on this object, it blocks until a card is inserted into or removed from
|
||||||
|
* a CardTerminal.
|
||||||
|
*
|
||||||
|
* <p>If <code>timeout</code> is greater than 0, the method returns after
|
||||||
|
* <code>timeout</code> milliseconds even if there is no change in state.
|
||||||
|
* In that case, this method returns <code>false</code>; otherwise it
|
||||||
|
* returns <code>true</code>.
|
||||||
|
*
|
||||||
|
* <p>This method is often used in a loop in combination with
|
||||||
|
* {@link #list(CardTerminals.State) list(State.CARD_INSERTION)},
|
||||||
|
* for example:
|
||||||
|
* <pre>
|
||||||
|
* TerminalFactory factory = ...;
|
||||||
|
* CardTerminals terminals = factory.terminals();
|
||||||
|
* while (true) {
|
||||||
|
* for (CardTerminal terminal : terminals.list(CARD_INSERTION)) {
|
||||||
|
* // examine Card in terminal, return if it matches
|
||||||
|
* }
|
||||||
|
* terminals.waitForChange();
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @param timeout if positive, block for up to <code>timeout</code>
|
||||||
|
* milliseconds; if zero, block indefinitely; must not be negative
|
||||||
|
* @return false if the method returns due to an expired timeout,
|
||||||
|
* true otherwise.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if this <code>CardTerminals</code>
|
||||||
|
* object does not contain any terminals
|
||||||
|
* @throws IllegalArgumentException if timeout is negative
|
||||||
|
* @throws CardException if the card operation failed
|
||||||
|
*/
|
||||||
|
public abstract boolean waitForChange(long timeout) throws CardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of attributes of a CardTerminal.
|
||||||
|
* It is used as a parameter to the {@linkplain CardTerminals#list} method.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public static enum State {
|
||||||
|
/**
|
||||||
|
* All CardTerminals.
|
||||||
|
*/
|
||||||
|
ALL,
|
||||||
|
/**
|
||||||
|
* CardTerminals in which a card is present.
|
||||||
|
*/
|
||||||
|
CARD_PRESENT,
|
||||||
|
/**
|
||||||
|
* CardTerminals in which a card is not present.
|
||||||
|
*/
|
||||||
|
CARD_ABSENT,
|
||||||
|
/**
|
||||||
|
* CardTerminals for which a card insertion was detected during the
|
||||||
|
* latest call to {@linkplain State#waitForChange waitForChange()}
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
CARD_INSERTION,
|
||||||
|
/**
|
||||||
|
* CardTerminals for which a card removal was detected during the
|
||||||
|
* latest call to {@linkplain State#waitForChange waitForChange()}
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
CARD_REMOVAL,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
606
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/CommandAPDU.java
vendored
Normal file
@@ -0,0 +1,606 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A command APDU following the structure defined in ISO/IEC 7816-4.
|
||||||
|
* It consists of a four byte header and a conditional body of variable length.
|
||||||
|
* This class does not attempt to verify that the APDU encodes a semantically
|
||||||
|
* valid command.
|
||||||
|
*
|
||||||
|
* <p>Note that when the expected length of the response APDU is specified
|
||||||
|
* in the {@linkplain #CommandAPDU(int,int,int,int,int) constructors},
|
||||||
|
* the actual length (Ne) must be specified, not its
|
||||||
|
* encoded form (Le). Similarly, {@linkplain #getNe} returns the actual
|
||||||
|
* value Ne. In other words, a value of 0 means "no data in the response APDU"
|
||||||
|
* rather than "maximum length."
|
||||||
|
*
|
||||||
|
* <p>This class supports both the short and extended forms of length
|
||||||
|
* encoding for Ne and Nc. However, note that not all terminals and Smart Cards
|
||||||
|
* are capable of accepting APDUs that use the extended form.
|
||||||
|
*
|
||||||
|
* <p>For the header bytes CLA, INS, P1, and P2 the Java type <code>int</code>
|
||||||
|
* is used to represent the 8 bit unsigned values. In the constructors, only
|
||||||
|
* the 8 lowest bits of the <code>int</code> value specified by the application
|
||||||
|
* are significant. The accessor methods always return the byte as an unsigned
|
||||||
|
* value between 0 and 255.
|
||||||
|
*
|
||||||
|
* <p>Instances of this class are immutable. Where data is passed in or out
|
||||||
|
* via byte arrays, defensive cloning is performed.
|
||||||
|
*
|
||||||
|
* @see ResponseAPDU
|
||||||
|
* @see CardChannel#transmit CardChannel.transmit
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public final class CommandAPDU implements java.io.Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 398698301286670877L;
|
||||||
|
|
||||||
|
private static final int MAX_APDU_SIZE = 65544;
|
||||||
|
|
||||||
|
/** @serial */
|
||||||
|
private byte[] apdu;
|
||||||
|
|
||||||
|
// value of nc
|
||||||
|
private transient int nc;
|
||||||
|
|
||||||
|
// value of ne
|
||||||
|
private transient int ne;
|
||||||
|
|
||||||
|
// index of start of data within the apdu array
|
||||||
|
private transient int dataOffset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from a byte array containing the complete
|
||||||
|
* APDU contents (header and body).
|
||||||
|
*
|
||||||
|
* <p>Note that the apdu bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param apdu the complete command APDU
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if apdu is null
|
||||||
|
* @throws IllegalArgumentException if apdu does not contain a valid
|
||||||
|
* command APDU
|
||||||
|
*/
|
||||||
|
public CommandAPDU(byte[] apdu) {
|
||||||
|
this.apdu = apdu.clone();
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from a byte array containing the complete
|
||||||
|
* APDU contents (header and body). The APDU starts at the index
|
||||||
|
* <code>apduOffset</code> in the byte array and is <code>apduLength</code>
|
||||||
|
* bytes long.
|
||||||
|
*
|
||||||
|
* <p>Note that the apdu bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param apdu the complete command APDU
|
||||||
|
* @param apduOffset the offset in the byte array at which the apdu
|
||||||
|
* data begins
|
||||||
|
* @param apduLength the length of the APDU
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if apdu is null
|
||||||
|
* @throws IllegalArgumentException if apduOffset or apduLength are
|
||||||
|
* negative or if apduOffset + apduLength are greater than apdu.length,
|
||||||
|
* or if the specified bytes are not a valid APDU
|
||||||
|
*/
|
||||||
|
public CommandAPDU(byte[] apdu, int apduOffset, int apduLength) {
|
||||||
|
checkArrayBounds(apdu, apduOffset, apduLength);
|
||||||
|
this.apdu = new byte[apduLength];
|
||||||
|
System.arraycopy(apdu, apduOffset, this.apdu, 0, apduLength);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkArrayBounds(byte[] b, int ofs, int len) {
|
||||||
|
if ((ofs < 0) || (len < 0)) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Offset and length must not be negative");
|
||||||
|
}
|
||||||
|
if (b == null) {
|
||||||
|
if ((ofs != 0) && (len != 0)) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("offset and length must be 0 if array is null");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ofs > b.length - len) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Offset plus length exceed array size");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CommandAPDU from the ByteBuffer containing the complete APDU
|
||||||
|
* contents (header and body).
|
||||||
|
* The buffer's <code>position</code> must be set to the start of the APDU,
|
||||||
|
* its <code>limit</code> to the end of the APDU. Upon return, the buffer's
|
||||||
|
* <code>position</code> is equal to its limit; its limit remains unchanged.
|
||||||
|
*
|
||||||
|
* <p>Note that the data in the ByteBuffer is copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param apdu the ByteBuffer containing the complete APDU
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if apdu is null
|
||||||
|
* @throws IllegalArgumentException if apdu does not contain a valid
|
||||||
|
* command APDU
|
||||||
|
*/
|
||||||
|
public CommandAPDU(ByteBuffer apdu) {
|
||||||
|
this.apdu = new byte[apdu.remaining()];
|
||||||
|
apdu.get(this.apdu);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes. This is case 1
|
||||||
|
* in ISO 7816, no command body.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2) {
|
||||||
|
this(cla, ins, p1, p2, null, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes and the expected
|
||||||
|
* response data length. This is case 2 in ISO 7816, empty command data
|
||||||
|
* field with Ne specified. If Ne is 0, the APDU is encoded as ISO 7816
|
||||||
|
* case 1.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
* @param ne the maximum number of expected data bytes in a response APDU
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if ne is negative or greater than
|
||||||
|
* 65536
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2, int ne) {
|
||||||
|
this(cla, ins, p1, p2, null, 0, 0, ne);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes and command data.
|
||||||
|
* This is case 3 in ISO 7816, command data present and Ne absent. The
|
||||||
|
* value Nc is taken as data.length. If <code>data</code> is null or
|
||||||
|
* its length is 0, the APDU is encoded as ISO 7816 case 1.
|
||||||
|
*
|
||||||
|
* <p>Note that the data bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
* @param data the byte array containing the data bytes of the command body
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if data.length is greater than 65535
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data) {
|
||||||
|
this(cla, ins, p1, p2, data, 0, arrayLength(data), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes and command data.
|
||||||
|
* This is case 3 in ISO 7816, command data present and Ne absent. The
|
||||||
|
* value Nc is taken as dataLength. If <code>dataLength</code>
|
||||||
|
* is 0, the APDU is encoded as ISO 7816 case 1.
|
||||||
|
*
|
||||||
|
* <p>Note that the data bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
* @param data the byte array containing the data bytes of the command body
|
||||||
|
* @param dataOffset the offset in the byte array at which the data
|
||||||
|
* bytes of the command body begin
|
||||||
|
* @param dataLength the number of the data bytes in the command body
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if data is null and dataLength is not 0
|
||||||
|
* @throws IllegalArgumentException if dataOffset or dataLength are
|
||||||
|
* negative or if dataOffset + dataLength are greater than data.length
|
||||||
|
* or if dataLength is greater than 65535
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data,
|
||||||
|
int dataOffset, int dataLength) {
|
||||||
|
this(cla, ins, p1, p2, data, dataOffset, dataLength, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes, command data,
|
||||||
|
* and expected response data length. This is case 4 in ISO 7816,
|
||||||
|
* command data and Ne present. The value Nc is taken as data.length
|
||||||
|
* if <code>data</code> is non-null and as 0 otherwise. If Ne or Nc
|
||||||
|
* are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.
|
||||||
|
*
|
||||||
|
* <p>Note that the data bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
* @param data the byte array containing the data bytes of the command body
|
||||||
|
* @param ne the maximum number of expected data bytes in a response APDU
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if data.length is greater than 65535
|
||||||
|
* or if ne is negative or greater than 65536
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data, int ne) {
|
||||||
|
this(cla, ins, p1, p2, data, 0, arrayLength(data), ne);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int arrayLength(byte[] b) {
|
||||||
|
return (b != null) ? b.length : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command APDU encoding options:
|
||||||
|
*
|
||||||
|
* case 1: |CLA|INS|P1 |P2 | len = 4
|
||||||
|
* case 2s: |CLA|INS|P1 |P2 |LE | len = 5
|
||||||
|
* case 3s: |CLA|INS|P1 |P2 |LC |...BODY...| len = 6..260
|
||||||
|
* case 4s: |CLA|INS|P1 |P2 |LC |...BODY...|LE | len = 7..261
|
||||||
|
* case 2e: |CLA|INS|P1 |P2 |00 |LE1|LE2| len = 7
|
||||||
|
* case 3e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...| len = 8..65542
|
||||||
|
* case 4e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...|LE1|LE2| len =10..65544
|
||||||
|
*
|
||||||
|
* LE, LE1, LE2 may be 0x00.
|
||||||
|
* LC must not be 0x00 and LC1|LC2 must not be 0x00|0x00
|
||||||
|
*/
|
||||||
|
private void parse() {
|
||||||
|
if (apdu.length < 4) {
|
||||||
|
throw new IllegalArgumentException("apdu must be at least 4 bytes long");
|
||||||
|
}
|
||||||
|
if (apdu.length == 4) {
|
||||||
|
// case 1
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int l1 = apdu[4] & 0xff;
|
||||||
|
if (apdu.length == 5) {
|
||||||
|
// case 2s
|
||||||
|
this.ne = (l1 == 0) ? 256 : l1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (l1 != 0) {
|
||||||
|
if (apdu.length == 4 + 1 + l1) {
|
||||||
|
// case 3s
|
||||||
|
this.nc = l1;
|
||||||
|
this.dataOffset = 5;
|
||||||
|
return;
|
||||||
|
} else if (apdu.length == 4 + 2 + l1) {
|
||||||
|
// case 4s
|
||||||
|
this.nc = l1;
|
||||||
|
this.dataOffset = 5;
|
||||||
|
int l2 = apdu[apdu.length - 1] & 0xff;
|
||||||
|
this.ne = (l2 == 0) ? 256 : l2;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Invalid APDU: length=" + apdu.length + ", b1=" + l1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (apdu.length < 7) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Invalid APDU: length=" + apdu.length + ", b1=" + l1);
|
||||||
|
}
|
||||||
|
int l2 = ((apdu[5] & 0xff) << 8) | (apdu[6] & 0xff);
|
||||||
|
if (apdu.length == 7) {
|
||||||
|
// case 2e
|
||||||
|
this.ne = (l2 == 0) ? 65536 : l2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (l2 == 0) {
|
||||||
|
throw new IllegalArgumentException("Invalid APDU: length="
|
||||||
|
+ apdu.length + ", b1=" + l1 + ", b2||b3=" + l2);
|
||||||
|
}
|
||||||
|
if (apdu.length == 4 + 3 + l2) {
|
||||||
|
// case 3e
|
||||||
|
this.nc = l2;
|
||||||
|
this.dataOffset = 7;
|
||||||
|
return;
|
||||||
|
} else if (apdu.length == 4 + 5 + l2) {
|
||||||
|
// case 4e
|
||||||
|
this.nc = l2;
|
||||||
|
this.dataOffset = 7;
|
||||||
|
int leOfs = apdu.length - 2;
|
||||||
|
int l3 = ((apdu[leOfs] & 0xff) << 8) | (apdu[leOfs + 1] & 0xff);
|
||||||
|
this.ne = (l3 == 0) ? 65536 : l3;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Invalid APDU: length="
|
||||||
|
+ apdu.length + ", b1=" + l1 + ", b2||b3=" + l2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a CommandAPDU from the four header bytes, command data,
|
||||||
|
* and expected response data length. This is case 4 in ISO 7816,
|
||||||
|
* command data and Le present. The value Nc is taken as
|
||||||
|
* <code>dataLength</code>.
|
||||||
|
* If Ne or Nc
|
||||||
|
* are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.
|
||||||
|
*
|
||||||
|
* <p>Note that the data bytes are copied to protect against
|
||||||
|
* subsequent modification.
|
||||||
|
*
|
||||||
|
* @param cla the class byte CLA
|
||||||
|
* @param ins the instruction byte INS
|
||||||
|
* @param p1 the parameter byte P1
|
||||||
|
* @param p2 the parameter byte P2
|
||||||
|
* @param data the byte array containing the data bytes of the command body
|
||||||
|
* @param dataOffset the offset in the byte array at which the data
|
||||||
|
* bytes of the command body begin
|
||||||
|
* @param dataLength the number of the data bytes in the command body
|
||||||
|
* @param ne the maximum number of expected data bytes in a response APDU
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if data is null and dataLength is not 0
|
||||||
|
* @throws IllegalArgumentException if dataOffset or dataLength are
|
||||||
|
* negative or if dataOffset + dataLength are greater than data.length,
|
||||||
|
* or if ne is negative or greater than 65536,
|
||||||
|
* or if dataLength is greater than 65535
|
||||||
|
*/
|
||||||
|
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data,
|
||||||
|
int dataOffset, int dataLength, int ne) {
|
||||||
|
checkArrayBounds(data, dataOffset, dataLength);
|
||||||
|
if (dataLength > 65535) {
|
||||||
|
throw new IllegalArgumentException("dataLength is too large");
|
||||||
|
}
|
||||||
|
if (ne < 0) {
|
||||||
|
throw new IllegalArgumentException("ne must not be negative");
|
||||||
|
}
|
||||||
|
if (ne > 65536) {
|
||||||
|
throw new IllegalArgumentException("ne is too large");
|
||||||
|
}
|
||||||
|
this.ne = ne;
|
||||||
|
this.nc = dataLength;
|
||||||
|
if (dataLength == 0) {
|
||||||
|
if (ne == 0) {
|
||||||
|
// case 1
|
||||||
|
this.apdu = new byte[4];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
} else {
|
||||||
|
// case 2s or 2e
|
||||||
|
if (ne <= 256) {
|
||||||
|
// case 2s
|
||||||
|
// 256 is encoded as 0x00
|
||||||
|
byte len = (ne != 256) ? (byte)ne : 0;
|
||||||
|
this.apdu = new byte[5];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
this.apdu[4] = len;
|
||||||
|
} else {
|
||||||
|
// case 2e
|
||||||
|
byte l1, l2;
|
||||||
|
// 65536 is encoded as 0x00 0x00
|
||||||
|
if (ne == 65536) {
|
||||||
|
l1 = 0;
|
||||||
|
l2 = 0;
|
||||||
|
} else {
|
||||||
|
l1 = (byte)(ne >> 8);
|
||||||
|
l2 = (byte)ne;
|
||||||
|
}
|
||||||
|
this.apdu = new byte[7];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
this.apdu[5] = l1;
|
||||||
|
this.apdu[6] = l2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ne == 0) {
|
||||||
|
// case 3s or 3e
|
||||||
|
if (dataLength <= 255) {
|
||||||
|
// case 3s
|
||||||
|
apdu = new byte[4 + 1 + dataLength];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
apdu[4] = (byte)dataLength;
|
||||||
|
this.dataOffset = 5;
|
||||||
|
System.arraycopy(data, dataOffset, apdu, 5, dataLength);
|
||||||
|
} else {
|
||||||
|
// case 3e
|
||||||
|
apdu = new byte[4 + 3 + dataLength];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
apdu[4] = 0;
|
||||||
|
apdu[5] = (byte)(dataLength >> 8);
|
||||||
|
apdu[6] = (byte)dataLength;
|
||||||
|
this.dataOffset = 7;
|
||||||
|
System.arraycopy(data, dataOffset, apdu, 7, dataLength);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// case 4s or 4e
|
||||||
|
if ((dataLength <= 255) && (ne <= 256)) {
|
||||||
|
// case 4s
|
||||||
|
apdu = new byte[4 + 2 + dataLength];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
apdu[4] = (byte)dataLength;
|
||||||
|
this.dataOffset = 5;
|
||||||
|
System.arraycopy(data, dataOffset, apdu, 5, dataLength);
|
||||||
|
apdu[apdu.length - 1] = (ne != 256) ? (byte)ne : 0;
|
||||||
|
} else {
|
||||||
|
// case 4e
|
||||||
|
apdu = new byte[4 + 5 + dataLength];
|
||||||
|
setHeader(cla, ins, p1, p2);
|
||||||
|
apdu[4] = 0;
|
||||||
|
apdu[5] = (byte)(dataLength >> 8);
|
||||||
|
apdu[6] = (byte)dataLength;
|
||||||
|
this.dataOffset = 7;
|
||||||
|
System.arraycopy(data, dataOffset, apdu, 7, dataLength);
|
||||||
|
if (ne != 65536) {
|
||||||
|
int leOfs = apdu.length - 2;
|
||||||
|
apdu[leOfs] = (byte)(ne >> 8);
|
||||||
|
apdu[leOfs + 1] = (byte)ne;
|
||||||
|
} // else le == 65536: no need to fill in, encoded as 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHeader(int cla, int ins, int p1, int p2) {
|
||||||
|
apdu[0] = (byte)cla;
|
||||||
|
apdu[1] = (byte)ins;
|
||||||
|
apdu[2] = (byte)p1;
|
||||||
|
apdu[3] = (byte)p2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the class byte CLA.
|
||||||
|
*
|
||||||
|
* @return the value of the class byte CLA.
|
||||||
|
*/
|
||||||
|
public int getCLA() {
|
||||||
|
return apdu[0] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the instruction byte INS.
|
||||||
|
*
|
||||||
|
* @return the value of the instruction byte INS.
|
||||||
|
*/
|
||||||
|
public int getINS() {
|
||||||
|
return apdu[1] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the parameter byte P1.
|
||||||
|
*
|
||||||
|
* @return the value of the parameter byte P1.
|
||||||
|
*/
|
||||||
|
public int getP1() {
|
||||||
|
return apdu[2] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the parameter byte P2.
|
||||||
|
*
|
||||||
|
* @return the value of the parameter byte P2.
|
||||||
|
*/
|
||||||
|
public int getP2() {
|
||||||
|
return apdu[3] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of data bytes in the command body (Nc) or 0 if this
|
||||||
|
* APDU has no body. This call is equivalent to
|
||||||
|
* <code>getData().length</code>.
|
||||||
|
*
|
||||||
|
* @return the number of data bytes in the command body or 0 if this APDU
|
||||||
|
* has no body.
|
||||||
|
*/
|
||||||
|
public int getNc() {
|
||||||
|
return nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the data bytes in the command body. If this APDU as
|
||||||
|
* no body, this method returns a byte array with length zero.
|
||||||
|
*
|
||||||
|
* @return a copy of the data bytes in the command body or the empty
|
||||||
|
* byte array if this APDU has no body.
|
||||||
|
*/
|
||||||
|
public byte[] getData() {
|
||||||
|
byte[] data = new byte[nc];
|
||||||
|
System.arraycopy(apdu, dataOffset, data, 0, nc);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum number of expected data bytes in a response
|
||||||
|
* APDU (Ne).
|
||||||
|
*
|
||||||
|
* @return the maximum number of expected data bytes in a response APDU.
|
||||||
|
*/
|
||||||
|
public int getNe() {
|
||||||
|
return ne;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the bytes in this APDU.
|
||||||
|
*
|
||||||
|
* @return a copy of the bytes in this APDU.
|
||||||
|
*/
|
||||||
|
public byte[] getBytes() {
|
||||||
|
return apdu.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this command APDU.
|
||||||
|
*
|
||||||
|
* @return a String representation of this command APDU.
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return "CommmandAPDU: " + apdu.length + " bytes, nc=" + nc + ", ne=" + ne;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the specified object with this command APDU for equality.
|
||||||
|
* Returns true if the given object is also a CommandAPDU and its bytes are
|
||||||
|
* identical to the bytes in this CommandAPDU.
|
||||||
|
*
|
||||||
|
* @param obj the object to be compared for equality with this command APDU
|
||||||
|
* @return true if the specified object is equal to this command APDU
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof CommandAPDU == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CommandAPDU other = (CommandAPDU)obj;
|
||||||
|
return Arrays.equals(this.apdu, other.apdu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hash code value for this command APDU.
|
||||||
|
*
|
||||||
|
* @return the hash code value for this command APDU.
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return Arrays.hashCode(apdu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readObject(java.io.ObjectInputStream in)
|
||||||
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
|
apdu = (byte[])in.readUnshared();
|
||||||
|
// initialize transient fields
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
185
ACardEmulator/app/src/main/external/android-scio/src/main/java/javax/smartcardio/ResponseAPDU.java
vendored
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional
|
||||||
|
* body and a two byte trailer.
|
||||||
|
* This class does not attempt to verify that the APDU encodes a semantically
|
||||||
|
* valid response.
|
||||||
|
*
|
||||||
|
* <p>Instances of this class are immutable. Where data is passed in or out
|
||||||
|
* via byte arrays, defensive cloning is performed.
|
||||||
|
*
|
||||||
|
* @see CommandAPDU
|
||||||
|
* @see CardChannel#transmit CardChannel.transmit
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public final class ResponseAPDU implements java.io.Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6962744978375594225L;
|
||||||
|
|
||||||
|
/** @serial */
|
||||||
|
private byte[] apdu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a ResponseAPDU from a byte array containing the complete
|
||||||
|
* APDU contents (conditional body and trailed).
|
||||||
|
*
|
||||||
|
* <p>Note that the byte array is cloned to protect against subsequent
|
||||||
|
* modification.
|
||||||
|
*
|
||||||
|
* @param apdu the complete response APDU
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if apdu is null
|
||||||
|
* @throws IllegalArgumentException if apdu.length is less than 2
|
||||||
|
*/
|
||||||
|
public ResponseAPDU(byte[] apdu) {
|
||||||
|
apdu = apdu.clone();
|
||||||
|
check(apdu);
|
||||||
|
this.apdu = apdu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void check(byte[] apdu) {
|
||||||
|
if (apdu.length < 2) {
|
||||||
|
throw new IllegalArgumentException("apdu must be at least 2 bytes long");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of data bytes in the response body (Nr) or 0 if this
|
||||||
|
* APDU has no body. This call is equivalent to
|
||||||
|
* <code>getData().length</code>.
|
||||||
|
*
|
||||||
|
* @return the number of data bytes in the response body or 0 if this APDU
|
||||||
|
* has no body.
|
||||||
|
*/
|
||||||
|
public int getNr() {
|
||||||
|
return apdu.length - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the data bytes in the response body. If this APDU as
|
||||||
|
* no body, this method returns a byte array with a length of zero.
|
||||||
|
*
|
||||||
|
* @return a copy of the data bytes in the response body or the empty
|
||||||
|
* byte array if this APDU has no body.
|
||||||
|
*/
|
||||||
|
public byte[] getData() {
|
||||||
|
byte[] data = new byte[apdu.length - 2];
|
||||||
|
System.arraycopy(apdu, 0, data, 0, data.length);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the status byte SW1 as a value between 0 and 255.
|
||||||
|
*
|
||||||
|
* @return the value of the status byte SW1 as a value between 0 and 255.
|
||||||
|
*/
|
||||||
|
public int getSW1() {
|
||||||
|
return apdu[apdu.length - 2] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the status byte SW2 as a value between 0 and 255.
|
||||||
|
*
|
||||||
|
* @return the value of the status byte SW2 as a value between 0 and 255.
|
||||||
|
*/
|
||||||
|
public int getSW2() {
|
||||||
|
return apdu[apdu.length - 1] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the status bytes SW1 and SW2 as a single
|
||||||
|
* status word SW.
|
||||||
|
* It is defined as
|
||||||
|
* <code>(getSW1() << 8) | getSW2()</code>.
|
||||||
|
*
|
||||||
|
* @return the value of the status word SW.
|
||||||
|
*/
|
||||||
|
public int getSW() {
|
||||||
|
return (getSW1() << 8) | getSW2();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the bytes in this APDU.
|
||||||
|
*
|
||||||
|
* @return a copy of the bytes in this APDU.
|
||||||
|
*/
|
||||||
|
public byte[] getBytes() {
|
||||||
|
return apdu.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this response APDU.
|
||||||
|
*
|
||||||
|
* @return a String representation of this response APDU.
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return "ResponseAPDU: " + apdu.length + " bytes, SW="
|
||||||
|
+ Integer.toHexString(getSW());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the specified object with this response APDU for equality.
|
||||||
|
* Returns true if the given object is also a ResponseAPDU and its bytes are
|
||||||
|
* identical to the bytes in this ResponseAPDU.
|
||||||
|
*
|
||||||
|
* @param obj the object to be compared for equality with this response APDU
|
||||||
|
* @return true if the specified object is equal to this response APDU
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof ResponseAPDU == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ResponseAPDU other = (ResponseAPDU)obj;
|
||||||
|
return Arrays.equals(this.apdu, other.apdu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the hash code value for this response APDU.
|
||||||
|
*
|
||||||
|
* @return the hash code value for this response APDU.
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return Arrays.hashCode(apdu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readObject(java.io.ObjectInputStream in)
|
||||||
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
|
apdu = (byte[])in.readUnshared();
|
||||||
|
check(apdu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package javax.smartcardio;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TerminalFactorySpi class defines the service provider interface.
|
||||||
|
* Applications do not access this class directly, instead see
|
||||||
|
* {@linkplain TerminalFactory}.
|
||||||
|
*
|
||||||
|
* <P>Service providers that want to write a new implementation should define
|
||||||
|
* a concrete subclass of TerminalFactorySpi with a constructor that takes
|
||||||
|
* an <code>Object</code> as parameter. That class needs to be registered
|
||||||
|
* in a {@linkplain java.security.Provider}. The engine
|
||||||
|
* {@linkplain java.security.Provider.Service#getType type} is
|
||||||
|
* <code>TerminalFactory</code>.
|
||||||
|
* Service providers also need to implement subclasses of the abstract classes
|
||||||
|
* {@linkplain CardTerminals}, {@linkplain CardTerminal}, {@linkplain Card},
|
||||||
|
* and {@linkplain CardChannel}.
|
||||||
|
*
|
||||||
|
* <p>For example:
|
||||||
|
* <pre><em>file MyProvider.java:</em>
|
||||||
|
*
|
||||||
|
* package com.somedomain.card;
|
||||||
|
*
|
||||||
|
* import java.security.Provider;
|
||||||
|
*
|
||||||
|
* public class MyProvider extends Provider {
|
||||||
|
* public MyProvider() {
|
||||||
|
* super("MyProvider", 1.0d, "Smart Card Example");
|
||||||
|
* put("TerminalFactory.MyType", "com.somedomain.card.MySpi");
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*<em>file MySpi.java</em>
|
||||||
|
*
|
||||||
|
* package com.somedomain.card;
|
||||||
|
*
|
||||||
|
* import javax.smartcardio.*;
|
||||||
|
*
|
||||||
|
* public class MySpi extends TerminalFactoySpi {
|
||||||
|
* public MySpi(Object parameter) {
|
||||||
|
* // initialize as appropriate
|
||||||
|
* }
|
||||||
|
* protected CardTerminals engineTerminals() {
|
||||||
|
* // add implementation code here
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @see TerminalFactory
|
||||||
|
* @see java.security.Provider
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
* @author Andreas Sterbenz
|
||||||
|
* @author JSR 268 Expert Group
|
||||||
|
*/
|
||||||
|
public abstract class TerminalFactorySpi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new TerminalFactorySpi object.
|
||||||
|
*
|
||||||
|
* <p>This class is part of the service provider interface and not accessed
|
||||||
|
* directly by applications. Applications
|
||||||
|
* should use TerminalFactory objects, which can be obtained by calling
|
||||||
|
* one of the
|
||||||
|
* {@linkplain TerminalFactory#getInstance TerminalFactory.getInstance()}
|
||||||
|
* methods.
|
||||||
|
*
|
||||||
|
* <p>Concrete subclasses should define a constructor that takes an
|
||||||
|
* <code>Object</code> as parameter. It will be invoked when an
|
||||||
|
* application calls one of the {@linkplain TerminalFactory#getInstance
|
||||||
|
* TerminalFactory.getInstance()} methods and receives the <code>params</code>
|
||||||
|
* object specified by the application.
|
||||||
|
*/
|
||||||
|
protected TerminalFactorySpi() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CardTerminals created by this factory.
|
||||||
|
*
|
||||||
|
* @return the CardTerminals created by this factory.
|
||||||
|
*/
|
||||||
|
protected abstract CardTerminals engineTerminals();
|
||||||
|
|
||||||
|
}
|
||||||
1
ACardEmulator/app/src/main/external/jcardsim
vendored
Submodule
1
ACardEmulator/app/src/main/external/ykneo-oath
vendored
Submodule
1
ACardEmulator/app/src/main/external/ykneo-openpgp
vendored
Submodule
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Frank Morgner
|
||||||
|
*
|
||||||
|
* This file is part of ACardEmulator.
|
||||||
|
*
|
||||||
|
* ACardEmulator is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* ACardEmulator is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* ACardEmulator. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.vsmartcard.acardemulator;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Layout;
|
||||||
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
public class MainActivity extends ActionBarActivity {
|
||||||
|
|
||||||
|
private TextView textViewVPCDStatus;
|
||||||
|
private BroadcastReceiver bReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(SimulatorService.TAG)) {
|
||||||
|
String capdu = intent.getStringExtra(SimulatorService.EXTRA_CAPDU);
|
||||||
|
String rapdu = intent.getStringExtra(SimulatorService.EXTRA_RAPDU);
|
||||||
|
String error = intent.getStringExtra(SimulatorService.EXTRA_ERROR);
|
||||||
|
String deselect = intent.getStringExtra(SimulatorService.EXTRA_DESELECT);
|
||||||
|
String install = intent.getStringExtra(SimulatorService.EXTRA_INSTALL);
|
||||||
|
if (install != null)
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_install) + ":" + install + "\n");
|
||||||
|
if (capdu != null)
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_capdu) + ": " + capdu + "\n");
|
||||||
|
if (error != null)
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_error) + ": " + error + "\n");
|
||||||
|
if (rapdu != null) {
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_rapdu) + ": " + rapdu + "\n");
|
||||||
|
Layout layout = textViewVPCDStatus.getLayout();
|
||||||
|
if (layout != null) {
|
||||||
|
int scrollAmount = layout.getLineTop(textViewVPCDStatus.getLineCount()) - textViewVPCDStatus.getHeight();
|
||||||
|
if (scrollAmount > 0)
|
||||||
|
textViewVPCDStatus.scrollTo(0, scrollAmount);
|
||||||
|
else
|
||||||
|
textViewVPCDStatus.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deselect != null)
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_disconnected) + ": " + deselect + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
textViewVPCDStatus = (TextView) findViewById(R.id.textViewLog);
|
||||||
|
textViewVPCDStatus.setMovementMethod(new ScrollingMovementMethod());
|
||||||
|
|
||||||
|
LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
|
||||||
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
|
intentFilter.addAction(SimulatorService.TAG);
|
||||||
|
bManager.registerReceiver(bReceiver, intentFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Handle presses on the action bar items
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_copy:
|
||||||
|
// Code to Copy the content of Text View to the Clip board.
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText("simple text", textViewVPCDStatus.getText());
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
Toast.makeText(getApplicationContext(), "Log copied to clipboard.",
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
return true;
|
||||||
|
case R.id.action_delete:
|
||||||
|
textViewVPCDStatus.setText("");
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static String saved_status_key = "textViewVPCDStatus";
|
||||||
|
@Override
|
||||||
|
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
textViewVPCDStatus.setText(savedInstanceState.getCharSequence(saved_status_key));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
|
savedInstanceState.putCharSequence(saved_status_key, textViewVPCDStatus.getText());
|
||||||
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Frank Morgner
|
||||||
|
*
|
||||||
|
* This file is part of RemoteSmartCardReader.
|
||||||
|
*
|
||||||
|
* RemoteSmartCardReader is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* RemoteSmartCardReader is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* RemoteSmartCardReader. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.vsmartcard.acardemulator;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.licel.jcardsim.base.Simulator;
|
||||||
|
|
||||||
|
import net.pwendland.javacard.pki.isoapplet.FileNotFoundException;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private static final String simulatorFilename = "simulator";
|
||||||
|
|
||||||
|
public Settings (Context activity) {
|
||||||
|
context = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void witeObjectToFile(String filename, Object object) {
|
||||||
|
|
||||||
|
ObjectOutputStream objectOut = null;
|
||||||
|
try {
|
||||||
|
FileOutputStream fileOut = context.openFileOutput(filename, Activity.MODE_PRIVATE);
|
||||||
|
objectOut = new ObjectOutputStream(fileOut);
|
||||||
|
objectOut.writeObject(object);
|
||||||
|
fileOut.getFD().sync();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (objectOut != null) {
|
||||||
|
try {
|
||||||
|
objectOut.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// do nowt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object readObjectFromFile(String filename) {
|
||||||
|
ObjectInputStream objectIn = null;
|
||||||
|
Object object = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
FileInputStream fileIn = context.getApplicationContext().openFileInput(filename);
|
||||||
|
objectIn = new ObjectInputStream(fileIn);
|
||||||
|
object = objectIn.readObject();
|
||||||
|
|
||||||
|
} catch (java.io.FileNotFoundException e) {
|
||||||
|
// Do nothing
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (objectIn != null) {
|
||||||
|
try {
|
||||||
|
objectIn.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// do nowt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulator(Simulator simulator) {
|
||||||
|
witeObjectToFile(simulatorFilename, simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Simulator getSimulator() {
|
||||||
|
Object object = readObjectFromFile(simulatorFilename);
|
||||||
|
if (object == null) {
|
||||||
|
// TODO
|
||||||
|
return new Simulator();
|
||||||
|
} else {
|
||||||
|
return (Simulator) object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Frank Morgner
|
||||||
|
*
|
||||||
|
* This file is part of ACardEmulator.
|
||||||
|
*
|
||||||
|
* ACardEmulator is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* ACardEmulator is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* ACardEmulator. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.vsmartcard.acardemulator;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.nfc.cardemulation.HostApduService;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import com.licel.jcardsim.samples.HelloWorldApplet;
|
||||||
|
import com.licel.jcardsim.smartcardio.CardSimulator;
|
||||||
|
import com.licel.jcardsim.utils.AIDUtil;
|
||||||
|
|
||||||
|
import net.pwendland.javacard.pki.isoapplet.IsoApplet;
|
||||||
|
|
||||||
|
import openpgpcard.OpenPGPApplet;
|
||||||
|
import pkgYkneoOath.YkneoOath;
|
||||||
|
|
||||||
|
public class SimulatorService extends HostApduService {
|
||||||
|
|
||||||
|
public static final String TAG = "com.vsmartcard.acardemulator.SimulatorService";
|
||||||
|
public static final String EXTRA_CAPDU = "MSG_CAPDU";
|
||||||
|
public static final String EXTRA_RAPDU = "MSG_RAPDU";
|
||||||
|
public static final String EXTRA_ERROR = "MSG_ERROR";
|
||||||
|
public static final String EXTRA_DESELECT = "MSG_DESELECT";
|
||||||
|
public static final String EXTRA_INSTALL = "MSG_INSTALL";
|
||||||
|
|
||||||
|
private static CardSimulator simulator = null;
|
||||||
|
|
||||||
|
private void createSimulator() {
|
||||||
|
String aid, name, extra_install = "", extra_error = "";
|
||||||
|
simulator = new CardSimulator();
|
||||||
|
|
||||||
|
name = getResources().getString(R.string.applet_helloworld);
|
||||||
|
aid = getResources().getString(R.string.aid_helloworld);
|
||||||
|
try {
|
||||||
|
simulator.installApplet(AIDUtil.create(aid), HelloWorldApplet.class);
|
||||||
|
extra_install += "\n" + name + " (AID: " + aid + ")";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
name = getResources().getString(R.string.applet_isoapplet);
|
||||||
|
aid = getResources().getString(R.string.aid_isoapplet);
|
||||||
|
try {
|
||||||
|
simulator.installApplet(AIDUtil.create(aid), IsoApplet.class);
|
||||||
|
extra_install += "\n" + name + " (AID: " + aid + ")";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
name = getResources().getString(R.string.applet_openpgp);
|
||||||
|
aid = getResources().getString(R.string.aid_openpgp);
|
||||||
|
try {
|
||||||
|
byte[] aid_bytes = Util.hexStringToByteArray(aid);
|
||||||
|
byte[] inst_params = new byte[aid.length()+1];
|
||||||
|
inst_params[0] = (byte) aid_bytes.length;
|
||||||
|
System.arraycopy(aid_bytes, 0, inst_params, 1, aid_bytes.length);
|
||||||
|
simulator.installApplet(AIDUtil.create(aid), OpenPGPApplet.class, inst_params, (short) 0, (byte) inst_params.length);
|
||||||
|
extra_install += "\n" + name + " (AID: " + aid + ")";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
name = getResources().getString(R.string.applet_oath);
|
||||||
|
aid = getResources().getString(R.string.aid_oath);
|
||||||
|
try {
|
||||||
|
byte[] aid_bytes = Util.hexStringToByteArray(aid);
|
||||||
|
byte[] inst_params = new byte[aid.length()+1];
|
||||||
|
inst_params[0] = (byte) aid_bytes.length;
|
||||||
|
System.arraycopy(aid_bytes, 0, inst_params, 1, aid_bytes.length);
|
||||||
|
simulator.installApplet(AIDUtil.create(aid), YkneoOath.class, inst_params, (short) 0, (byte) inst_params.length);
|
||||||
|
extra_install += "\n" + name + " (AID: " + aid + ")";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent i = new Intent(TAG);
|
||||||
|
if (!extra_error.isEmpty())
|
||||||
|
i.putExtra(EXTRA_ERROR, extra_error);
|
||||||
|
if (!extra_install.isEmpty())
|
||||||
|
i.putExtra(EXTRA_INSTALL, extra_install);
|
||||||
|
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate () {
|
||||||
|
super.onCreate();
|
||||||
|
|
||||||
|
if (simulator == null)
|
||||||
|
createSimulator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] processCommandApdu(byte[] capdu, Bundle extras) {
|
||||||
|
Intent i = new Intent(TAG);
|
||||||
|
String extra_error = "";
|
||||||
|
byte[] rapdu = null;
|
||||||
|
|
||||||
|
i.putExtra(EXTRA_CAPDU, Util.byteArrayToHexString(capdu));
|
||||||
|
try {
|
||||||
|
rapdu = simulator.transmitCommand(capdu);
|
||||||
|
i.putExtra(EXTRA_RAPDU, Util.byteArrayToHexString(rapdu));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
extra_error += "Internal error";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extra_error.isEmpty())
|
||||||
|
i.putExtra(EXTRA_ERROR, extra_error);
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
|
||||||
|
|
||||||
|
return rapdu;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeactivated(int reason) {
|
||||||
|
Intent i = new Intent(TAG);
|
||||||
|
|
||||||
|
switch (reason) {
|
||||||
|
case DEACTIVATION_LINK_LOSS:
|
||||||
|
i.putExtra(EXTRA_DESELECT, "link lost");
|
||||||
|
break;
|
||||||
|
case DEACTIVATION_DESELECTED:
|
||||||
|
i.putExtra(EXTRA_DESELECT, "deactivated");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Frank Morgner
|
||||||
|
*
|
||||||
|
* This file is part of ACardEmulator.
|
||||||
|
*
|
||||||
|
* ACardEmulator is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* ACardEmulator is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* ACardEmulator. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.vsmartcard.acardemulator;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
|
||||||
|
public static byte[] hexStringToByteArray(String s) {
|
||||||
|
int len = s.length();
|
||||||
|
byte[] data = new byte[len/2];
|
||||||
|
|
||||||
|
for(int i = 0; i < len; i+=2){
|
||||||
|
data[i/2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected static char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||||
|
public static String byteArrayToHexString(byte[] bytes) {
|
||||||
|
char[] hexChars = new char[bytes.length*2];
|
||||||
|
int v;
|
||||||
|
|
||||||
|
for(int j=0; j < bytes.length; j++) {
|
||||||
|
v = bytes[j] & 0xFF;
|
||||||
|
hexChars[j*2] = hexArray[v>>>4];
|
||||||
|
hexChars[j*2 + 1] = hexArray[v & 0x0F];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(hexChars);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
ACardEmulator/app/src/main/res/drawable-hdpi/ic_action_copy.png
Normal file
|
After Width: | Height: | Size: 375 B |
BIN
ACardEmulator/app/src/main/res/drawable-hdpi/ic_action_delete.png
Executable file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
ACardEmulator/app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
ACardEmulator/app/src/main/res/drawable-mdpi/ic_action_copy.png
Normal file
|
After Width: | Height: | Size: 284 B |
BIN
ACardEmulator/app/src/main/res/drawable-mdpi/ic_action_delete.png
Executable file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
ACardEmulator/app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
ACardEmulator/app/src/main/res/drawable-xhdpi/ic_action_copy.png
Normal file
|
After Width: | Height: | Size: 351 B |
BIN
ACardEmulator/app/src/main/res/drawable-xhdpi/ic_action_delete.png
Executable file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
ACardEmulator/app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 464 B |
BIN
ACardEmulator/app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
29
ACardEmulator/app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:keepScreenOn="true"
|
||||||
|
tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity">
|
||||||
|
|
||||||
|
<HorizontalScrollView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentBottom="true">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:id="@+id/textViewLog"
|
||||||
|
android:typeface="monospace" />
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
16
ACardEmulator/app/src/main/res/menu/main.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity" >
|
||||||
|
|
||||||
|
<item android:id="@+id/action_copy"
|
||||||
|
android:title="@string/action_copy"
|
||||||
|
android:icon="@drawable/ic_action_copy"
|
||||||
|
app:showAsAction="withText" />
|
||||||
|
|
||||||
|
<item android:id="@+id/action_delete"
|
||||||
|
android:title="@string/action_delete"
|
||||||
|
android:icon="@drawable/ic_action_delete"
|
||||||
|
app:showAsAction="withText" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
6
ACardEmulator/app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|
||||||
|
</resources>
|
||||||
25
ACardEmulator/app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string name="app_name">Smart Card Emulator</string>
|
||||||
|
|
||||||
|
<string name="status_error">Error</string>
|
||||||
|
<string name="status_disconnected">Disconnected from terminal</string>
|
||||||
|
<string name="status_capdu">C-APDU</string>
|
||||||
|
<string name="status_rapdu">R-APDU</string>
|
||||||
|
<string name="status_install">Installed Applets</string>
|
||||||
|
|
||||||
|
<string name="action_restart">Restart Emulator</string>
|
||||||
|
<string name="action_copy">Copy Log</string>
|
||||||
|
<string name="action_delete">Clear Log</string>
|
||||||
|
|
||||||
|
<string name="aid_isoapplet">f276a288bcfba69d34f31001</string>
|
||||||
|
<string name="applet_isoapplet">Philip Wendland\'s ISO Applet</string>
|
||||||
|
<string name="aid_helloworld">F000000001</string>
|
||||||
|
<string name="applet_helloworld">jCardSim Team\'s Hello World Applet</string>
|
||||||
|
<string name="aid_openpgp">D2760001240102000000000000010000</string>
|
||||||
|
<string name="applet_openpgp">Yubico\'s OpenPGP Applet</string>
|
||||||
|
<string name="aid_oath">a000000527210101</string>
|
||||||
|
<string name="applet_oath">Yubico\'s OATH Applet</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
8
ACardEmulator/app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
14
ACardEmulator/app/src/main/res/xml/aid_list.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:description="@string/app_name"
|
||||||
|
android:requireDeviceUnlock="false">
|
||||||
|
|
||||||
|
<aid-group android:description="@string/applet_isoapplet" android:category="other">
|
||||||
|
<aid-filter android:name="@string/aid_isoapplet"/>
|
||||||
|
</aid-group>
|
||||||
|
|
||||||
|
<aid-group android:description="@string/applet_helloworld" android:category="other">
|
||||||
|
<aid-filter android:name="@string/aid_helloworld"/>
|
||||||
|
</aid-group>
|
||||||
|
</host-apdu-service>
|
||||||
19
ACardEmulator/build.gradle
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.1.0'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
18
ACardEmulator/gradle.properties
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||||
|
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
BIN
ACardEmulator/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
ACardEmulator/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Wed Apr 10 15:27:10 PDT 2013
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
||||||
164
ACardEmulator/gradlew
vendored
Executable file
@@ -0,0 +1,164 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >&-
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >&-
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
90
ACardEmulator/gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windowz variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
1
ACardEmulator/settings.gradle
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||