Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.smartcardio/share/classes/sun/security/smartcardio/SunPCSC.java
41159 views
1
/*
2
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.security.smartcardio;
27
28
import java.security.*;
29
30
import javax.smartcardio.*;
31
import static sun.security.util.SecurityConstants.PROVIDER_VER;
32
33
/**
34
* Provider object for PC/SC.
35
*
36
* @since 1.6
37
* @author Andreas Sterbenz
38
*/
39
public final class SunPCSC extends Provider {
40
41
private static final long serialVersionUID = 6168388284028876579L;
42
43
private static final class ProviderService extends Provider.Service {
44
45
ProviderService(Provider p, String type, String algo, String cn) {
46
super(p, type, algo, cn, null, null);
47
}
48
49
@Override
50
public Object newInstance(Object ctrParamObj)
51
throws NoSuchAlgorithmException {
52
String type = getType();
53
String algo = getAlgorithm();
54
try {
55
if (type.equals("TerminalFactory") &&
56
algo.equals("PC/SC")) {
57
return new SunPCSC.Factory(ctrParamObj);
58
}
59
} catch (Exception ex) {
60
throw new NoSuchAlgorithmException("Error constructing " +
61
type + " for " + algo + " using SunPCSC", ex);
62
}
63
throw new ProviderException("No impl for " + algo +
64
" " + type);
65
}
66
}
67
68
@SuppressWarnings("removal")
69
public SunPCSC() {
70
super("SunPCSC", PROVIDER_VER, "Sun PC/SC provider");
71
72
final Provider p = this;
73
AccessController.doPrivileged(new PrivilegedAction<Void>() {
74
public Void run() {
75
putService(new ProviderService(p, "TerminalFactory",
76
"PC/SC", "sun.security.smartcardio.SunPCSC$Factory"));
77
return null;
78
}
79
});
80
}
81
82
public static final class Factory extends TerminalFactorySpi {
83
public Factory(Object obj) throws PCSCException {
84
if (obj != null) {
85
throw new IllegalArgumentException
86
("SunPCSC factory does not use parameters");
87
}
88
// make sure PCSC is available and that we can obtain a context
89
PCSC.checkAvailable();
90
PCSCTerminals.initContext();
91
}
92
/**
93
* Returns the available readers.
94
* This must be a new object for each call.
95
*/
96
protected CardTerminals engineTerminals() {
97
return new PCSCTerminals();
98
}
99
}
100
101
}
102
103