PCSC4Java
0.2
Library PCSC for Java language.
|
00001 /* 00002 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 00003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00004 * 00005 * This code is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU General Public License version 2 only, as 00007 * published by the Free Software Foundation. Oracle designates this 00008 * particular file as subject to the "Classpath" exception as provided 00009 * by Oracle in the LICENSE file that accompanied this code. 00010 * 00011 * This code is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 * version 2 for more details (a copy is included in the LICENSE file that 00015 * accompanied this code). 00016 * 00017 * You should have received a copy of the GNU General Public License version 00018 * 2 along with this work; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 00020 * 00021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 00022 * or visit www.oracle.com if you need additional information or have any 00023 * questions. 00024 */ 00025 00026 package fr.redbilled.security.pcscforjava; 00027 00028 import java.security.*; 00029 00030 import fr.redbilled.pcscforjava.*; 00031 import java.util.logging.Level; 00032 import java.util.logging.Logger; 00033 00040 public final class PCSC4Java extends Provider { 00041 00042 private static final long serialVersionUID = 6168388284028876579L; 00043 00044 public PCSC4Java() { 00045 super("PCSC4Java", 0.1d, "PC/SC 4 Java provider"); 00046 AccessController.doPrivileged(new PrivilegedAction<Void>() { 00047 public Void run() { 00048 put("TerminalFactory.PC/SC", 00049 "fr.redbilled.security.pcscforjava.PCSC4Java$Factory"); 00050 return null; 00051 } 00052 }); 00053 } 00054 00055 public static final class Factory extends TerminalFactorySpi { 00056 public Factory(Object obj) throws PCSCException { 00057 if (obj != null) { 00058 throw new IllegalArgumentException 00059 ("PCSC 4 Java factory does not use parameters"); 00060 } 00061 // make sure PCSC is available and that we can obtain a context 00062 PCSC.checkAvailable(); 00063 PCSCTerminals.initContext(); 00064 } 00069 protected CardTerminals engineTerminals() { 00070 return new PCSCTerminals(); 00071 } 00072 00077 @Override 00078 protected boolean destroyTerminals() { 00079 try 00080 { 00081 PCSCTerminals.releaseContext(); 00082 } 00083 catch (PCSCException ex) 00084 { 00085 return false; 00086 } 00087 00088 return true; 00089 } 00090 } 00091 00092 }