jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/SunPCSC.java
changeset 31270 e6470b24700d
parent 25859 3317bb8137f4
child 33991 619bfc4d582d
equal deleted inserted replaced
31269:14968253ce7e 31270:e6470b24700d
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    37  */
    37  */
    38 public final class SunPCSC extends Provider {
    38 public final class SunPCSC extends Provider {
    39 
    39 
    40     private static final long serialVersionUID = 6168388284028876579L;
    40     private static final long serialVersionUID = 6168388284028876579L;
    41 
    41 
       
    42     private static final class ProviderService extends Provider.Service {
       
    43 
       
    44         ProviderService(Provider p, String type, String algo, String cn) {
       
    45             super(p, type, algo, cn, null, null);
       
    46         }
       
    47 
       
    48         @Override
       
    49         public Object newInstance(Object ctrParamObj)
       
    50             throws NoSuchAlgorithmException {
       
    51             String type = getType();
       
    52             String algo = getAlgorithm();
       
    53             try {
       
    54                 if (type.equals("TerminalFactory") &&
       
    55                     algo.equals("PC/SC")) {
       
    56                     return new SunPCSC.Factory(ctrParamObj);
       
    57                 }
       
    58             } catch (Exception ex) {
       
    59                 throw new NoSuchAlgorithmException("Error constructing " +
       
    60                     type + " for " + algo + " using SunPCSC", ex);
       
    61             }
       
    62             throw new ProviderException("No impl for " + algo +
       
    63                 " " + type);
       
    64         }
       
    65     }
       
    66 
    42     public SunPCSC() {
    67     public SunPCSC() {
    43         super("SunPCSC", 1.9d, "Sun PC/SC provider");
    68         super("SunPCSC", 1.9d, "Sun PC/SC provider");
       
    69 
       
    70         final Provider p = this;
    44         AccessController.doPrivileged(new PrivilegedAction<Void>() {
    71         AccessController.doPrivileged(new PrivilegedAction<Void>() {
    45             public Void run() {
    72             public Void run() {
    46                 put("TerminalFactory.PC/SC", "sun.security.smartcardio.SunPCSC$Factory");
    73                 putService(new ProviderService(p, "TerminalFactory",
       
    74                            "PC/SC", "sun.security.smartcardio.SunPCSC$Factory"));
    47                 return null;
    75                 return null;
    48             }
    76             }
    49         });
    77         });
    50     }
    78     }
    51 
    79