Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/macosx/classes/apple/security/AppleProvider.java
41133 views
1
/*
2
* Copyright (c) 2011, 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 apple.security;
27
28
import java.security.*;
29
import static sun.security.util.SecurityConstants.PROVIDER_VER;
30
31
/**
32
* The Apple Security Provider.
33
*/
34
35
/**
36
* Defines the Apple provider.
37
*
38
* This provider only exists to provide access to the Apple keychain-based KeyStore implementation
39
*/
40
@SuppressWarnings("serial") // JDK implementation class
41
public final class AppleProvider extends Provider {
42
43
private static final String info = "Apple Provider";
44
45
private static final class ProviderService extends Provider.Service {
46
ProviderService(Provider p, String type, String algo, String cn) {
47
super(p, type, algo, cn, null, null);
48
}
49
50
@Override
51
public Object newInstance(Object ctrParamObj)
52
throws NoSuchAlgorithmException {
53
String type = getType();
54
if (ctrParamObj != null) {
55
throw new InvalidParameterException
56
("constructorParameter not used with " + type + " engines");
57
}
58
59
String algo = getAlgorithm();
60
try {
61
if (type.equals("KeyStore")) {
62
if (algo.equals("KeychainStore")) {
63
return new KeychainStore();
64
}
65
}
66
} catch (Exception ex) {
67
throw new NoSuchAlgorithmException("Error constructing " +
68
type + " for " + algo + " using Apple", ex);
69
}
70
throw new ProviderException("No impl for " + algo +
71
" " + type);
72
}
73
}
74
75
76
@SuppressWarnings("removal")
77
public AppleProvider() {
78
/* We are the Apple provider */
79
super("Apple", PROVIDER_VER, info);
80
81
final Provider p = this;
82
AccessController.doPrivileged(new PrivilegedAction<Void>() {
83
public Void run() {
84
putService(new ProviderService(p, "KeyStore",
85
"KeychainStore", "apple.security.KeychainStore"));
86
return null;
87
}
88
});
89
}
90
}
91
92