All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.keyple.card.calypso.CommandGetDataTraceabilityInformation Maven / Gradle / Ivy

There is a newer version: 3.1.5
Show newest version
/* **************************************************************************************
 * 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
 ************************************************************************************** */
package org.eclipse.keyple.card.calypso;

import static org.eclipse.keyple.card.calypso.DtoAdapters.*;

import java.util.HashMap;
import java.util.Map;
import org.eclipse.keyple.core.util.ApduUtil;
import org.eclipse.keypop.card.ApduResponseApi;

/**
 * Builds the Get data APDU commands for the TRACEABILITY INFORMATION tag.
 *
 * 

In contact mode, this command can not be sent in a secure session because it would generate a * 6Cxx status and thus make calculation of the digest impossible. * * @since 2.1.0 */ final class CommandGetDataTraceabilityInformation extends Command { private static final Map STATUS_TABLE; static { Map m = new HashMap<>(Command.STATUS_TABLE); m.put( 0x6A88, new StatusProperties( "Data object not found (optional mode not available)", CardDataAccessException.class)); m.put( 0x6B00, new StatusProperties("P1 or P2 value not supported", CardDataAccessException.class)); STATUS_TABLE = m; } /** * Constructor. * * @param transactionContext The global transaction context common to all commands. * @param commandContext The local command context specific to each command. * @since 2.3.2 */ CommandGetDataTraceabilityInformation( TransactionContextDto transactionContext, CommandContextDto commandContext) { super(CardCommandRef.GET_DATA, 0, transactionContext, commandContext); byte cardClass = transactionContext.getCard() != null ? transactionContext.getCard().getCardClass().getValue() : CalypsoCardClass.ISO.getValue(); setApduRequest( new ApduRequestAdapter( ApduUtil.build( cardClass, getCommandRef().getInstructionByte(), CalypsoCardConstant.TAG_TRACEABILITY_INFORMATION_MSB, CalypsoCardConstant.TAG_TRACEABILITY_INFORMATION_LSB, null, (byte) 0x00))); addSubName("TRACEABILITY_INFORMATION"); } /** * {@inheritDoc} * * @since 2.3.2 */ @Override void finalizeRequest() { encryptRequestAndUpdateTerminalSessionMacIfNeeded(); } /** * {@inheritDoc} * * @since 2.3.2 */ @Override boolean isCryptoServiceRequiredToFinalizeRequest() { return getCommandContext().isEncryptionActive(); } /** * {@inheritDoc} * * @since 2.3.2 */ @Override boolean synchronizeCryptoServiceBeforeCardProcessing() { return !getCommandContext().isSecureSessionOpen(); } /** * {@inheritDoc} * * @since 2.3.2 */ @Override void parseResponse(ApduResponseApi apduResponse) throws CardCommandException { decryptResponseAndUpdateTerminalSessionMacIfNeeded(apduResponse); super.setApduResponseAndCheckStatus(apduResponse); getTransactionContext().getCard().setTraceabilityInformation(apduResponse.getDataOut()); updateTerminalSessionIfNeeded(); } /** * {@inheritDoc} * * @since 2.1.0 */ @Override Map getStatusTable() { return STATUS_TABLE; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy