diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e49bfad --- /dev/null +++ b/.clang-format @@ -0,0 +1,303 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +#http://clang.llvm.org/docs/ClangFormatStyleOptions.html + +# The style used for all options not specifically set in the configuration. +# This option is supported only in the clang-format configuration (both within +# -style='{...}' and the .clang-format file). +# LLVM A style complying with the LLVM coding standards +# Google A style complying with Google’s C++ style guide +# Chromium A style complying with Chromium’s style guide +# Mozilla A style complying with Mozilla’s style guide +# WebKit A style complying with WebKit’s style guide +BasedOnStyle: Webkit + +# The extra indent or outdent of access modifiers, e.g. public:. +AccessModifierOffset: -4 + +# If true, horizontally aligns arguments after an open bracket. +# This applies to round brackets (parentheses), angle brackets and square +# brackets. This will result in formattings like code +# someLongFunction(argument1, argument2); endcode +AlignAfterOpenBracket: AlwaysBreak + +# If true, aligns escaped newlines as far left as possible. Otherwise puts them +# into the right-most column. +#AlignEscapedNewlinesLeft + +# If true, horizontally align operands of binary and ternary expressions. +AlignOperands: true + +# If true, aligns trailing comments. +AlignTrailingComments: true + +# Allow putting all parameters of a function declaration onto the next line even +# if BinPackParameters is false. +AllowAllParametersOfDeclarationOnNextLine: true + +# Allows contracting simple braced statements to a single line. +# E.g., this allows if (a) { return; } to be put on a single line. +AllowShortBlocksOnASingleLine: false + +# If true, short case labels will be contracted to a single line. +AllowShortCaseLabelsOnASingleLine: false + +# Dependent on the value, int f() { return 0; } can be put on a single line. +# SFS_None (in configuration: None) Never merge functions into a single line. +# SFS_Inline (in configuration: Inline) Only merge functions defined inside a +# class. +# SFS_Empty (in configuration: Empty) Only merge empty functions. +# SFS_All (in configuration: All) Merge all functions fitting on a single line. +AllowShortFunctionsOnASingleLine: None + +# If true, if (a) return; can be put on a single line. +#AllowShortIfStatementsOnASingleLine: false + +# If true, while (true) continue; can be put on a single line. +AllowShortLoopsOnASingleLine: true + +# If true, always break after function definition return types. +# More truthfully called ‘break before the identifier following the type in a +# function definition’. +# PenaltyReturnTypeOnItsOwnLine becomes irrelevant. +AlwaysBreakAfterDefinitionReturnType: All + +# If true, always break before multiline string literals. +AlwaysBreakBeforeMultilineStrings: false + +# If true, always break after the template<...> of a template declaration. +AlwaysBreakTemplateDeclarations: true + +# If false, a function call’s arguments will either be all on the same line or +# will have one line each. +BinPackArguments: false + +# If false, a function call’s arguments will either be all +# on the same line or will have one line each. +BinPackParameters: false + +# The way to wrap binary operators. +# BOS_None (in configuration: None) Break after operators. +# BOS_NonAssignment (in configuration: NonAssignment) Break before operators +# that aren’t assignments. +# BOS_All (in configuration: All) Break before operators. +#BreakBeforeBinaryOperators: None + +# The brace breaking style to use. +# BS_Attach (in configuration: Attach) Always attach braces to surrounding +# context. +# BS_Linux (in configuration: Linux) Like Attach, but break before braces on +# function, namespace and class definitions. +# BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before +# function definitions, and ‘else’. +# BS_Allman (in configuration: Allman) Always break before braces. +# BS_GNU (in configuration: GNU) Always break before braces and add an extra +# level of indentation to braces of control statements, not to those of class, +# function or other definitions. +BreakBeforeBraces: WebKit + +# If true, ternary operators will be placed after line breaks. +BreakBeforeTernaryOperators: true + +# Always break constructor initializers before commas and align the commas with +# the colon. +BreakConstructorInitializersBeforeComma: true + +# The column limit. +# A column limit of 0 means that there is no column limit. In this case, +# clang-format will respect the input’s line breaking decisions within +# statements unless they contradict other rules. +ColumnLimit: 80 + +# A regular expression that describes comments with special meaning, which +# should not be split into lines or otherwise changed. +CommentPragmas: "\/*(.*)*\/" + +# If the constructor initializers don’t fit on a line, put each initializer on +# its own line. +#ConstructorInitializerAllOnOneLineOrOnePerLine: false + +# The number of characters to use for indentation of constructor initializer +# lists. +ConstructorInitializerIndentWidth: 0 + +# Indent width for line continuations. +#ContinuationIndentWidth: 4 + +# If true, format braced lists as best suited for C++11 braced lists. +# Important differences: - No spaces inside the braced list. - No line break +# before the closing brace. - Indentation with the continuation indent, not with +# the block indent. +# Fundamentally, C++11 braced lists are formatted exactly like function calls +# would be formatted in their place. If the braced list follows a name (e.g. a +# type or variable name), clang-format formats as if the {} were the parentheses +# of a function call with that name. If there is no name, a zero-length name is +# assumed. +Cpp11BracedListStyle: true + +# If true, analyze the formatted file for the most common alignment of & and *. +# Point +#DerivePointerAlignment: false + +# Disables formatting at all. +#DisableFormat: false + +# If true, clang-format detects whether function calls and definitions are +# formatted with one parameter per line. +# Each call can be bin-packed, one-per-line or inconclusive. If it is +# inconclusive, e.g. completely on one line, but a decision needs to be made, +# clang-format analyzes whether there are other bin-packed cases in the input +# file and act accordingly. +# NOTE: This is an experimental flag, that might go away or be renamed. Do not +# use this in config files, etc. Use at your own risk. +ExperimentalAutoDetectBinPacking: false + +# A vector of macros that should be interpreted as foreach loops instead of as +# function calls. +# These are expected to be macros of the form: code +# FOREACH(, ...) endcode +# For example: BOOST_FOREACH. +#ForEachMacros (std::vector) + +# Indent case labels one level from the switch statement. +# When false, use the same indentation level as for the switch statement. Switch +# statement body is always indented one level more than case labels. +IndentCaseLabels: false + +# The number of columns to use for indentation. +IndentWidth: 4 + +# Indent if a function definition or declaration is wrapped after the type. +#IndentWrappedFunctionNames: false + +# If true, empty lines at the start of blocks are kept. +KeepEmptyLinesAtTheStartOfBlocks: false + +# Language, this format style is targeted at. +# LK_None (in configuration: None) Do not use. +# LK_Cpp (in configuration: Cpp) Should be used for C, C++, ObjectiveC, +# ObjectiveC++. +# LK_Java (in configuration: Java) Should be used for Java. +# LK_JavaScript (in configuration: JavaScript) Should be used for JavaScript. +# LK_Proto (in configuration: Proto) Should be used for Protocol Buffers +# (https://developers.google.com/protocol-buffers/). +Language: Cpp + +# The maximum number of consecutive empty lines to keep. +#MaxEmptyLinesToKeep: 0 + +# The indentation used for namespaces. +# NI_None (in configuration: None) Don’t indent in namespaces. +# NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in +# other namespaces). +# NI_All (in configuration: All) Indent in all namespaces. +NamespaceIndentation: None + +# The number of characters to use for indentation of ObjC blocks. +#ObjCBlockIndentWidth: 4 + +# Add a space after @property in Objective-C, i.e. use \@property (readonly) +# instead of \@property(readonly). +#ObjCSpaceAfterProperty: false + +# Add a space in front of an Objective-C protocol list, i.e. use Foo +# instead of Foo. +#ObjCSpaceBeforeProtocolList: false + +# The penalty for breaking a function call after “call(”. +#PenaltyBreakBeforeFirstCallParameter (unsigned) + +# The penalty for each line break introduced inside a comment. +#PenaltyBreakComment (unsigned) + +# The penalty for breaking before the first <<. +#PenaltyBreakFirstLessLess (unsigned) + +# The penalty for each line break introduced inside a string literal. +#PenaltyBreakString (unsigned) + +# The penalty for each character outside of the column limit. +#PenaltyExcessCharacter (unsigned) + +# Penalty for putting the return type of a function onto its own line. +#PenaltyReturnTypeOnItsOwnLine (unsigned) + +# If true, analyze the formatted file for the most common alignment of & and *. +# PointerAlignment is then used only as fallback. +PointerAlignment: Left + +# If true, a space may be inserted after C style casts. +SpaceAfterCStyleCast: false + +# If false, spaces will be removed before assignment operators. +SpaceBeforeAssignmentOperators: true + +# Defines in which cases to put a space before opening parentheses. +# SBPO_Never (in configuration: Never) Never put a space before opening +# parentheses. +# SBPO_ControlStatements (in configuration: ControlStatements) Put a space +# before opening parentheses only after control statement keywords +# (for/if/while...). +# SBPO_Always (in configuration: Always) Always put a space before opening +# parentheses, except when it’s prohibited by the syntax rules (in function-like +# macro definitions) or when determined by other style rules (after unary +# operators, opening parentheses, etc.) +SpaceBeforeParens: ControlStatements + +# If true, spaces may be inserted into ‘()’. +SpaceInEmptyParentheses: false + +# The number of spaces before trailing line comments (// - comments). +# This does not affect trailing block comments (/**/ - comments) as those +# commonly have different usage patterns and a number of special cases. +SpacesBeforeTrailingComments: 2 + +# If true, spaces will be inserted after ‘<’ and before ‘>’ in template argument +# lists +SpacesInAngles: false + +# If true, spaces may be inserted into C style casts. +SpacesInCStyleCastParentheses: false + +# If true, spaces are inserted inside container literals (e.g. ObjC and +# Javascript array and dict literals). +SpacesInContainerLiterals: false + +# If true, spaces will be inserted after ‘(‘ and before ‘)’. +SpacesInParentheses: false + +# If true, spaces will be inserted after ‘[‘ and before ‘]’. +SpacesInSquareBrackets: false + +# Format compatible with this standard, e.g. use A > instead of A> +# for LS_Cpp03. +# LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax. +# LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A> +# instead of A >). +# LS_Auto (in configuration: Auto) Automatic detection based on the input. +Standard: Cpp11 + +# The number of columns used for tab stops. +TabWidth: 4 + +# The way to use tab characters in the resulting file. +# UT_Never (in configuration: Never) Never use tab. +# UT_ForIndentation (in configuration: ForIndentation) Use tabs only for +# indentation. +# UT_Always (in configuration: Always) Use tabs whenever we need to fill +# whitespace that spans at least from one tab stop to the next one. +UseTab: Never + +# Indent code enclosed in an extern block +IndentExternBlock: NoIndent diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..748be04 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,17 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +Checks: '-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*' +WarningsAsErrors: true +HeaderFilterRegex: '.*' +FormatStyle: webkit diff --git a/.cppcheck.suppress b/.cppcheck.suppress new file mode 100644 index 0000000..0320283 --- /dev/null +++ b/.cppcheck.suppress @@ -0,0 +1,18 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +cstyleCast +missingInclude +unusedStructMember +accessMoved +normalCheckLevelMaxBranches diff --git a/.github/scripts/check_version.sh b/.github/scripts/check_version.sh index e776a4e..ea0c841 100644 --- a/.github/scripts/check_version.sh +++ b/.github/scripts/check_version.sh @@ -32,4 +32,4 @@ fi echo "PROJECT_VERSION=$version" >> $GITHUB_ENV -echo "Retained PROJECT_VERSION=$version" \ No newline at end of file +echo "Retained PROJECT_VERSION=$version" diff --git a/.github/scripts/patch_doxyfile.sh b/.github/scripts/patch_doxyfile.sh index 65d38f3..a6d5e9f 100644 --- a/.github/scripts/patch_doxyfile.sh +++ b/.github/scripts/patch_doxyfile.sh @@ -6,4 +6,4 @@ sed -i "s/%PROJECT_VERSION%/$project_version/g" ./.github/doxygen/Doxyfile project_name="$(head -n 1 README.md | sed 's/#//')" -sed -i "s/%PROJECT_NAME%/$project_name/g" ./.github/doxygen/Doxyfile \ No newline at end of file +sed -i "s/%PROJECT_NAME%/$project_name/g" ./.github/doxygen/Doxyfile diff --git a/.github/scripts/prepare_doxygen.sh b/.github/scripts/prepare_doxygen.sh index 543d953..f87b122 100644 --- a/.github/scripts/prepare_doxygen.sh +++ b/.github/scripts/prepare_doxygen.sh @@ -36,6 +36,3 @@ sed -i "2s/.*/title: $project_name/" _config.yml cd .. echo "Local docs update finished." - - - diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..e3d536b --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,50 @@ +name: Build and test code + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + + strategy: + matrix: + env: + - toolchain: "toolchain/gcc-linux.cmake" + runner: ubuntu-latest + generator: "" + - toolchain: "toolchain/clang-macos.cmake" + runner: macos-latest + generator: "" + - toolchain: "\"toolchain/clang-windows.cmake\"" + runner: windows-latest + generator: "-G \"Visual Studio 17 2022\"" + + runs-on: ${{ matrix.env.runner }} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install Linux reqs + if: ${{ matrix.env.runner == 'ubuntu-latest' }} + run: | + sudo apt-get update + sudo apt-get install -y clang cmake cppcheck clang-format clang-tidy gcc pre-commit + + - name: Install macOS reqs + if: ${{ matrix.env.runner == 'macos-latest' }} + run: | + brew install llvm cmake cppcheck clang-format gcc pre-commit + + - name: Build + run: | + cmake ${{ matrix.env.generator }} -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ matrix.env.toolchain }} + cmake --build build -j8 + + # - name: Run Linux/macOS tests + # if: ${{ matrix.env.runner == 'ubuntu-latest' || matrix.env.runner == 'macos-latest' }} + # run: | + # ./build/bin/keyplecardgenericcpplib_ut diff --git a/.github/workflows/publish-doc-release.yml b/.github/workflows/publish-doc-release.yml index 5c65148..16c1211 100644 --- a/.github/workflows/publish-doc-release.yml +++ b/.github/workflows/publish-doc-release.yml @@ -38,4 +38,4 @@ jobs: git commit -m "docs: update ${{ github.event.inputs.version || github.ref_name }} documentation" git push origin doc --force env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8292a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build directories +build +out + +# IDE files +CMakeSettings.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8a705b1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,52 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +fail_fast: false + +repos: + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: master + hooks: + - id: clang-tidy + name: clang-tidy + entry: clang-tidy -p=build + --system-headers + --fix-errors + + # Code formatting (see .clang-format for config used). + - id: clang-format + name: clang-format + args: [-i] + + # Static code analysis (for C++ files). + - id: cppcheck + name: cppcheck + args: [--enable=all, + --error-exitcode=1, + --language=c++, + --std=c++11, + --suppressions-list=./.cppcheck.suppress] + files: \.(cpp|hpp)$ + + # Coding style analysis. Based on Google C++ code style. + # cpplint configuration can be found in CPPLINT.cfg. + - id: cpplint diff --git a/CMakeLists.txt b/CMakeLists.txt index df0caac..496b2ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,24 @@ -# ************************************************************************************************* -# Copyright (c) 2023 Calypso Networks Association https://calypsonet.org/ * -# * -# See the NOTICE file(s) distributed with this work for additional information regarding * -# copyright ownership. * -# * -# This program and the accompanying materials are made available under the terms of the Eclipse * -# Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * -# SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ - -PROJECT(KeypleCardGenericCppLib C CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 3.0) - -SET(CMAKE_PROJECT_VERSION_MAJOR "2") -SET(CMAKE_PROJECT_VERSION_MINOR "0") -SET(CMAKE_PROJECT_VERSION_PATCH "4") +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +PROJECT(KeypleCardGenericCppLib + VERSION 3.1.2 + LANGUAGES C CXX) + +SET(CMAKE_PROJECT_VERSION_MAJOR "3") +SET(CMAKE_PROJECT_VERSION_MINOR "1") +SET(CMAKE_PROJECT_VERSION_PATCH "2") SET(CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}. ${CMAKE_PROJECT_VERSION_MINOR}. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c347b27..33bd8b6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -90,4 +90,4 @@ The Eclipse Foundation Board of Directors may amend this Code from time to time This Code was inspired by the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). -[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. \ No newline at end of file +[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e99c61c..5052fad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,38 +2,38 @@ **Welcome to the Eclipse Keyple Community!** -We are thrilled to have you onboard and look forward to your contributions. Whether you're a coder, designer, -documenter, or enthusiast, your involvement is invaluable to us. Here's how you can start contributing to Eclipse +We are thrilled to have you onboard and look forward to your contributions. Whether you're a coder, designer, +documenter, or enthusiast, your involvement is invaluable to us. Here's how you can start contributing to Eclipse Keyple: ## Quick Start 1. **Read the Contribution Guidelines**: Before starting, please visit our detailed contributing guide at the -[Eclipse Keyple Contribution Guide](https://keyple.org/community/contributing/). +[Eclipse Keyple Contribution Guide](https://keyple.org/community/contributing/). This guide covers all the necessary information about contributing to the project. -2. **Join the mailing list**: Connect with other contributors on our -[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). +2. **Join the mailing list**: Connect with other contributors on our +[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). It's a great place to ask questions, share ideas, and collaborate. 3. **Explore Open Issues**: Check out the issues tab in our GitHub repository. ## How to Contribute -- **Code**: Submit pull requests with bug fixes, new features, and improvements. Make sure to follow the code style and +- **Code**: Submit pull requests with bug fixes, new features, and improvements. Make sure to follow the code style and testing guidelines. - **Documentation**: Help us improve our documentation by fixing errors, adding examples, or writing tutorials. -- **Feedback**: Share your experience using Eclipse Keyple. Feedback on usability, features, and your overall experience +- **Feedback**: Share your experience using Eclipse Keyple. Feedback on usability, features, and your overall experience is incredibly valuable. -- **Community Support**: Answer questions on the community forums, help with user support, and participate in +- **Community Support**: Answer questions on the community forums, help with user support, and participate in discussions. ## Need Help? -If you have any questions or need assistance, please reach out on the +If you have any questions or need assistance, please reach out on the [mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). --- diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..b8d9efb --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,16 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +set noparent +filter=-whitespace/indent,-build/c++11,-runtime/references,-whitespace/braces,-whitespace/blank_line,-runtime/string +linelength=80 diff --git a/LICENSE b/LICENSE index d3087e4..e48e096 100644 --- a/LICENSE +++ b/LICENSE @@ -261,8 +261,8 @@ No third-party beneficiary rights are created under this Agreement. Exhibit A - Form of Secondary Licenses Notice -"This Source Code may also be made available under the following -Secondary Licenses when the conditions for such availability set forth +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}." diff --git a/NOTICE.md b/NOTICE.md index 1032ec8..bb75df5 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -5,11 +5,11 @@ This content is produced and maintained by the Eclipse Keyple project. * Project home: https://projects.eclipse.org/projects/iot.keyple ## Trademarks - + * Eclipse Keyple and the Eclipse Keyple project are Trademarks of the Eclipse Foundation, Inc. * Eclipse® is a Trademark of the Eclipse Foundation, Inc. * Eclipse Foundation is a Trademark of the Eclipse Foundation, Inc. - + ## Copyright All content is the property of the respective authors or their employers. @@ -23,7 +23,7 @@ of the Eclipse Public License v. 2.0 which is available at http://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html SPDX-License-Identifier: EPL-2.0 - + ## Third-party Content Calypsonet Terminal Reader API (1.0.0) diff --git a/SECURITY.md b/SECURITY.md index bfb9250..0b90d27 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,4 +6,4 @@ This project implements the Eclipse Foundation Security Policy ## Reporting a Vulnerability -Please report vulnerabilities to the Eclipse Foundation Security Team at security@eclipse.org \ No newline at end of file +Please report vulnerabilities to the Eclipse Foundation Security Team at security@eclipse.org diff --git a/src/main/ApduRequestAdapter.h b/include/keyple/card/generic/ApduRequestAdapter.hpp similarity index 65% rename from src/main/ApduRequestAdapter.h rename to include/keyple/card/generic/ApduRequestAdapter.hpp index 6e15f3d..afa8a04 100644 --- a/src/main/ApduRequestAdapter.h +++ b/include/keyple/card/generic/ApduRequestAdapter.hpp @@ -1,14 +1,15 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ #pragma once @@ -17,14 +18,13 @@ #include #include -/* Calypsonet Terminal Card */ -#include "ApduRequestSpi.h" +#include "keypop/card/spi/ApduRequestSpi.hpp" namespace keyple { namespace card { namespace generic { -using namespace calypsonet::terminal::card::spi; +using keypop::card::spi::ApduRequestSpi; /** * (package-private)
@@ -37,17 +37,20 @@ class ApduRequestAdapter final : public ApduRequestSpi { /** * Builds an APDU request from a raw byte buffer. * - *

The default status words list is initialized with the standard successful code 9000h. + *

The default status words list is initialized with the standard + * successful code 9000h. * * @param apdu The bytes of the APDU's body. * @since 2.0.0 */ - ApduRequestAdapter(const std::vector& apdu); + explicit ApduRequestAdapter(const std::vector& apdu); /** - * Adds a status word to the list of those that should be considered successful for the APDU. + * Adds a status word to the list of those that should be considered + * successful for the APDU. * - *

Note: initially, the list contains the standard successful status word {@code 9000h}. + *

Note: initially, the list contains the standard successful status word + * 9000h. * * @param successfulStatusWord A positive int ≤ {@code FFFFh}. * @return The current instance. @@ -58,8 +61,9 @@ class ApduRequestAdapter final : public ApduRequestSpi { /** * Information about the APDU request. * - *

This string is dedicated to improve the readability of logs and should therefore only be - * invoked conditionally (e.g. when log level >= debug). + *

This string is dedicated to improve the readability of logs and should + * therefore only be invoked conditionally (e.g. when log level >= + * debug). * * @param info The request info (free text). * @return The current instance. @@ -72,7 +76,14 @@ class ApduRequestAdapter final : public ApduRequestSpi { * * @since 2.0.0 */ - std::vector& getApdu() override; + const std::vector& getApdu() const override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + void setApdu(const std::vector& apdu) override; /** * {@inheritDoc} @@ -91,7 +102,8 @@ class ApduRequestAdapter final : public ApduRequestSpi { /** * */ - friend std::ostream& operator<<(std::ostream& os, const std::shared_ptr ara); + friend std::ostream& + operator<<(std::ostream& os, const std::shared_ptr ara); private: /** @@ -115,6 +127,6 @@ class ApduRequestAdapter final : public ApduRequestSpi { std::string mInfo; }; -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/CardRequestAdapter.h b/include/keyple/card/generic/CardRequestAdapter.hpp similarity index 52% rename from src/main/CardRequestAdapter.h rename to include/keyple/card/generic/CardRequestAdapter.hpp index 87d2b57..ee1d70c 100644 --- a/src/main/CardRequestAdapter.h +++ b/include/keyple/card/generic/CardRequestAdapter.hpp @@ -1,59 +1,63 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ #pragma once #include #include -/* Calypsonet Terminal Card */ -#include "CardRequestSpi.h" +#include "keypop/card/spi/ApduRequestSpi.hpp" +#include "keypop/card/spi/CardRequestSpi.hpp" namespace keyple { namespace card { namespace generic { -using namespace calypsonet::terminal::card::spi; +using keypop::card::spi::ApduRequestSpi; +using keypop::card::spi::CardRequestSpi; /** - * (package-private)
- * This POJO contains an ordered list of {@link ApduRequestSpi} and the associated status word check - * policy. + * This POJO contains an ordered list of {@link ApduRequestSpi} and the + * associated status word check policy. * * @since 2.0.0 */ class CardRequestAdapter final : public CardRequestSpi { public: /** - * Builds a card request with a list of {@link ApduRequestSpi } and the flag indicating the - * expected response checking behavior. + * Builds a card request with a list of {@link ApduRequestSpi } and the flag + * indicating the expected response checking behavior. * - *

When the status word verification is enabled, the transmission of the APDUs must be - * interrupted as soon as the status word of a response is unexpected. + *

When the status word verification is enabled, the transmission of the + * APDUs must be interrupted as soon as the status word of a response is + * unexpected. * * @param apduRequests A not empty list. - * @param stopOnUnsuccessfulStatusWord True if the transmission must be stopped when an unexpected - * status word is received. + * @param stopOnUnsuccessfulStatusWord True if the transmission must be + * stopped when an unexpected status word is received. * @since 2.0.0 */ - CardRequestAdapter(const std::vector>& apduRequests, - const bool stopOnUnsuccessfulStatusWord); + CardRequestAdapter( + const std::vector>& apduRequests, + const bool stopOnUnsuccessfulStatusWord); /** * {@inheritDoc} * * @since 2.0.0 */ - const std::vector>& getApduRequests() const override; + const std::vector>& + getApduRequests() const override; /** * {@inheritDoc} @@ -64,16 +68,16 @@ class CardRequestAdapter final : public CardRequestSpi { private: /** - * + * */ const std::vector> mApduRequests; - + /** - * + * */ const bool mStopOnUnsuccessfulStatusWord; }; -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/CardTransactionManager.hpp b/include/keyple/card/generic/CardTransactionManager.hpp new file mode 100644 index 0000000..bee8cdc --- /dev/null +++ b/include/keyple/card/generic/CardTransactionManager.hpp @@ -0,0 +1,144 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "keyple/card/generic/ChannelControl.hpp" + +namespace keyple { +namespace card { +namespace generic { + +/** + * Provides basic methods to prepare and process APDU exchange with a card. + */ +class CardTransactionManager { +public: + /** + * + */ + virtual ~CardTransactionManager() = default; + + /** + * Prepares an APDU to be transmitted the next time + * processApdusToByteArrays(ChannelControl) is invoked. + * + * @param apduCommand A not empty hexadecimal string containing a raw APDU + * command. + * @return This instance. + * @since 2.0.0 + */ + virtual CardTransactionManager& prepareApdu(const std::string& apduCommand) + = 0; + + /** + * Prepares an APDU to be transmitted the next time + * processApdusToByteArrays(ChannelControl) is invoked. + * + * @param apduCommand A not empty const uint8_t arrays containing raw APDU + * commands. + * @return This instance. + * @since 2.0.0 + */ + virtual CardTransactionManager& + prepareApdu(const std::vector& apduCommand) + = 0; + + /** + * Prepares an APDU to be transmitted the next time + * processApdusToByteArrays(ChannelControl) is invoked. + * + * @param cla The class const uint8_t. + * @param ins The instruction const uint8_t. + * @param p1 The P1 parameter. + * @param p2 The P2 parameter. + * @param dataIn The APDU data, null if there is no data. + * @param le The expected output length, 0 if the output length is + * unspecified, null if no output data is expected. + * @return This instance. + * @since 2.0.0 + */ + virtual CardTransactionManager& prepareApdu( + const uint8_t cla, + const uint8_t ins, + const uint8_t p1, + const uint8_t p2, + const std::vector& dataIn, + const uint8_t le) + = 0; + + /** + * Prepares an APDU to be transmitted the next time + * processApdusToByteArrays() is invoked. + * + * @param cla The class const uint8_t. + * @param ins The instruction const uint8_t. + * @param p1 The P1 parameter. + * @param p2 The P2 parameter. + * @param dataIn The APDU data, null if there is no data. + * + * @return This instance. + * @since 2.0.0 + */ + virtual CardTransactionManager& prepareApdu( + const uint8_t cla, + const uint8_t ins, + const uint8_t p1, + const uint8_t p2, + const std::vector& dataIn) + = 0; + + /** + * Transmits all prepared APDUs, closes the physical channel if required, + * and returns a list of responses to the APDUs in the form of list of of + * const uint8_t arrays. + * + *

If the prepared APDU list is empty an empty list is returned. + * + *

The prepared APDU list is cleared after this method has been invoked. + * + * @param channelControl Policy for managing the physical channel after + * executing commands to the card. + * @return A not null reference. + * @throw TransactionException If the communication with the card or the + * reader has failed. + */ + virtual const std::vector> + processApdusToByteArrays(ChannelControl channelControl) = 0; + + /** + * Transmits all prepared APDUs, closes the physical channel if required, + * and returns a list of responses to the APDUs in the form of list of + * hexadecimal strings. + * + *

If the prepared APDU list is empty an empty list is returned. + * + *

The prepared APDU list is cleared after this method has been invoked. + * + * @param channelControl Policy for managing the physical channel after + * executing commands to the card. + * @return A not null reference. + * @throw TransactionException If the communication with the card or the + * reader has failed. + */ + virtual const std::vector + processApdusToHexStrings(ChannelControl channelControl) = 0; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/CardTransactionManagerAdapter.hpp b/include/keyple/card/generic/CardTransactionManagerAdapter.hpp new file mode 100644 index 0000000..c5e1707 --- /dev/null +++ b/include/keyple/card/generic/CardTransactionManagerAdapter.hpp @@ -0,0 +1,130 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "keyple/card/generic/CardTransactionManager.hpp" +#include "keyple/card/generic/ChannelControl.hpp" +#include "keypop/card/spi/ApduRequestSpi.hpp" +#include "keypop/reader/CardReader.hpp" +#include "keypop/reader/selection/spi/SmartCard.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keypop::card::spi::ApduRequestSpi; +using keypop::reader::CardReader; +using keypop::reader::selection::spi::SmartCard; + +/** + * Implementation of CardTransactionManager. + * + * @since 2.0.0 + */ +class CardTransactionManagerAdapter final : public CardTransactionManager { +public: + /** + * + */ + static const std::string APDU_COMMAND; + + /** + * Creates an instance of CardTransactionManager. + * + * @param reader The reader through which the card communicates. + * @param card The initial card data provided by the selection process. + * @throw IllegalArgumentException If the card resource or one of its + * components is null. + * @since 2.0.0 + */ + CardTransactionManagerAdapter( + std::shared_ptr reader, + const std::shared_ptr card); + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + CardTransactionManager& + prepareApdu(const std::string& apduCommand) override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + CardTransactionManager& + prepareApdu(const std::vector& apduCommand) override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + CardTransactionManager& prepareApdu( + const uint8_t cla, + const uint8_t ins, + const uint8_t p1, + const uint8_t p2, + const std::vector& dataIn, + const uint8_t le) override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + CardTransactionManager& prepareApdu( + const uint8_t cla, + const uint8_t ins, + const uint8_t p1, + const uint8_t p2, + const std::vector& dataIn) override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::vector> + processApdusToByteArrays(const ChannelControl channelControl) override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::vector + processApdusToHexStrings(ChannelControl channelControl) override; + +private: + /** + * + */ + std::shared_ptr mReader; + + /** + * + */ + std::vector> mApduRequests; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/ChannelControl.hpp b/include/keyple/card/generic/ChannelControl.hpp new file mode 100644 index 0000000..62fb218 --- /dev/null +++ b/include/keyple/card/generic/ChannelControl.hpp @@ -0,0 +1,45 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +namespace keyple { +namespace card { +namespace generic { + +/** + * Policy for managing the physical channel after a card request is executed. + * + * @since 3.0.0 + */ +enum class ChannelControl { + /** + * Leaves the physical channel open. + * + * @since 3.0.0 + */ + KEEP_OPEN, + + /** + * Terminates communication with the card.
+ * The physical channel closes instantly or a card removal sequence is + * initiated depending on the observation mode. + * + * @since 3.0.0 + */ + CLOSE_AFTER +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericCardAdapter.hpp b/include/keyple/card/generic/GenericCardAdapter.hpp new file mode 100644 index 0000000..b24bf70 --- /dev/null +++ b/include/keyple/card/generic/GenericCardAdapter.hpp @@ -0,0 +1,80 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "keypop/card/CardSelectionResponseApi.hpp" +#include "keypop/card/spi/SmartCardSpi.hpp" +#include "keypop/reader/selection/spi/IsoSmartCard.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keypop::card::CardSelectionResponseApi; +using keypop::card::spi::SmartCardSpi; +using keypop::reader::selection::spi::IsoSmartCard; + +/** + * (package-private)
+ * Implementation of a generic {@link SmartCard}. + * + * @since 2.0.0 + */ +class GenericCardAdapter final : public IsoSmartCard, public SmartCardSpi { +public: + /** + * Constructor + * + *

Gets ATR and FCI from the CardSelectionResponseApi if they exist (both + * are optional). + * + * @param cardSelectionResponse The CardSelectionResponseApi from the + * selection process. + */ + explicit GenericCardAdapter( + std::shared_ptr cardSelectionResponse); + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::string& getPowerOnData() const override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + std::vector getSelectApplicationResponse() const override; + +private: + /** + * + */ + const std::vector mSelectApplicationResponse; + + /** + * + */ + const std::string mPowerOnData; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericCardResourceProfileExtensionAdapter.hpp b/include/keyple/card/generic/GenericCardResourceProfileExtensionAdapter.hpp new file mode 100644 index 0000000..87d5fad --- /dev/null +++ b/include/keyple/card/generic/GenericCardResourceProfileExtensionAdapter.hpp @@ -0,0 +1,97 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include + +#include "keyple/card/generic/GenericCardSelectionExtension.hpp" +#include "keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp" +#include "keyple/core/service/resource/spi/CardResourceProfileExtension.hpp" +#include "keyple/core/util/cpp/Logger.hpp" +#include "keyple/core/util/cpp/LoggerFactory.hpp" +#include "keypop/reader/CardReader.hpp" +#include "keypop/reader/ReaderApiFactory.hpp" +#include "keypop/reader/selection/IsoCardSelector.hpp" +#include "keypop/reader/selection/spi/SmartCard.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keyple::core::service::resource::spi::CardResourceProfileExtension; +using keyple::core::util::cpp::Logger; +using keyple::core::util::cpp::LoggerFactory; +using keypop::reader::CardReader; +using keypop::reader::ReaderApiFactory; +using keypop::reader::selection::IsoCardSelector; +using keypop::reader::selection::spi::SmartCard; + +/** + * Implementation of CardResourceProfileExtension that provides the capability + * to filter cards of any type. + * + * @since 2.0.0 + */ +class GenericCardResourceProfileExtensionAdapter final +: public CardResourceProfileExtension { +public: + /** + * @param cardSelector An ISO card selector. + * @param genericCardSelectionExtension The generic card selection + * extension. + * @since 2.0.0 + */ + GenericCardResourceProfileExtensionAdapter( + std::shared_ptr cardSelector, + std::shared_ptr + genericCardSelectionExtension); + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + std::shared_ptr matches( + std::shared_ptr reader, + std::shared_ptr readerApiFactory) override; + + /** + * {@inheritDoc} + * + * @since 3.1.0 + */ + std::shared_ptr + matches(std::shared_ptr smartCard) override; + +private: + /** + * + */ + const std::unique_ptr mLogger = LoggerFactory::getLogger( + typeid(GenericCardResourceProfileExtensionAdapter)); + + /** + * + */ + std::shared_ptr mGenericCardSelection; + + /** + * + */ + std::shared_ptr mCardSelector; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericCardSelectionExtension.hpp b/include/keyple/card/generic/GenericCardSelectionExtension.hpp new file mode 100644 index 0000000..28661b1 --- /dev/null +++ b/include/keyple/card/generic/GenericCardSelectionExtension.hpp @@ -0,0 +1,55 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include "keypop/reader/selection/spi/CardSelectionExtension.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keypop::reader::selection::spi::CardSelectionExtension; + +/** + * Card specific CardSelectionExtension providing means to add successful status + * word. + * + * @since 3.0.0 + */ +class GenericCardSelectionExtension : public CardSelectionExtension { +public: + /** + * + */ + virtual ~GenericCardSelectionExtension() = default; + + /** + * Adds a status word to the list of those that should be considered + * successful for the Select Application APDU. + * + *

Note: initially, the list contains the standard successful status word + * 9000h. + * + * @param statusWord A positive int ≤ {@code FFFFh}. + * @return The current instance. + * @since 2.0.0 + */ + virtual GenericCardSelectionExtension& + addSuccessfulStatusWord(const int statusWord) + = 0; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp b/include/keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp new file mode 100644 index 0000000..0ab982b --- /dev/null +++ b/include/keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp @@ -0,0 +1,88 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/card/generic/GenericCardSelectionExtension.hpp" +#include "keypop/card/CardSelectionResponseApi.hpp" +#include "keypop/card/spi/CardSelectionExtensionSpi.hpp" +#include "keypop/card/spi/CardSelectionRequestSpi.hpp" +#include "keypop/card/spi/SmartCardSpi.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keypop::card::CardSelectionResponseApi; +using keypop::card::spi::CardSelectionExtensionSpi; +using keypop::card::spi::CardSelectionRequestSpi; +using keypop::card::spi::SmartCardSpi; + +/** + * Implementation of GenericCardSelectionExtension. + * + * @since 2.0.0 + */ +class GenericCardSelectionExtensionAdapter +: public GenericCardSelectionExtension, + public CardSelectionExtensionSpi { +public: + /** + * Creates an instance. + * + * @since 2.0.0 + */ + GenericCardSelectionExtensionAdapter(); + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + std::shared_ptr getCardSelectionRequest() override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + std::shared_ptr parse( + const std::shared_ptr& cardSelectionResponse) + override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + GenericCardSelectionExtension& + addSuccessfulStatusWord(const int statusWord) override; + +private: + /** + * + */ + static const int DEFAULT_SUCCESSFUL_CODE; + + /** + * + */ + std::vector mSuccessfulSelectionStatusWords; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericCardSelectionRequestAdapter.hpp b/include/keyple/card/generic/GenericCardSelectionRequestAdapter.hpp new file mode 100644 index 0000000..97288db --- /dev/null +++ b/include/keyple/card/generic/GenericCardSelectionRequestAdapter.hpp @@ -0,0 +1,88 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "keypop/card/spi/CardRequestSpi.hpp" +#include "keypop/card/spi/CardSelectionRequestSpi.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keypop::card::spi::CardRequestSpi; +using keypop::card::spi::CardSelectionRequestSpi; + +/** + * Implementation of CardSelectionRequestSpi. + * + * @since 2.0.0 + */ +class GenericCardSelectionRequestAdapter final +: public CardSelectionRequestSpi { +public: + /** + * Builds a card selection request to open a logical channel with additional + * APDUs to be sent after the selection step. + * + * @param successfulSelectionStatusWords List of successful status words. + * @since 2.0.0 + */ + explicit GenericCardSelectionRequestAdapter( + const std::vector& successfulSelectionStatusWords); + + /** + * {@inheritDoc} + * + * @since 3.0.0 + */ + const std::vector& getSuccessfulSelectionStatusWords() const override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::shared_ptr getCardRequest() const override; + + /** + * {@inheritDoc} + * + * @since 3.0.0 + */ + friend std::ostream& operator<<( + std::ostream& os, const GenericCardSelectionRequestAdapter& gcsra); + + /** + * {@inheritDoc} + * + * @since 3.0.0 + */ + friend std::ostream& operator<<( + std::ostream& os, + const std::shared_ptr gcsra); + +private: + /** + * + */ + std::vector mSuccessfulSelectionStatusWords; +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/include/keyple/card/generic/GenericExtensionService.hpp b/include/keyple/card/generic/GenericExtensionService.hpp new file mode 100644 index 0000000..3dc7f17 --- /dev/null +++ b/include/keyple/card/generic/GenericExtensionService.hpp @@ -0,0 +1,131 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/card/generic/CardTransactionManager.hpp" +#include "keyple/card/generic/GenericCardSelectionExtension.hpp" +#include "keyple/card/generic/KeypleCardGenericExport.hpp" +#include "keyple/core/common/KeypleCardExtension.hpp" +#include "keyple/core/service/resource/spi/CardResourceProfileExtension.hpp" +#include "keypop/reader/CardReader.hpp" +#include "keypop/reader/selection/IsoCardSelector.hpp" +#include "keypop/reader/selection/spi/SmartCard.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keyple::card::generic::GenericCardSelectionExtension; +using keyple::core::common::KeypleCardExtension; +using keyple::core::service::resource::spi::CardResourceProfileExtension; +using keypop::reader::CardReader; +using keypop::reader::selection::IsoCardSelector; +using keypop::reader::selection::spi::SmartCard; + +/** + * Card extension service providing basic access to APDU exchange functions with + * a card. + * + * @since 2.0.0 + */ +class KEYPLECARDGENERIC_API GenericExtensionService final +: public KeypleCardExtension { +public: + /** + * Gets the unique instance of this object. + * + * @return A not null reference. + */ + static std::shared_ptr getInstance(); + + /** + * Creates an instance of CardSelectionExtension. + * + * @return A not null reference. + * @since 2.0.0 + */ + std::shared_ptr + createGenericCardSelectionExtension(); + + /** + * Creates an instance of CardTransactionManager. + * + * @param reader The reader through which the card communicates. + * @param card The initial card data provided by the selection process. + * @return A not null reference. + * @since 2.0.0 + */ + std::shared_ptr createCardTransaction( + std::shared_ptr reader, std::shared_ptr card); + + /** + * Creates an instance of CardResourceProfileExtension to be provided to the + * keyple::core::service::resource::CardResourceService. + * + *

The provided argument defines the selection rules to be applied to the + * card when detected by the card resource service. + * + * @param cardSelector The ISO card selector targeting the expected card + * profile. + * @param genericCardSelectionExtension A not null generic card extension. + * @return A not null reference. + * @throws IllegalArgumentException If genericCardSelectionExtension is + * null. + * @since 2.0.0 + */ + std::shared_ptr + createCardResourceProfileExtension( + const std::shared_ptr cardSelector, + const std::shared_ptr + genericCardSelectionExtension); + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::string getCardApiVersion() const override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::string getReaderApiVersion() const override; + + /** + * {@inheritDoc} + * + * @since 2.0.0 + */ + const std::string getCommonApiVersion() const override; + +private: + /** + * + */ + static std::shared_ptr mInstance; + + /** + * Constructor + */ + GenericExtensionService(); +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/KeypleCardGenericExport.h b/include/keyple/card/generic/KeypleCardGenericExport.hpp similarity index 55% rename from src/main/KeypleCardGenericExport.h rename to include/keyple/card/generic/KeypleCardGenericExport.hpp index 9e38eda..966fa2e 100644 --- a/src/main/KeypleCardGenericExport.h +++ b/include/keyple/card/generic/KeypleCardGenericExport.hpp @@ -1,14 +1,15 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ #pragma once diff --git a/include/keyple/card/generic/TransactionException.hpp b/include/keyple/card/generic/TransactionException.hpp new file mode 100644 index 0000000..cb9adc5 --- /dev/null +++ b/include/keyple/card/generic/TransactionException.hpp @@ -0,0 +1,75 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/core/util/cpp/exception/RuntimeException.hpp" + +namespace keyple { +namespace card { +namespace generic { + +using keyple::core::util::cpp::exception::RuntimeException; + +/** + * Exception when an error or a communication failure with the card or the + * reader occurs. + * + * @since 2.0.0 + */ +class TransactionException : public RuntimeException { +public: + /** + * Builds a new exception. + * + * @param message Message to identify the exception context. + * @since 2.0.0 + */ + explicit TransactionException(const std::string& message) + : RuntimeException(message) + { + } + + /** + * Builds a new exception with the originating exception. + * + * @param message Message to identify the exception context. + * @param cause The cause + * @since 2.0.0 + */ + TransactionException( + const std::string& message, const std::shared_ptr cause) + : RuntimeException(message, cause) + { + } + + /** + * Builds a new exception with the originating exception. + * + * @param message Message to identify the exception context. + * @param cause The cause + * @since 2.0.0 + */ + TransactionException( + const std::string& message, const std::shared_ptr) + : RuntimeException(message) + { + } +}; + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/ApduRequestAdapter.cpp b/src/main/ApduRequestAdapter.cpp index cf90e4c..8b9e2f0 100644 --- a/src/main/ApduRequestAdapter.cpp +++ b/src/main/ApduRequestAdapter.cpp @@ -1,19 +1,23 @@ -/************************************************************************************************** - * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "ApduRequestAdapter.h" - -/* Keyple Core Util */ -#include "KeypleStd.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/ApduRequestAdapter.hpp" + +#include +#include +#include + +#include "keyple/core/util/cpp/KeypleStd.hpp" namespace keyple { namespace card { @@ -22,49 +26,63 @@ namespace generic { const int ApduRequestAdapter::DEFAULT_SUCCESSFUL_CODE = 0x9000; ApduRequestAdapter::ApduRequestAdapter(const std::vector& apdu) -: mApdu(apdu), mSuccessfulStatusWords({ApduRequestAdapter::DEFAULT_SUCCESSFUL_CODE}) {} +: mApdu(apdu) +, mSuccessfulStatusWords({ApduRequestAdapter::DEFAULT_SUCCESSFUL_CODE}) +{ +} -ApduRequestAdapter& ApduRequestAdapter::addSuccessfulStatusWord(const int successfulStatusWord) +ApduRequestAdapter& +ApduRequestAdapter::addSuccessfulStatusWord(const int successfulStatusWord) { mSuccessfulStatusWords.push_back(successfulStatusWord); return *this; } -ApduRequestAdapter& ApduRequestAdapter::setInfo(const std::string& info) +ApduRequestAdapter& +ApduRequestAdapter::setInfo(const std::string& info) { mInfo = info; return *this; } -std::vector& ApduRequestAdapter::getApdu() +const std::vector& +ApduRequestAdapter::getApdu() const { return mApdu; } -const std::vector& ApduRequestAdapter::getSuccessfulStatusWords() const +void +ApduRequestAdapter::setApdu(const std::vector& apdu) +{ + mApdu = apdu; +} + +const std::vector& +ApduRequestAdapter::getSuccessfulStatusWords() const { return mSuccessfulStatusWords; } -const std::string& ApduRequestAdapter::getInfo() const +const std::string& +ApduRequestAdapter::getInfo() const { return mInfo; } -std::ostream& operator<<(std::ostream& os, const std::shared_ptr ara) +std::ostream& +operator<<(std::ostream& os, const std::shared_ptr ara) { os << "APDU_REQUEST_ADAPTER: {" << "DEFAULT_SUCCESSFUL_CODE = " << ara->DEFAULT_SUCCESSFUL_CODE << ", " << "APDU = " << ara->mApdu << ", " << "SUCCESSFUL_STATUS_WORD = " << ara->mSuccessfulStatusWords << ", " - << "INFO = " << ara->mInfo - << "}"; + << "INFO = " << ara->mInfo << "}"; return os; } -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 181e644..e81abb3 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,19 +1,24 @@ -#/************************************************************************************************* -# * Copyright (c) 2023 Calypso Networks Association https://calypsonet.org/ * -# * * -# * See the NOTICE file(s) distributed with this work for additional information regarding * -# * copyright ownership. * -# * * -# * This program and the accompanying materials are made available under the terms of the Eclipse * -# * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * -# * * -# * SPDX-License-Identifier: EPL-2.0 * -# *************************************************************************************************/ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ SET(LIBRARY_NAME keyplecardgenericcpplib) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKEYPLECARDGENERIC_EXPORT") +INCLUDE("CMakeLists.txt.keypop-card") +INCLUDE("CMakeLists.txt.keyple-service-resource") +INCLUDE("CMakeLists.txt.keyple-util") + ADD_LIBRARY( ${LIBRARY_NAME} @@ -22,13 +27,12 @@ ADD_LIBRARY( ${CMAKE_CURRENT_SOURCE_DIR}/ApduRequestAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CardRequestAdapter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/CardSelectorAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CardTransactionManagerAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GenericCardAdapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/GenericCardSelectionExtensionAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GenericCardResourceProfileExtensionAdapter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/GenericCardSelectionAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GenericCardSelectionRequestAdapter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/GenericExtensionService.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/GenericExtensionService.cpp ) TARGET_INCLUDE_DIRECTORIES( @@ -37,18 +41,25 @@ TARGET_INCLUDE_DIRECTORIES( PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} + $ ) TARGET_LINK_LIBRARIES( - - ${LIBRARY_NAME} - + + ${LIBRARY_NAME} + PUBLIC - - CalypsoNet::TerminalCard - Keyple::ServiceResource + + Keypop::Card + Keyple::Service::Resource Keyple::Util ) -ADD_LIBRARY(Keyple::CardGeneric ALIAS ${LIBRARY_NAME}) +ADD_LIBRARY( + + Keyple::Card::Generic + + ALIAS + + ${LIBRARY_NAME} +) diff --git a/src/main/CMakeLists.txt.keyple-service-resource b/src/main/CMakeLists.txt.keyple-service-resource new file mode 100644 index 0000000..5161d00 --- /dev/null +++ b/src/main/CMakeLists.txt.keyple-service-resource @@ -0,0 +1,43 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypleserviceresourcecpplib-src") + + MESSAGE("-- > Fetching keyple service resource from keyple card generic") + + # Checkout Keyple Service Resource Cpp Lib dependency + FetchContent_Declare( + + KeypleServiceResourceCppLib + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keyple/keyple-service-resource-cpp-lib + GIT_TAG develop-3.1.0 + ) + +ELSE() + + FetchContent_Declare( + + KeypleServiceResourceCppLib + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypleserviceresourcecpplib-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypleServiceResourceCppLib) diff --git a/src/main/CMakeLists.txt.keyple-util b/src/main/CMakeLists.txt.keyple-util new file mode 100644 index 0000000..6b5d965 --- /dev/null +++ b/src/main/CMakeLists.txt.keyple-util @@ -0,0 +1,47 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypleutilcpplib-src") + + MESSAGE("-- > Fetching keyple util from keyple card generic") + + # FetchContent added in CMake 3.11, downloads during the configure step + # FetchContent_MakeAvailable was added in CMake 3.14; simpler usage + INCLUDE(FetchContent) + + # Checkout Keyple Util Cpp Lib dependency + FetchContent_Declare( + + KeypleUtilCppLib + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keyple/keyple-util-cpp-lib + GIT_TAG develop-2.4.0 + ) + +ELSE() + + FetchContent_Declare( + + KeypleUtilCppLib + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypleutilcpplib-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypleUtilCppLib) diff --git a/src/main/CMakeLists.txt.keypop-card b/src/main/CMakeLists.txt.keypop-card new file mode 100644 index 0000000..0cd97f5 --- /dev/null +++ b/src/main/CMakeLists.txt.keypop-card @@ -0,0 +1,43 @@ +#****************************************************************************** +#* Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +#* * +#* See the NOTICE file(s) distributed with this work for additional * +#* information regarding copyright ownership. * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the Eclipse Public License 2.0 which is available at * +#* http://www.eclipse.org/legal/epl-2.0 * +#* * +#* SPDX-License-Identifier: EPL-2.0 * +#******************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/keypopcardcppapi-src") + + MESSAGE("-- > Fetching keypop card from keyple card generic") + + # Checkout Keypop Card Cpp Api dependency + FetchContent_Declare( + + KeypopCardCppApi + + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/eclipse-keypop/keypop-card-cpp-api + GIT_TAG develop-2.0.1 + ) + +ELSE() + + FetchContent_Declare( + + KeypopCardCppApi + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/keypopcardcppapi-src + ) + +ENDIF() + +FetchContent_MakeAvailable(KeypopCardCppApi) diff --git a/src/main/CardRequestAdapter.cpp b/src/main/CardRequestAdapter.cpp index 5142ba2..09c9eca 100644 --- a/src/main/CardRequestAdapter.cpp +++ b/src/main/CardRequestAdapter.cpp @@ -1,36 +1,42 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ -#include "CardRequestAdapter.h" +#include "keyple/card/generic/CardRequestAdapter.hpp" namespace keyple { namespace card { namespace generic { CardRequestAdapter::CardRequestAdapter( - const std::vector>& apduRequests, - const bool stopOnUnsuccessfulStatusWord) -: mApduRequests(apduRequests), mStopOnUnsuccessfulStatusWord(stopOnUnsuccessfulStatusWord) {} + const std::vector>& apduRequests, + const bool stopOnUnsuccessfulStatusWord) +: mApduRequests(apduRequests) +, mStopOnUnsuccessfulStatusWord(stopOnUnsuccessfulStatusWord) +{ +} -const std::vector>& CardRequestAdapter::getApduRequests() const +const std::vector>& +CardRequestAdapter::getApduRequests() const { return mApduRequests; } -bool CardRequestAdapter::stopOnUnsuccessfulStatusWord() const +bool +CardRequestAdapter::stopOnUnsuccessfulStatusWord() const { return mStopOnUnsuccessfulStatusWord; } -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/CardSelectorAdapter.cpp b/src/main/CardSelectorAdapter.cpp deleted file mode 100644 index 04241a4..0000000 --- a/src/main/CardSelectorAdapter.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "CardSelectorAdapter.h" - -/* Keyple Core Util */ -#include "ByteArrayUtil.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace keyple::core::util; - -const int CardSelectorAdapter::DEFAULT_SUCCESSFUL_CODE = 0x9000; - -CardSelectorAdapter::CardSelectorAdapter() -: mFileOccurrence(FileOccurrence::FIRST), - mFileControlInformation(FileControlInformation::FCI), - mSuccessfulSelectionStatusWords({CardSelectorAdapter::DEFAULT_SUCCESSFUL_CODE}) {} - -CardSelectorSpi& CardSelectorAdapter::filterByCardProtocol(const std::string& cardProtocol) -{ - mCardProtocol = cardProtocol; - - return *this; -} - -CardSelectorSpi& CardSelectorAdapter::filterByPowerOnData(const std::string& powerOnDataRegex) -{ - mPowerOnDataRegex = powerOnDataRegex; - - return *this; -} - -CardSelectorSpi& CardSelectorAdapter::filterByDfName(const std::vector& aid) -{ - mAid = aid; - - return *this; -} - -CardSelectorSpi& CardSelectorAdapter::filterByDfName(const std::string& aid) -{ - return filterByDfName(ByteArrayUtil::fromHex(aid)); -} - -CardSelectorSpi& CardSelectorAdapter::setFileOccurrence(const FileOccurrence fileOccurrence) -{ - mFileOccurrence = fileOccurrence; - - return *this; -} - -CardSelectorSpi& CardSelectorAdapter::setFileControlInformation( - const FileControlInformation fileControlInformation) -{ - mFileControlInformation = fileControlInformation; - - return *this; -} - -CardSelectorSpi& CardSelectorAdapter::addSuccessfulStatusWord(const int statusWord) -{ - mSuccessfulSelectionStatusWords.push_back(statusWord); - - return *this; -} - -const std::string& CardSelectorAdapter::getCardProtocol() const -{ - return mCardProtocol; -} - -const std::string& CardSelectorAdapter::getPowerOnDataRegex() const -{ - return mPowerOnDataRegex; -} - -const std::vector& CardSelectorAdapter::getAid() const -{ - return mAid; -} - -FileOccurrence CardSelectorAdapter::getFileOccurrence() const -{ - return mFileOccurrence; -} - -FileControlInformation CardSelectorAdapter::getFileControlInformation() const -{ - return mFileControlInformation; -} - -const std::vector& CardSelectorAdapter::getSuccessfulSelectionStatusWords() const -{ - return mSuccessfulSelectionStatusWords; -} - -} -} -} diff --git a/src/main/CardSelectorAdapter.h b/src/main/CardSelectorAdapter.h deleted file mode 100644 index 23b2117..0000000 --- a/src/main/CardSelectorAdapter.h +++ /dev/null @@ -1,221 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -/* Calypsonet Terminal Card */ -#include "CardSelectorSpi.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::card::spi; - -using FileOccurrence = CardSelectorSpi::FileOccurrence; -using FileControlInformation = CardSelectorSpi::FileControlInformation; - -/** - * (package-private)
- * Implementation of {@link CardSelectorSpi}. - * - * @since 2.0.0 - */ -class CardSelectorAdapter final : public CardSelectorSpi { -public: - /** - * (package-private)
- * Created an instance of {@link CardSelectorAdapter}. - * - *

Initialize default values. - * - * @since 2.0.0 - */ - CardSelectorAdapter(); - - /** - * (package-private)
- * Sets a protocol-based filtering by defining an expected card. - * - *

If the card protocol is set, only cards using that protocol will match the card selector. - * - * @param cardProtocol A not empty String. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& filterByCardProtocol(const std::string& cardProtocol); - - /** - * (package-private)
- * Sets a power-on data-based filtering by defining a regular expression that will be applied to - * the card's power-on data. - * - *

If it is set, only the cards whose power-on data is recognized by the provided regular - * expression will match the card selector. - * - * @param powerOnDataRegex A valid regular expression - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& filterByPowerOnData(const std::string& powerOnDataRegex); - - /** - * (package-private)
- * Sets a DF Name-based filtering by defining in a byte array the AID that will be included in - * the standard SELECT APPLICATION command sent to the card during the selection process. - * - *

The provided AID can be a right truncated image of the target DF Name - * (see ISO 7816-4 4.2). - * - * @param aid A byte array containing 5 to 16 bytes. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& filterByDfName(const std::vector& aid); - - /** - * (package-private)
- * Sets a DF Name-based filtering by defining in a hexadecimal string the AID that will be - * included in the standard SELECT APPLICATION command sent to the card during the selection - * process. - * - *

The provided AID can be a right truncated image of the target DF Name - * (see ISO 7816-4 4.2). - * - * @param aid A hexadecimal string representation of 5 to 16 bytes. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& filterByDfName(const std::string& aid); - - /** - * (package-private)
- * Sets the file occurrence mode (see ISO7816-4). - * - *

The default value is {@link FileOccurrence#FIRST}. - * - * @param fileOccurrence The {@link FileOccurrence}. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& setFileOccurrence(const FileOccurrence fileOccurrence); - - /** - * (package-private)
- * Sets the file control mode (see ISO7816-4). - * - *

The default value is {@link FileControlInformation#FCI}. - * - * @param fileControlInformation The {@link FileControlInformation}. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& setFileControlInformation(const FileControlInformation fileControlInformation); - - /** - * (package-private)
- * Adds a status word to the list of those that should be considered successful for the Select - * Application APDU. - * - *

Note: initially, the list contains the standard successful status word {@code 9000h}. - * - * @param statusWord A positive int ≤ {@code FFFFh}. - * @return The current instance. - * @since 2.0.0 - */ - CardSelectorSpi& addSuccessfulStatusWord(const int statusWord); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getCardProtocol() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getPowerOnDataRegex() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::vector& getAid() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - FileOccurrence getFileOccurrence() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - FileControlInformation getFileControlInformation() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::vector& getSuccessfulSelectionStatusWords() const override; - -private: - /** - * - */ - static const int DEFAULT_SUCCESSFUL_CODE; - - /** - * - */ - std::string mCardProtocol; - - /** - * - */ - std::string mPowerOnDataRegex; - - /** - * - */ - std::vector mAid; - - /** - * - */ - FileOccurrence mFileOccurrence; - - /** - * - */ - FileControlInformation mFileControlInformation; - - /** - * - */ - std::vector mSuccessfulSelectionStatusWords; -}; - -} -} -} diff --git a/src/main/CardTransactionManager.h b/src/main/CardTransactionManager.h deleted file mode 100644 index 1f943a2..0000000 --- a/src/main/CardTransactionManager.h +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -namespace keyple { -namespace card { -namespace generic { - -/** - * Provides basic methods to prepare and process APDU exchange with a card. - */ -class CardTransactionManager { -public: - /** - * - */ - virtual ~CardTransactionManager() = default; - - /** - * Prepares an APDU to be transmitted the next time processApdusToByteArrays()} is - * invoked. - * - * @param apduCommand A not empty hexadecimal string containing a raw APDU command. - * @return This instance. - * @since 2.0.0 - */ - virtual CardTransactionManager& prepareApdu(const std::string& apduCommand) = 0; - - /** - * Prepares an APDU to be transmitted the next time processApdusToByteArrays() is - * invoked. - * - * @param apduCommand A not empty const uint8_t arrays containing raw APDU commands. - * @return This instance. - * @since 2.0.0 - */ - virtual CardTransactionManager& prepareApdu(const std::vector& apduCommand) = 0; - - /** - * Prepares an APDU to be transmitted the next time processApdusToByteArrays() is - * invoked. - * - * @param cla The class const uint8_t. - * @param ins The instruction const uint8_t. - * @param p1 The P1 parameter. - * @param p2 The P2 parameter. - * @param dataIn The APDU data, null if there is no data. - * @param le The expected output length, 0 if the output length is unspecified, null if no - * output data is expected. - * @return This instance. - * @since 2.0.0 - */ - virtual CardTransactionManager& prepareApdu(const uint8_t cla, - const uint8_t ins, - const uint8_t p1, - const uint8_t p2, - const std::vector& dataIn, - const uint8_t le) = 0; - - /** - * Prepares an APDU to be transmitted the next time processApdusToByteArrays() is - * invoked. - * - * @param cla The class const uint8_t. - * @param ins The instruction const uint8_t. - * @param p1 The P1 parameter. - * @param p2 The P2 parameter. - * @param dataIn The APDU data, null if there is no data. - * - * @return This instance. - * @since 2.0.0 - */ - virtual CardTransactionManager& prepareApdu(const uint8_t cla, - const uint8_t ins, - const uint8_t p1, - const uint8_t p2, - const std::vector& dataIn) = 0; - - /** - * Requests the closing of the physical channel after the next transmission of APDUs. - * - * @return This instance. - * @since 2.0.0 - */ - virtual CardTransactionManager& prepareReleaseChannel() = 0; - - /** - * Transmits all prepared APDUs, closes the physical channel if required, and returns a list of - * responses to the APDUs in the form of list of of const uint8_t arrays. - * - *

If the prepared APDU list is empty an empty list is returned. - * - *

The prepared APDU list is cleared after this method has been invoked. - * - * @return A not null reference. - * @throw TransactionException If the communication with the card or the reader has failed. - */ - virtual const std::vector> processApdusToByteArrays() = 0; - - /** - * Transmits all prepared APDUs, closes the physical channel if required, and returns a list of - * responses to the APDUs in the form of list of hexadecimal strings. - * - *

If the prepared APDU list is empty an empty list is returned. - * - *

The prepared APDU list is cleared after this method has been invoked. - * - * @return A not null reference. - * @throw TransactionException If the communication with the card or the reader has failed. - */ - virtual const std::vector processApdusToHexStrings() = 0; -}; - -} -} -} diff --git a/src/main/CardTransactionManagerAdapter.cpp b/src/main/CardTransactionManagerAdapter.cpp index 8195aec..4357981 100644 --- a/src/main/CardTransactionManagerAdapter.cpp +++ b/src/main/CardTransactionManagerAdapter.cpp @@ -1,71 +1,81 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "CardTransactionManagerAdapter.h" - -/* Keyple Core Util */ -#include "ApduUtil.h" -#include "ByteArrayUtil.h" -#include "KeypleAssert.h" - -/* Keyple Card Generic */ -#include "ApduRequestAdapter.h" -#include "TransactionException.h" - -/* Calypsonet Terminal Card */ -#include "CardBrokenCommunicationException.h" -#include "CardRequestAdapter.h" -#include "CardResponseApi.h" -#include "ProxyReaderApi.h" -#include "ReaderBrokenCommunicationException.h" -#include "UnexpectedStatusWordException.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/CardTransactionManagerAdapter.hpp" + +#include "keyple/card/generic/ApduRequestAdapter.hpp" +#include "keyple/card/generic/CardRequestAdapter.hpp" +#include "keyple/card/generic/ChannelControl.hpp" +#include "keyple/card/generic/TransactionException.hpp" +#include "keyple/core/util/ApduUtil.hpp" +#include "keyple/core/util/ByteArrayUtil.hpp" +#include "keyple/core/util/HexUtil.hpp" +#include "keyple/core/util/KeypleAssert.hpp" +#include "keypop/card/CardBrokenCommunicationException.hpp" +#include "keypop/card/CardResponseApi.hpp" +#include "keypop/card/ProxyReaderApi.hpp" +#include "keypop/card/ReaderBrokenCommunicationException.hpp" +#include "keypop/card/UnexpectedStatusWordException.hpp" namespace keyple { namespace card { namespace generic { -using namespace calypsonet::terminal::card; -using namespace keyple::core::util; +using keyple::core::util::ApduUtil; +using keyple::core::util::Assert; +using keyple::core::util::ByteArrayUtil; +using keyple::core::util::HexUtil; +using keypop::card::CardBrokenCommunicationException; +using keypop::card::CardResponseApi; +using keypop::card::ProxyReaderApi; +using keypop::card::ReaderBrokenCommunicationException; +using keypop::card::UnexpectedStatusWordException; const std::string CardTransactionManagerAdapter::APDU_COMMAND = "apduCommand"; -CardTransactionManagerAdapter::CardTransactionManagerAdapter(std::shared_ptr reader, - const std::shared_ptr card) -: mReader(reader), mChannelControl(ChannelControl::KEEP_OPEN) +CardTransactionManagerAdapter::CardTransactionManagerAdapter( + std::shared_ptr reader, const std::shared_ptr card) +: mReader(reader) { Assert::getInstance().notNull(reader, "reader").notNull(card, "card"); } -CardTransactionManager& CardTransactionManagerAdapter::prepareApdu(const std::string& apduCommand) +CardTransactionManager& +CardTransactionManagerAdapter::prepareApdu(const std::string& apduCommand) { - Assert::getInstance().notEmpty(apduCommand, APDU_COMMAND) - .isTrue(ByteArrayUtil::isValidHexString(apduCommand), APDU_COMMAND); + Assert::getInstance() + .notEmpty(apduCommand, APDU_COMMAND) + .isTrue(HexUtil::isValid(apduCommand), APDU_COMMAND); - prepareApdu(ByteArrayUtil::fromHex(apduCommand)); + prepareApdu(HexUtil::toByteArray(apduCommand)); return *this; } -CardTransactionManager& CardTransactionManagerAdapter::prepareApdu( +CardTransactionManager& +CardTransactionManagerAdapter::prepareApdu( const std::vector& apduCommand) { - Assert::getInstance().isInRange(static_cast(apduCommand.size()), 5, 251, "length"); + Assert::getInstance().isInRange( + static_cast(apduCommand.size()), 5, 251, "length"); mApduRequests.push_back(std::make_shared(apduCommand)); return *this; } -CardTransactionManager& CardTransactionManagerAdapter::prepareApdu( +CardTransactionManager& +CardTransactionManagerAdapter::prepareApdu( const uint8_t cla, const uint8_t ins, const uint8_t p1, @@ -73,33 +83,29 @@ CardTransactionManager& CardTransactionManagerAdapter::prepareApdu( const std::vector& dataIn, const uint8_t le) { - mApduRequests.push_back( - std::make_shared(ApduUtil::build(cla, ins, p1, p2, dataIn, le))); + mApduRequests.push_back(std::make_shared( + ApduUtil::build(cla, ins, p1, p2, dataIn, le))); return *this; } -CardTransactionManager& CardTransactionManagerAdapter::prepareApdu( +CardTransactionManager& +CardTransactionManagerAdapter::prepareApdu( const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const std::vector& dataIn) { - mApduRequests.push_back( - std::make_shared(ApduUtil::build(cla, ins, p1, p2, dataIn))); + mApduRequests.push_back(std::make_shared( + ApduUtil::build(cla, ins, p1, p2, dataIn))); return *this; } -CardTransactionManager& CardTransactionManagerAdapter::prepareReleaseChannel() -{ - mChannelControl = ChannelControl::CLOSE_AFTER; - - return *this; -} - -const std::vector> CardTransactionManagerAdapter::processApdusToByteArrays() +const std::vector> +CardTransactionManagerAdapter::processApdusToByteArrays( + const ChannelControl channelControl) { std::shared_ptr cardResponse; std::vector> apduResponsesBytes; @@ -109,20 +115,26 @@ const std::vector> CardTransactionManagerAdapter::processAp } try { - cardResponse = - std::dynamic_pointer_cast(mReader) - ->transmitCardRequest( - std::make_shared(mApduRequests, false), mChannelControl); + auto cardRequest + = std::make_shared(mApduRequests, false); + auto control = channelControl == ChannelControl::CLOSE_AFTER + ? keypop::card::ChannelControl::CLOSE_AFTER + : keypop::card::ChannelControl::KEEP_OPEN; + + cardResponse = std::dynamic_pointer_cast(mReader) + ->transmitCardRequest(cardRequest, control); } catch (const ReaderBrokenCommunicationException& e) { - throw TransactionException("Reader communication error.", - std::make_shared(e)); + throw TransactionException( + "Reader communication error", + std::make_shared(e)); } catch (const CardBrokenCommunicationException& e) { - throw TransactionException("Card communication error.", - std::make_shared(e)); + throw TransactionException( + "Card communication error", + std::make_shared(e)); } catch (const UnexpectedStatusWordException& e) { - throw TransactionException("Apdu error.", - std::make_shared(e)); + throw TransactionException( + "Apdu error", std::make_shared(e)); } mApduRequests.clear(); @@ -134,18 +146,21 @@ const std::vector> CardTransactionManagerAdapter::processAp return apduResponsesBytes; } -const std::vector CardTransactionManagerAdapter::processApdusToHexStrings() +const std::vector +CardTransactionManagerAdapter::processApdusToHexStrings( + const ChannelControl channelControl) { - const std::vector> apduResponsesBytes = processApdusToByteArrays(); std::vector apduResponsesHex; + const std::vector> apduResponsesBytes + = processApdusToByteArrays(channelControl); for (const auto& bytes : apduResponsesBytes) { - apduResponsesHex.push_back(ByteArrayUtil::toHex(bytes)); + apduResponsesHex.push_back(HexUtil::toHex(bytes)); } return apduResponsesHex; } -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/CardTransactionManagerAdapter.h b/src/main/CardTransactionManagerAdapter.h deleted file mode 100644 index 5af90c9..0000000 --- a/src/main/CardTransactionManagerAdapter.h +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include -#include - -/* Keyple Card Generic */ -#include "CardTransactionManager.h" - -/* Calypsonet Terminal Card */ -#include "ApduRequestSpi.h" -#include "ChannelControl.h" - -/* Calypsonet Terminal Reader */ -#include "CardReader.h" -#include "SmartCard.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::card; -using namespace calypsonet::terminal::card::spi; -using namespace calypsonet::terminal::reader; -using namespace calypsonet::terminal::reader::selection::spi; - -/** - * (package-private)
- * Implementation of CardTransactionManager. - * - * @since 2.0.0 - */ -class CardTransactionManagerAdapter final : public CardTransactionManager { -public: - /** - * - */ - static const std::string APDU_COMMAND; - - /** - * (package-private)
- * Creates an instance of CardTransactionManager. - * - * @param reader The reader through which the card communicates. - * @param card The initial card data provided by the selection process. - * @throw IllegalArgumentException If the card resource or one of its components is null. - * @since 2.0.0 - */ - CardTransactionManagerAdapter(std::shared_ptr reader, - const std::shared_ptr card); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - CardTransactionManager& prepareApdu(const std::string& apduCommand) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - CardTransactionManager& prepareApdu(const std::vector& apduCommand) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - CardTransactionManager& prepareApdu(const uint8_t cla, - const uint8_t ins, - const uint8_t p1, - const uint8_t p2, - const std::vector& dataIn, - const uint8_t le) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - CardTransactionManager& prepareApdu(const uint8_t cla, - const uint8_t ins, - const uint8_t p1, - const uint8_t p2, - const std::vector& dataIn) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - CardTransactionManager& prepareReleaseChannel() override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::vector> processApdusToByteArrays() override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::vector processApdusToHexStrings() override; - -private: - /** - * - */ - std::shared_ptr mReader; - - /** - * - */ - std::vector> mApduRequests; - - /** - * - */ - ChannelControl mChannelControl; -}; - -} -} -} diff --git a/src/main/GenericCardAdapter.cpp b/src/main/GenericCardAdapter.cpp index 8092a9b..234b829 100644 --- a/src/main/GenericCardAdapter.cpp +++ b/src/main/GenericCardAdapter.cpp @@ -1,39 +1,48 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ -#include "GenericCardAdapter.h" +#include "keyple/card/generic/GenericCardAdapter.hpp" + +#include +#include +#include namespace keyple { namespace card { namespace generic { GenericCardAdapter::GenericCardAdapter( - std::shared_ptr cardSelectionResponse) + std::shared_ptr cardSelectionResponse) : mSelectApplicationResponse( - cardSelectionResponse->getSelectApplicationResponse() != nullptr ? - cardSelectionResponse->getSelectApplicationResponse()->getApdu() : - std::vector()), - mPowerOnData(cardSelectionResponse->getPowerOnData()) {} + cardSelectionResponse->getSelectApplicationResponse() != nullptr + ? cardSelectionResponse->getSelectApplicationResponse()->getApdu() + : std::vector()) +, mPowerOnData(cardSelectionResponse->getPowerOnData()) +{ +} -const std::string& GenericCardAdapter::getPowerOnData() const +const std::string& +GenericCardAdapter::getPowerOnData() const { return mPowerOnData; } -const std::vector GenericCardAdapter::getSelectApplicationResponse() const +std::vector +GenericCardAdapter::getSelectApplicationResponse() const { return mSelectApplicationResponse; } -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/GenericCardAdapter.h b/src/main/GenericCardAdapter.h deleted file mode 100644 index e56e44c..0000000 --- a/src/main/GenericCardAdapter.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -/* Calypsonet Terminal Card */ -#include "CardSelectionResponseApi.h" -#include "SmartCardSpi.h" - -/* Calypsonet Terminal Reader */ -#include "SmartCard.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::card; -using namespace calypsonet::terminal::card::spi; -using namespace calypsonet::terminal::reader::selection::spi; - -/** - * (package-private)
- * Implementation of a generic {@link SmartCard}. - * - * @since 2.0.0 - */ -class GenericCardAdapter final : public SmartCard, public SmartCardSpi { -public: - /** - * Constructor - * - *

Gets ATR and FCI from the CardSelectionResponseApi if they exist (both are - * optional). - * - * @param cardSelectionResponse The CardSelectionResponseApi from the selection process. - */ - GenericCardAdapter(std::shared_ptr cardSelectionResponse); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getPowerOnData() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::vector getSelectApplicationResponse() const override; - -private: - /** - * - */ - const std::vector mSelectApplicationResponse; - - /** - * - */ - const std::string mPowerOnData; -}; - -} -} -} diff --git a/src/main/GenericCardResourceProfileExtensionAdapter.cpp b/src/main/GenericCardResourceProfileExtensionAdapter.cpp index 0502bc8..c275cbc 100644 --- a/src/main/GenericCardResourceProfileExtensionAdapter.cpp +++ b/src/main/GenericCardResourceProfileExtensionAdapter.cpp @@ -1,60 +1,88 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "GenericCardResourceProfileExtensionAdapter.h" - -/* Keyple Core Util */ -#include "KeypleAssert.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/GenericCardResourceProfileExtensionAdapter.hpp" + +#include "keyple/core/util/KeypleAssert.hpp" +#include "keyple/core/util/cpp/exception/Exception.hpp" +#include "keypop/reader/selection/CardSelectionManager.hpp" +#include "keypop/reader/selection/CardSelectionResult.hpp" +#include "keypop/reader/selection/spi/IsoSmartCard.hpp" namespace keyple { namespace card { namespace generic { -using namespace keyple::core::service::resource::spi; -using namespace keyple::core::util; -using namespace keyple::core::util::cpp; +using keyple::core::util::Assert; +using keyple::core::util::cpp::exception::Exception; +using keypop::reader::selection::CardSelectionManager; +using keypop::reader::selection::CardSelectionResult; +using keypop::reader::selection::spi::IsoSmartCard; -GenericCardResourceProfileExtensionAdapter::GenericCardResourceProfileExtensionAdapter( - std::shared_ptr genericCardSelection) -: mGenericCardSelection(genericCardSelection) +GenericCardResourceProfileExtensionAdapter:: + GenericCardResourceProfileExtensionAdapter( + std::shared_ptr cardSelector, + std::shared_ptr + genericCardSelectionExtension) +: mGenericCardSelection( + std::dynamic_pointer_cast( + genericCardSelectionExtension)) +, mCardSelector(cardSelector) { - Assert::getInstance().notNull(genericCardSelection, "genericCardSelection"); + Assert::getInstance().notNull( + genericCardSelectionExtension, "genericCardSelectionExtension"); } -std::shared_ptr GenericCardResourceProfileExtensionAdapter::matches( - std::shared_ptr reader, - std::shared_ptr cardSelectionManager) +std::shared_ptr +GenericCardResourceProfileExtensionAdapter::matches( + std::shared_ptr reader, + std::shared_ptr readerApiFactory) { - if (!reader->isCardPresent()) { return nullptr; } - cardSelectionManager->prepareSelection(mGenericCardSelection); - std::shared_ptr cardSelectionResult = nullptr; + std::shared_ptr genericCardSelectionManager( + readerApiFactory->createCardSelectionManager()); + genericCardSelectionManager->prepareSelection( + mCardSelector, mGenericCardSelection); + std::shared_ptr genericCardSelectionResult = nullptr; try { - cardSelectionResult = cardSelectionManager->processCardSelectionScenario(reader); + genericCardSelectionResult + = genericCardSelectionManager->processCardSelectionScenario(reader); } catch (const Exception& e) { - mLogger->warn("An exception occurred while selecting the card: '%'\n", e.getMessage(), e); + mLogger->error("Card selection failed: %\n", e.getMessage(), e); } - if (cardSelectionResult != nullptr) { - return cardSelectionResult->getActiveSmartCard(); + if (genericCardSelectionResult != nullptr) { + return genericCardSelectionResult->getActiveSmartCard(); } return nullptr; } +std::shared_ptr +GenericCardResourceProfileExtensionAdapter::matches( + std::shared_ptr smartCard) +{ + if (std::dynamic_pointer_cast(smartCard) == nullptr) { + return nullptr; + } + + return smartCard; } -} -} + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/GenericCardResourceProfileExtensionAdapter.h b/src/main/GenericCardResourceProfileExtensionAdapter.h deleted file mode 100644 index 6dc1819..0000000 --- a/src/main/GenericCardResourceProfileExtensionAdapter.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -/* Keyple Core Service Resource */ -#include "CardResourceProfileExtension.h" -#include "GenericCardSelection.h" - -/* Keyple Core Util */ -#include "LoggerFactory.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace keyple::core::service::resource::spi; -using namespace keyple::core::util::cpp; - -/** - * (package-private)
- * Implementation of CardResourceProfileExtension dedicated to card identification. - * - * @since 2.0.0 - */ -class GenericCardResourceProfileExtensionAdapter final : public CardResourceProfileExtension { -public: - /** - * (package-private)
- * - * @param genericCardSelection The GenericCardSelection. - * @since 2.0.0 - */ - GenericCardResourceProfileExtensionAdapter( - std::shared_ptr genericCardSelection); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - std::shared_ptr matches(std::shared_ptr reader, - std::shared_ptr cardSelectionManager) - override; - -private: - /** - * - */ - const std::unique_ptr mLogger = - LoggerFactory::getLogger(typeid(GenericCardResourceProfileExtensionAdapter)); - - /** - * - */ - std::shared_ptr mGenericCardSelection; -}; - -} -} -} diff --git a/src/main/GenericCardSelection.h b/src/main/GenericCardSelection.h deleted file mode 100644 index a60f507..0000000 --- a/src/main/GenericCardSelection.h +++ /dev/null @@ -1,201 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include -#include - -/* Calypsonet Terminal Reader */ -#include "CardSelection.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::reader::selection::spi; - -/** - * Card specific {@link CardSelection} providing means to filter cards, select applications. - * - * @since 2.0.0 - */ -class GenericCardSelection : public CardSelection { -public: - /** - * Navigation options through the different applications contained in the card according to the - * ISO7816-4 standard. - * - * @since 2.0.0 - */ - enum class FileOccurrence { - /** - * First occurrence. - * - * @since 2.0.0 - */ - FIRST, - - /** - * Last occurrence. - * - * @since 2.0.0 - */ - LAST, - - /** - * Next occurrence. - * - * @since 2.0.0 - */ - NEXT, - - /** - * Previous occurrence. - * - * @since 2.0.0 - */ - PREVIOUS - }; - - /** - * Types of templates available in return for the Select Application command, according to the - * ISO7816-4 standard. - * - * @since 2.0.0 - */ - enum class FileControlInformation { - /** - * File control information. - * - * @since 2.0.0 - */ - FCI, - - /** - * File control parameters. - * - * @since 2.0.0 - */ - FCP, - - /** - * File management data. - * - * @since 2.0.0 - */ - FMD, - - /** - * No response expected. - * - * @since 2.0.0 - */ - NO_RESPONSE - }; - - /** - * Requests a protocol-based filtering by defining an expected card. - * - *

If the card protocol is set, only cards using that protocol will match the card selector. - * - * @param cardProtocol A not empty String. - * @return The current instance. - * @throw IllegalArgumentException If the argument is null or empty. - * @since 2.0.0 - */ - virtual GenericCardSelection& filterByCardProtocol(const std::string& cardProtocol) = 0; - - /** - * Requests a power-on data-based filtering by defining a regular expression that will be - * applied to the card's power-on data. - * - *

If it is set, only the cards whose power-on data is recognized by the provided regular - * expression will match the card selector. - * - * @param powerOnDataRegex A valid regular expression - * @return The current instance. - * @throw IllegalArgumentException If the provided regular expression is null, empty or invalid. - * @since 2.0.0 - */ - virtual GenericCardSelection& filterByPowerOnData(const std::string& powerOnDataRegex) = 0; - - /** - * Requests a DF Name-based filtering by defining in a byte array the AID that will be included - * in the standard SELECT APPLICATION command sent to the card during the selection process. - * - *

The provided AID can be a right truncated image of the target DF Name - * (see ISO 7816-4 4.2). - * - * @param aid A byte array containing 5 to 16 bytes. - * @return The current instance. - * @throw IllegalArgumentException If the provided array is null or out of range. - * @since 2.0.0 - */ - virtual GenericCardSelection& filterByDfName(const std::vector& aid) = 0; - - /** - * Requests a DF Name-based filtering by defining in a hexadecimal string the AID that will be - * included in the standard SELECT APPLICATION command sent to the card during the selection - * process. - * - *

The provided AID can be a right truncated image of the target DF Name - * (see ISO 7816-4 4.2). - * - * @param aid A hexadecimal string representation of 5 to 16 bytes. - * @return The current instance. - * @throw IllegalArgumentException If the provided AID is null, invalid or out of range. - * @since 2.0.0 - */ - virtual GenericCardSelection& filterByDfName(const std::string& aid) = 0; - - /** - * Sets the file occurrence mode (see ISO7816-4). - * - *

The default value is {@link GenericCardSelection.FileOccurrence#FIRST}. - * - * @param fileOccurrence The {@link GenericCardSelection.FileOccurrence}. - * @return The current instance. - * @throw IllegalArgumentException If fileOccurrence is null. - * @since 2.0.0 - */ - virtual GenericCardSelection& setFileOccurrence(const FileOccurrence fileOccurrence) = 0; - - /** - * Sets the file control mode (see ISO7816-4). - * - *

The default value is {@link GenericCardSelection.FileControlInformation#FCI}. - * - * @param fileControlInformation The {@link GenericCardSelection.FileControlInformation}. - * @return The current instance. - * @throw IllegalArgumentException If fileControlInformation is null. - * @since 2.0.0 - */ - virtual GenericCardSelection& setFileControlInformation( - const FileControlInformation fileControlInformation) = 0; - - /** - * Adds a status word to the list of those that should be considered successful for the Select - * Application APDU. - * - *

Note: initially, the list contains the standard successful status word {@code 9000h}. - * - * @param statusWord A positive int ≤ {@code FFFFh}. - * @return The current instance. - * @since 2.0.0 - */ - virtual GenericCardSelection& addSuccessfulStatusWord(const int statusWord) = 0; -}; - -} -} -} diff --git a/src/main/GenericCardSelectionAdapter.cpp b/src/main/GenericCardSelectionAdapter.cpp deleted file mode 100644 index dc629d2..0000000 --- a/src/main/GenericCardSelectionAdapter.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "GenericCardSelectionAdapter.h" - -/* Keyple Card Generic */ -#include "GenericCardAdapter.h" -#include "GenericCardSelectionRequestAdapter.h" - -/* Keyple Core Util */ -#include "ByteArrayUtil.h" -#include "IllegalArgumentException.h" -#include "KeypleAssert.h" -#include "Pattern.h" -#include "PatternSyntaxException.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace keyple::core::util; -using namespace keyple::core::util::cpp; -using namespace keyple::core::util::cpp::exception; - -const int GenericCardSelectionAdapter::AID_MIN_LENGTH = 5; -const int GenericCardSelectionAdapter::AID_MAX_LENGTH = 16; - -GenericCardSelectionAdapter::GenericCardSelectionAdapter() -: mCardSelector(std::make_shared()) {} - -const std::shared_ptr - GenericCardSelectionAdapter::getCardSelectionRequest() -{ - return std::make_shared(mCardSelector); -} - -const std::shared_ptr GenericCardSelectionAdapter::parse( - const std::shared_ptr cardSelectionResponse) -{ - return std::make_shared(cardSelectionResponse); -} - - -GenericCardSelection& GenericCardSelectionAdapter::filterByCardProtocol( - const std::string& cardProtocol) -{ - Assert::getInstance().notEmpty(cardProtocol, "cardProtocol"); - - mCardSelector->filterByCardProtocol(cardProtocol); - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::filterByPowerOnData( - const std::string& powerOnDataRegex) -{ - Assert::getInstance().notEmpty(powerOnDataRegex, "powerOnDataRegex"); - - try { - Pattern::compile(powerOnDataRegex); - } catch (const PatternSyntaxException& e) { - (void)e; - throw IllegalArgumentException("Invalid regular expression: " + powerOnDataRegex); - } - - mCardSelector->filterByPowerOnData(powerOnDataRegex); - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::filterByDfName(const std::vector& aid) -{ - Assert::getInstance().isInRange(static_cast(aid.size()), - AID_MIN_LENGTH, - AID_MAX_LENGTH, - "aid"); - - mCardSelector->filterByDfName(aid); - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::filterByDfName(const std::string& aid) -{ - filterByDfName(ByteArrayUtil::fromHex(aid)); - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::setFileOccurrence( - const FileOccurrence fileOccurrence) -{ - switch (fileOccurrence) { - case FileOccurrence::FIRST: - mCardSelector->setFileOccurrence(CardSelectorSpi::FileOccurrence::FIRST); - break; - case FileOccurrence::LAST: - mCardSelector->setFileOccurrence(CardSelectorSpi::FileOccurrence::LAST); - break; - case FileOccurrence::NEXT: - mCardSelector->setFileOccurrence(CardSelectorSpi::FileOccurrence::NEXT); - break; - case FileOccurrence::PREVIOUS: - mCardSelector->setFileOccurrence(CardSelectorSpi::FileOccurrence::PREVIOUS); - break; - } - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::setFileControlInformation( - const FileControlInformation fileControlInformation) { - - switch (fileControlInformation) { - case FileControlInformation::FCI: - mCardSelector->setFileControlInformation(CardSelectorSpi::FileControlInformation::FCI); - break; - case FileControlInformation::FCP: - mCardSelector->setFileControlInformation(CardSelectorSpi::FileControlInformation::FCP); - break; - case FileControlInformation::FMD: - mCardSelector->setFileControlInformation(CardSelectorSpi::FileControlInformation::FMD); - break; - case FileControlInformation::NO_RESPONSE: - mCardSelector->setFileControlInformation(CardSelectorSpi::FileControlInformation::NO_RESPONSE); - break; - } - - return *this; -} - -GenericCardSelection& GenericCardSelectionAdapter::addSuccessfulStatusWord(const int statusWord) -{ - mCardSelector->addSuccessfulStatusWord(statusWord); - - return *this; -} - -} -} -} diff --git a/src/main/GenericCardSelectionAdapter.h b/src/main/GenericCardSelectionAdapter.h deleted file mode 100644 index 1d4a52c..0000000 --- a/src/main/GenericCardSelectionAdapter.h +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include - -/* Keyple Card Generic */ -#include "CardSelectorAdapter.h" -#include "GenericCardSelection.h" - -/* Calypsonet Terminal Card */ -#include "CardSelectionResponseApi.h" -#include "CardSelectionSpi.h" -#include "SmartCardSpi.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::card; -using namespace calypsonet::terminal::card::spi; - -/** - * (package-private)
- * Implementation of a generic {@link CardSelection}. - * - * @since 2.0.0 - */ -class GenericCardSelectionAdapter final : public GenericCardSelection, public CardSelectionSpi { -public: - /** - * (package-private) Creates an instance. - * - * @since 2.0.0 - */ - GenericCardSelectionAdapter(); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::shared_ptr getCardSelectionRequest() override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::shared_ptr parse( - const std::shared_ptr cardSelectionResponse) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& filterByCardProtocol(const std::string& cardProtocol) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& filterByPowerOnData(const std::string& powerOnDataRegex) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& filterByDfName(const std::vector& aid) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& filterByDfName(const std::string& aid) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& setFileOccurrence(const FileOccurrence fileOccurrence) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& setFileControlInformation( - const FileControlInformation fileControlInformation) override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - GenericCardSelection& addSuccessfulStatusWord(const int statusWord) override; - -private: - /** - * - */ - static const int AID_MIN_LENGTH; - - /** - * - */ - static const int AID_MAX_LENGTH; - - /** - * - */ - std::shared_ptr mCardSelector; -}; - -} -} -} diff --git a/src/main/GenericCardSelectionExtensionAdapter.cpp b/src/main/GenericCardSelectionExtensionAdapter.cpp new file mode 100644 index 0000000..30536a8 --- /dev/null +++ b/src/main/GenericCardSelectionExtensionAdapter.cpp @@ -0,0 +1,58 @@ +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp" + +#include + +#include "keyple/card/generic/GenericCardAdapter.hpp" +#include "keyple/card/generic/GenericCardSelectionRequestAdapter.hpp" + +namespace keyple { +namespace card { +namespace generic { + +const int GenericCardSelectionExtensionAdapter::DEFAULT_SUCCESSFUL_CODE + = 0x9000; + +GenericCardSelectionExtensionAdapter::GenericCardSelectionExtensionAdapter() +: mSuccessfulSelectionStatusWords({0x9000}) +{ +} + +std::shared_ptr +GenericCardSelectionExtensionAdapter::getCardSelectionRequest() +{ + return std::make_shared( + mSuccessfulSelectionStatusWords); +} + +std::shared_ptr +GenericCardSelectionExtensionAdapter::parse( + const std::shared_ptr& cardSelectionResponse) +{ + return std::make_shared(cardSelectionResponse); +} + +GenericCardSelectionExtension& +GenericCardSelectionExtensionAdapter::addSuccessfulStatusWord( + const int statusWord) +{ + mSuccessfulSelectionStatusWords.push_back(statusWord); + + return *this; +} + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/GenericCardSelectionRequestAdapter.cpp b/src/main/GenericCardSelectionRequestAdapter.cpp index 1e034a7..52b8ed8 100644 --- a/src/main/GenericCardSelectionRequestAdapter.cpp +++ b/src/main/GenericCardSelectionRequestAdapter.cpp @@ -1,35 +1,63 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "GenericCardSelectionRequestAdapter.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/GenericCardSelectionRequestAdapter.hpp" + +#include "keyple/core/util/cpp/KeypleStd.hpp" namespace keyple { namespace card { namespace generic { GenericCardSelectionRequestAdapter::GenericCardSelectionRequestAdapter( - std::shared_ptr cardSelector) -: mCardSelector(cardSelector) {} + const std::vector& successfulSelectionStatusWords) +: mSuccessfulSelectionStatusWords(successfulSelectionStatusWords) +{ +} -const std::shared_ptr GenericCardSelectionRequestAdapter::getCardSelector() const +const std::vector& +GenericCardSelectionRequestAdapter::getSuccessfulSelectionStatusWords() const { - return mCardSelector; + return mSuccessfulSelectionStatusWords; } -const std::shared_ptr GenericCardSelectionRequestAdapter::getCardRequest() const +const std::shared_ptr +GenericCardSelectionRequestAdapter::getCardRequest() const { + /* No additional command following the card selection in this extension. */ return nullptr; } +std::ostream& +operator<<(std::ostream& os, const GenericCardSelectionRequestAdapter& gcsra) +{ + os << "CARD_SELECTION_REQUEST: {" + << "SUCCESSFUL_STATUS_WORD: " << gcsra.mSuccessfulSelectionStatusWords + << "}"; + + return os; } + +std::ostream& +operator<<( + std::ostream& os, + const std::shared_ptr gcsra) +{ + os << *gcsra.get(); + + return os; } -} + +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/GenericCardSelectionRequestAdapter.h b/src/main/GenericCardSelectionRequestAdapter.h deleted file mode 100644 index cf580fe..0000000 --- a/src/main/GenericCardSelectionRequestAdapter.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include - -/* Calypsonet Terminal Card */ -#include "CardSelectionRequestSpi.h" -#include "CardSelectorSpi.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::card::spi; - -/** - * (package-private)
- * Implementation of {@link CardSelectionRequestSpi} - * - * @since 2.0.0 - */ -class GenericCardSelectionRequestAdapter final : public CardSelectionRequestSpi { -public: - /** - * Builds a card selection request to open a logical channel with additional APDUs to be sent - * after the selection step. - * - * @param cardSelector The card selector. - * @since 2.0.0 - */ - GenericCardSelectionRequestAdapter(std::shared_ptr cardSelector); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::shared_ptr getCardSelector() const; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::shared_ptr getCardRequest() const; - -private: - /** - * - */ - std::shared_ptr mCardSelector; -}; - -} -} -} diff --git a/src/main/GenericExtensionService.cpp b/src/main/GenericExtensionService.cpp index 9961ee1..e1c662a 100644 --- a/src/main/GenericExtensionService.cpp +++ b/src/main/GenericExtensionService.cpp @@ -1,84 +1,91 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#include "GenericExtensionService.h" - -/* Keyple Card Generic */ -#include "GenericCardSelectionAdapter.h" -#include "GenericCardResourceProfileExtensionAdapter.h" - -/* Calypsonet Terminal Card */ -#include "CardApiProperties.h" - -/* Calypsonet Terminal Reader */ -#include "ReaderApiProperties.h" - -/* Keyple Core Common */ -#include "CommonApiProperties.h" +/****************************************************************************** + * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * + * * + * See the NOTICE file(s) distributed with this work for additional * + * information regarding copyright ownership. * + * * + * This program and the accompanying materials are made available under the * + * terms of the Eclipse Public License 2.0 which is available at * + * http://www.eclipse.org/legal/epl-2.0 * + * * + * SPDX-License-Identifier: EPL-2.0 * + ******************************************************************************/ + +#include "keyple/card/generic/GenericExtensionService.hpp" + +#include "keyple/card/generic/CardTransactionManagerAdapter.hpp" +#include "keyple/card/generic/GenericCardResourceProfileExtensionAdapter.hpp" +#include "keyple/card/generic/GenericCardSelectionExtensionAdapter.hpp" +#include "keyple/core/common/CommonApiProperties.hpp" +#include "keypop/card/CardApiProperties.hpp" +#include "keypop/reader/ReaderApiProperties.hpp" namespace keyple { namespace card { namespace generic { -using namespace calypsonet::terminal::card; -using namespace calypsonet::terminal::reader; -using namespace keyple::core::common; +using keyple::core::common::CommonApiProperties_VERSION; +using keypop::card::CardApiProperties_VERSION; +using keypop::reader::ReaderApiProperties_VERSION; std::shared_ptr GenericExtensionService::mInstance; -GenericExtensionService::GenericExtensionService() {} +GenericExtensionService::GenericExtensionService() +{ +} -std::shared_ptr GenericExtensionService::getInstance() +std::shared_ptr +GenericExtensionService::getInstance() { if (mInstance == nullptr) { - mInstance = std::shared_ptr(new GenericExtensionService()); + mInstance = std::shared_ptr( + new GenericExtensionService()); } return mInstance; } -std::shared_ptr GenericExtensionService::createCardSelection() +std::shared_ptr +GenericExtensionService::createGenericCardSelectionExtension() { - return std::make_shared(); + return std::make_shared(); } -std::shared_ptr GenericExtensionService::createCardTransaction( +std::shared_ptr +GenericExtensionService::createCardTransaction( std::shared_ptr reader, std::shared_ptr card) { return std::make_shared(reader, card); } std::shared_ptr - GenericExtensionService::createCardResourceProfileExtension( - std::shared_ptr genericCardSelection) +GenericExtensionService::createCardResourceProfileExtension( + const std::shared_ptr cardSelector, + const std::shared_ptr + genericCardSelectionExtension) { - return std::make_shared(genericCardSelection); + return std::make_shared( + cardSelector, genericCardSelectionExtension); } -const std::string& GenericExtensionService::getCardApiVersion() const +const std::string +GenericExtensionService::getCardApiVersion() const { return CardApiProperties_VERSION; } -const std::string& GenericExtensionService::getReaderApiVersion() const +const std::string +GenericExtensionService::getReaderApiVersion() const { return ReaderApiProperties_VERSION; } -const std::string& GenericExtensionService::getCommonApiVersion() const +const std::string +GenericExtensionService::getCommonApiVersion() const { return CommonApiProperties_VERSION; } -} -} -} +} /* namespace generic */ +} /* namespace card */ +} /* namespace keyple */ diff --git a/src/main/GenericExtensionService.h b/src/main/GenericExtensionService.h deleted file mode 100644 index f2e86ec..0000000 --- a/src/main/GenericExtensionService.h +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -#include - -/* Keyple Core Common */ -#include "KeypleCardExtension.h" - -/* Keyple Card Generic */ -#include "CardTransactionManagerAdapter.h" -#include "GenericCardSelection.h" -#include "KeypleCardGenericExport.h" - -/* Calypsonet Terminal Reader */ -#include "CardReader.h" -#include "SmartCard.h" - -/* Keyple Core Service */ -#include "CardResourceProfileExtension.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace calypsonet::terminal::reader; -using namespace calypsonet::terminal::reader::selection::spi; -using namespace keyple::core::common; -using namespace keyple::core::service::resource::spi; - -/** - * Card extension service providing basic access to APDU exchange functions with a card. - * - * @since 2.0.0 - */ -class KEYPLECARDGENERIC_API GenericExtensionService final : public KeypleCardExtension { -public: - /** - * Gets the unique instance of this object. - * - * @return A not null reference. - */ - static std::shared_ptr getInstance(); - - /** - * Creates an instance of GenericCardSelection. - * - * @return A not null reference. - * @since 2.0.0 - */ - std::shared_ptr createCardSelection(); - - /** - * Creates an instance of CardTransactionManager. - * - * @param reader The reader through which the card communicates. - * @param card The initial card data provided by the selection process. - * @return A not null reference. - * @since 2.0.0 - */ - std::shared_ptr createCardTransaction( - std::shared_ptr reader, std::shared_ptr card); - - /** - * Creates an instance of CardResourceProfileExtension to be provided to the {@link - * org.eclipse.keyple.core.service.resource.CardResourceService}. - * - *

The provided argument defines the selection rules to be applied to the card when detected - * by the card resource service. - * - * @param genericCardSelection A not null {@link GenericCardSelection}. - * @return A not null reference. - * @throw IllegalArgumentException If genericCardSelection is null. - * @since 2.0.0 - */ - std::shared_ptr createCardResourceProfileExtension( - std::shared_ptr genericCardSelection); - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getCardApiVersion() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getReaderApiVersion() const override; - - /** - * {@inheritDoc} - * - * @since 2.0.0 - */ - const std::string& getCommonApiVersion() const override; - -private: - /** - * - */ - static std::shared_ptr mInstance; - - /** - * Constructor - */ - GenericExtensionService(); -}; - -} -} -} diff --git a/src/main/TransactionException.h b/src/main/TransactionException.h deleted file mode 100644 index fdff58e..0000000 --- a/src/main/TransactionException.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************************************** - * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ * - * * - * See the NOTICE file(s) distributed with this work for additional information regarding * - * copyright ownership. * - * * - * This program and the accompanying materials are made available under the terms of the Eclipse * - * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 * - * * - * SPDX-License-Identifier: EPL-2.0 * - **************************************************************************************************/ - -#pragma once - -/* Keyple Core Util */ -#include "RuntimeException.h" - -namespace keyple { -namespace card { -namespace generic { - -using namespace keyple::core::util::cpp::exception; - -/** - * Exception when an error or a communication failure with the card or the reader occurs. - * - * @since 2.0.0 - */ -class TransactionException : public RuntimeException { -public: - /** - * Builds a new exception. - * - * @param message Message to identify the exception context. - * @since 2.0.0 - */ - TransactionException(const std::string& message) : RuntimeException(message) {} - - /** - * Builds a new exception with the originating exception. - * - * @param message Message to identify the exception context. - * @param cause The cause - * @since 2.0.0 - */ - TransactionException(const std::string& message, const std::shared_ptr cause) - : RuntimeException(message, cause) {} -}; - -} -} -} diff --git a/toolchain/arm-unknown-gnueabi-linux.cmake b/toolchain/arm-unknown-gnueabi-linux.cmake index c7c68bc..3683870 100644 --- a/toolchain/arm-unknown-gnueabi-linux.cmake +++ b/toolchain/arm-unknown-gnueabi-linux.cmake @@ -9,10 +9,10 @@ SET(ARM_SYSROOT_DIR ${ARM_TOOLCHAIN_DIR}/arm-unknown-linux-gnueabi/sysroot) # Which C and C++ compiler to use SET(CMAKE_C_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-gcc) -SET(CMAKE_CXX_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-g++) +SET(CMAKE_CXX_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-g++) # Here is the target environment located -SET(CMAKE_FIND_ROOT_PATH ${ARM_SYSROOT_DIR}) +SET(CMAKE_FIND_ROOT_PATH ${ARM_SYSROOT_DIR}) # Adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, @@ -24,4 +24,3 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) # Linker SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR} -L${ARM_SYSROOT_DIR}") - diff --git a/toolchain/clang-8-linux.cmake b/toolchain/clang-8-linux.cmake index 1a932d1..93222ef 100644 --- a/toolchain/clang-8-linux.cmake +++ b/toolchain/clang-8-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-9-linux.cmake b/toolchain/clang-9-linux.cmake index ac30418..4c13b7f 100644 --- a/toolchain/clang-9-linux.cmake +++ b/toolchain/clang-9-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-linux.cmake b/toolchain/clang-linux.cmake index 31cea4d..6282777 100644 --- a/toolchain/clang-linux.cmake +++ b/toolchain/clang-linux.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-macos.cmake b/toolchain/clang-macos.cmake index f965786..29a03d5 100644 --- a/toolchain/clang-macos.cmake +++ b/toolchain/clang-macos.cmake @@ -42,4 +42,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/clang-windows.cmake b/toolchain/clang-windows.cmake index 606fe65..85be998 100644 --- a/toolchain/clang-windows.cmake +++ b/toolchain/clang-windows.cmake @@ -45,8 +45,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MDd") # debug multi thread dll SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS") # buffers security check SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") # floating point SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t") # standard behaviour -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:forScope") # -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:inline") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:forScope") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:inline") # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR") # enables RTTI SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gd") # uses __cdecl convention SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /TP") # all sources are C++ @@ -67,4 +67,3 @@ SET(LIBRARY_TYPE SHARED) # Special tricks INCLUDE(GenerateExportHeader) - diff --git a/toolchain/gcc-10-linux.cmake b/toolchain/gcc-10-linux.cmake index 3fbe78b..3282cd6 100644 --- a/toolchain/gcc-10-linux.cmake +++ b/toolchain/gcc-10-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-4.8.3-linux.cmake b/toolchain/gcc-4.8.3-linux.cmake index f6af177..e6d3df0 100644 --- a/toolchain/gcc-4.8.3-linux.cmake +++ b/toolchain/gcc-4.8.3-linux.cmake @@ -27,4 +27,3 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) # Linker #SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") - diff --git a/toolchain/gcc-8-linux.cmake b/toolchain/gcc-8-linux.cmake index 6272eb1..db27a7b 100644 --- a/toolchain/gcc-8-linux.cmake +++ b/toolchain/gcc-8-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-9-linux.cmake b/toolchain/gcc-9-linux.cmake index 21685b2..a6e923d 100644 --- a/toolchain/gcc-9-linux.cmake +++ b/toolchain/gcc-9-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/gcc-linux.cmake b/toolchain/gcc-linux.cmake index a62432d..ff67b6e 100644 --- a/toolchain/gcc-linux.cmake +++ b/toolchain/gcc-linux.cmake @@ -43,4 +43,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") # Libraries type SET(LIBRARY_TYPE SHARED) - diff --git a/toolchain/ios-macos.cmake b/toolchain/ios-macos.cmake index 990470f..3407d82 100644 --- a/toolchain/ios-macos.cmake +++ b/toolchain/ios-macos.cmake @@ -92,4 +92,3 @@ SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-search_paths_first") # Libraries type SET(LIBRARY_TYPE STATIC) -