// Path: commons-eid-client/src/main/java/be/bosa/commons/eid/client/exception/BeIDException.java
// public class BeIDException extends Exception {
// 
// 	public BeIDException() {
// 	}
// 
// 	public BeIDException(String message) {
// 		super(message);
// 	}
// 
// 	public BeIDException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public BeIDException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: commons-eid-client/src/main/java/be/bosa/commons/eid/client/spi/Logger.java
// public interface Logger {
// 
// 	/**
// 	 * Error messages receiver.
// 	 *
// 	 * @param message the error message.
// 	 */
// 	void error(String message);
// 
// 	/**
// 	 * Debug messages receiver.
// 	 *
// 	 * @param message the debug message.
// 	 */
// 	void debug(String message);
// }


import javax.smartcardio.ResponseAPDU;
import be.bosa.commons.eid.client.exception.BeIDException;
import be.bosa.commons.eid.client.spi.Logger;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.Locale;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;
/*
 * Commons eID Project.
 * Copyright (C) 2008-2013 FedICT.
 * Copyright (C) 2014 e-Contract.be BVBA.
 * Copyright (C) 2014 - 2018 BOSA.
 *
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License version 3.0 as published by
 * the Free Software Foundation.
 *
 * This software is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software; if not, see https://www.gnu.org/licenses/.
 */

package be.bosa.commons.eid.client.impl;




/**
 * CCID I/O according to the USB Smart card CCID 1.1 specifications.
 * FrankM added PPDU support.
 *
 * @author Frank Cornelis
 * @author Frank Marien
 */
public class CCID {

	private static final int GET_FEATURES = 0x42000D48;
	private static final int GET_FEATURES_ON_WINDOWS = 0x31 << 16 | 3400 << 2;
	private static final int MIN_PIN_SIZE = 4;
	private static final int MAX_PIN_SIZE = 12;

	private static final String DUTCH_LANGUAGE = "nl";
	private static final String FRENCH_LANGUAGE = Locale.FRENCH.getLanguage();
	private static final String GERMAN_LANGUAGE = Locale.GERMAN.getLanguage();
	private static final int DUTCH_LANGUAGE_CODE = 0x13;
	private static final int FRENCH_LANGUAGE_CODE = 0x0c;
	private static final int GERMAN_LANGUAGE_CODE = 0x07;
	private static final int ENGLISH_LANGUAGE_CODE = 0x09;

// Path: commons-eid-client/src/main/java/be/bosa/commons/eid/client/exception/BeIDException.java
// public class BeIDException extends Exception {
// 
// 	public BeIDException() {
// 	}
// 
// 	public BeIDException(String message) {
// 		super(message);
// 	}
// 
// 	public BeIDException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public BeIDException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: commons-eid-client/src/main/java/be/bosa/commons/eid/client/spi/Logger.java
// public interface Logger {
// 
// 	/**
// 	 * Error messages receiver.
// 	 *
// 	 * @param message the error message.
// 	 */
// 	void error(String message);
// 
// 	/**
// 	 * Debug messages receiver.
// 	 *
// 	 * @param message the debug message.
// 	 */
// 	void debug(String message);
// }


// Path: commons-eid-client/src/main/java/be/bosa/commons/eid/client/impl/CCID.java
import javax.smartcardio.ResponseAPDU;
import be.bosa.commons.eid.client.exception.BeIDException;
import be.bosa.commons.eid.client.spi.Logger;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.Locale;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;

/*
 * Commons eID Project.
 * Copyright (C) 2008-2013 FedICT.
 * Copyright (C) 2014 e-Contract.be BVBA.
 * Copyright (C) 2014 - 2018 BOSA.
 *
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License version 3.0 as published by
 * the Free Software Foundation.
 *
 * This software is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software; if not, see https://www.gnu.org/licenses/.
 */

package be.bosa.commons.eid.client.impl;




/**
 * CCID I/O according to the USB Smart card CCID 1.1 specifications.
 * FrankM added PPDU support.
 *
 * @author Frank Cornelis
 * @author Frank Marien
 */
public class CCID {

	private static final int GET_FEATURES = 0x42000D48;
	private static final int GET_FEATURES_ON_WINDOWS = 0x31 << 16 | 3400 << 2;
	private static final int MIN_PIN_SIZE = 4;
	private static final int MAX_PIN_SIZE = 12;

	private static final String DUTCH_LANGUAGE = "nl";
	private static final String FRENCH_LANGUAGE = Locale.FRENCH.getLanguage();
	private static final String GERMAN_LANGUAGE = Locale.GERMAN.getLanguage();
	private static final int DUTCH_LANGUAGE_CODE = 0x13;
	private static final int FRENCH_LANGUAGE_CODE = 0x0c;
	private static final int GERMAN_LANGUAGE_CODE = 0x07;
	private static final int ENGLISH_LANGUAGE_CODE = 0x09;

	private final Logger logger;