Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create EMV-NFC Paycard #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Landlordway
Copy link

sample-pcsc/src/main/java/com/github/devnied/emvpcsccard/EMV-NFC Paycard

Copy link
Author

@Landlordway Landlordway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create EMV-NFC Paycard #84

@Landlordway
Copy link
Author

#84 (comment) e8c7b53 Mon Sep 17 00:00:00 2001
From: Landlordway 126978865+Landlordway@users.noreply.github.com
Date: Sun, 5 Mar 2023 05:12:45 +0100
Subject: [PATCH] Create EMV-NFC Paycard


.../devnied/emvpcsccard/EMV-NFC Paycard | 127 ++++++++++++++++++
1 file changed, 127 insertions(+)
create mode 100644 sample-pcsc/src/main/java/com/github/devnied/emvpcsccard/EMV-NFC Paycard

diff --git a/sample-pcsc/src/main/java/com/github/devnied/emvpcsccard/EMV-NFC Paycard b/sample-pcsc/src/main/java/com/github/devnied/emvpcsccard/EMV-NFC Paycard
new file mode 100644
index 0000000..e436e3e
--- /dev/null
+++ b/sample-pcsc/src/main/java/com/github/devnied/emvpcsccard/EMV-NFC Paycard
@@ -0,0 +1,127 @@
+package com.github.devnied.emvpcsccard;
+
+import java.nio.ByteBuffer;
+
+import javax.smartcardio.CardChannel;
+
+import javax.smartcardio.CardException;
+
+import org.slf4j.Logger;
+
+import org.slf4j.LoggerFactory;
+
+import com.github.devnied.emvnfccard.enums.SwEnum;
+
+import com.github.devnied.emvnfccard.exception.CommunicationException;
+
+import com.github.devnied.emvnfccard.parser.IProvider;
+
+import com.github.devnied.emvnfccard.utils.TlvUtil;
+
+import fr.devnied.bitlib.BytesUtils;
+
+public class PcscProvider implements IProvider {
+

  • /** * Class logger
  • */
  • private static final Logger LOGGER = LoggerFactory.getLogger(PcscProvider.class);
  • /**
    • CardChanel
  • */
  • private final CardChannel channel;
  • /**
    • Buffer
  • */
  • private final ByteBuffer buffer = ByteBuffer.allocate(1024);
  • /**
    • Constructor using field
    •        card channel
      
  • */
  • public PcscProvider(final CardChannel pChannel) {
  •   channel = pChannel;
    
  • }
  • @OverRide
  • public byte[] transceive(final byte[] pCommand) throws CommunicationException {
  •   byte[] ret = null;
    
  •   buffer.clear();
    
  •   if (LOGGER.isDebugEnabled()) {
    
  •   	LOGGER.debug("send: " + BytesUtils.bytesToString(pCommand));
    
  •   }
    
  •   try {
    
  •   	int nbByte = channel.transmit(ByteBuffer.wrap(pCommand), buffer);
    
  •   	ret = new byte[nbByte];
    
  •   	System.arraycopy(buffer.array(), 0, ret, 0, ret.length);
    
  •   } catch (CardException e) {
    
  •   	// Do nothing
    
  •   }
    
  •   if (LOGGER.isDebugEnabled()) {
    
  •   	LOGGER.debug("resp: " + BytesUtils.bytesToString(ret));
    
  •   	try {
    
  •   		LOGGER.debug("resp: " + TlvUtil.prettyPrintAPDUResponse(ret));
    
  •   		SwEnum val = SwEnum.getSW(ret);
    
  •   		if (val != null) {
    
  •   			LOGGER.debug("resp: " + val.getDetail());
    
  •   		}
    
  •   	} catch (Exception e) {
    
  •   	}
    
  •   }
    
  •   return ret;
    
  • }
  • @OverRide
  • public byte[] getAt() {
  •   return channel.getCard().getATR().getBytes();
    
  • }

+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant