From 890c3c0d321c3b59ec1224d4630b3f2401ef94e7 Mon Sep 17 00:00:00 2001 From: tkellner Date: Tue, 7 Jan 2014 17:28:54 +0000 Subject: Add custom PC/SC library for MacOS X from OpeneCard project git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1276 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../java/org/openecard/scio/osx/SunOSXPCSC.java | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 smcc/src/main/java/org/openecard/scio/osx/SunOSXPCSC.java (limited to 'smcc/src/main/java/org/openecard/scio/osx/SunOSXPCSC.java') diff --git a/smcc/src/main/java/org/openecard/scio/osx/SunOSXPCSC.java b/smcc/src/main/java/org/openecard/scio/osx/SunOSXPCSC.java new file mode 100644 index 00000000..f05d0373 --- /dev/null +++ b/smcc/src/main/java/org/openecard/scio/osx/SunOSXPCSC.java @@ -0,0 +1,89 @@ +/**************************************************************************** + * Copyright (C) 2012-2013 ecsec GmbH. + * All rights reserved. + * Contact: ecsec GmbH (info@ecsec.de) + * + * This file is part of the Open eCard App. + * + * GNU General Public License Usage + * This file may be used under the terms of the GNU General Public + * License version 3.0 as published by the Free Software Foundation + * and appearing in the file LICENSE.GPL included in the packaging of + * this file. Please review the following information to ensure the + * GNU General Public License version 3.0 requirements will be met: + * http://www.gnu.org/copyleft/gpl.html. + * + * Other Usage + * Alternatively, this file may be used in accordance with the terms + * and conditions contained in a signed written agreement between + * you and ecsec GmbH. + * + ***************************************************************************/ + +package org.openecard.scio.osx; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.Provider; +import javax.smartcardio.CardTerminals; +import javax.smartcardio.TerminalFactorySpi; + +/** + * OS X PC/SC provider. For more information see {@link package-info}. + * + * @author Benedikt Biallowons + */ +public final class SunOSXPCSC extends Provider { + + private static final long serialVersionUID = -8720099822090870310L; + + /** + * Default constructor registering this provider. + */ + public SunOSXPCSC() { + super("SunOSXPCSC", 1.0d, "Sun OS X PC/SC provider"); + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + put("TerminalFactory.PC/SC", + "org.openecard.scio.osx.SunOSXPCSC$Factory"); + return null; + } + }); + } + + /** + * Internal provider factory. For more information see + * {@link TerminalFactorySpi} + * + * @author Benedikt Biallowons + */ + public static final class Factory extends TerminalFactorySpi { + /** + * Constructor checking availability & initializing context. + * + * @param obj + * provider parameters + * @throws PCSCException + * if problems occur. + */ + public Factory(Object obj) throws PCSCException { + if (obj != null) { + throw new IllegalArgumentException( + "SunOSXPCSC factory doesn't take parameters"); + } + PCSC.checkAvailable(); + PCSCTerminals.initContext(); + } + + /** + * Returns the available readers. This must be a new object for each call. + * + * @return CardTerminals card terminals wrapper object + */ + @Override + protected CardTerminals engineTerminals() { + return new PCSCTerminals(); + } + } + +} -- cgit v1.2.3