Path: blob/master/src/java.base/macosx/classes/apple/security/AppleProvider.java
41133 views
/*1* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package apple.security;2627import java.security.*;28import static sun.security.util.SecurityConstants.PROVIDER_VER;2930/**31* The Apple Security Provider.32*/3334/**35* Defines the Apple provider.36*37* This provider only exists to provide access to the Apple keychain-based KeyStore implementation38*/39@SuppressWarnings("serial") // JDK implementation class40public final class AppleProvider extends Provider {4142private static final String info = "Apple Provider";4344private static final class ProviderService extends Provider.Service {45ProviderService(Provider p, String type, String algo, String cn) {46super(p, type, algo, cn, null, null);47}4849@Override50public Object newInstance(Object ctrParamObj)51throws NoSuchAlgorithmException {52String type = getType();53if (ctrParamObj != null) {54throw new InvalidParameterException55("constructorParameter not used with " + type + " engines");56}5758String algo = getAlgorithm();59try {60if (type.equals("KeyStore")) {61if (algo.equals("KeychainStore")) {62return new KeychainStore();63}64}65} catch (Exception ex) {66throw new NoSuchAlgorithmException("Error constructing " +67type + " for " + algo + " using Apple", ex);68}69throw new ProviderException("No impl for " + algo +70" " + type);71}72}737475@SuppressWarnings("removal")76public AppleProvider() {77/* We are the Apple provider */78super("Apple", PROVIDER_VER, info);7980final Provider p = this;81AccessController.doPrivileged(new PrivilegedAction<Void>() {82public Void run() {83putService(new ProviderService(p, "KeyStore",84"KeychainStore", "apple.security.KeychainStore"));85return null;86}87});88}89}909192