1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package javax.net.ssl;
19
20import java.security.InvalidAlgorithmParameterException;
21import java.security.KeyStore;
22import java.security.KeyStoreException;
23import java.security.NoSuchAlgorithmException;
24import java.security.UnrecoverableKeyException;
25
26/**
27 * The <i>Service Provider Interface</i> (SPI) for the
28 * {@code KeyManagerFactory} class.
29 */
30public abstract class KeyManagerFactorySpi {
31
32    /**
33     * Creates a new {@code KeyManagerFactorySpi} instance.
34     */
35    public KeyManagerFactorySpi() {
36    }
37
38    /**
39     * Initializes this instance with the specified key store and password.
40     *
41     * @param ks
42     *            the key store or {@code null} to use the default key store.
43     * @param password
44     *            the key store password.
45     * @throws KeyStoreException
46     *             if initializing this instance fails.
47     * @throws NoSuchAlgorithmException
48     *             if a required algorithm is not available.
49     * @throws UnrecoverableKeyException
50     *             if a key cannot be recovered.
51     */
52    protected abstract void engineInit(KeyStore ks, char[] password) throws KeyStoreException,
53            NoSuchAlgorithmException, UnrecoverableKeyException;
54
55    /**
56     * Initializes this instance with the specified factory parameters.
57     *
58     * @param spec
59     *            the factory parameters.
60     * @throws InvalidAlgorithmParameterException
61     *             if an error occurs.
62     */
63    protected abstract void engineInit(ManagerFactoryParameters spec)
64            throws InvalidAlgorithmParameterException;
65
66    /**
67     * Returns a list of key managers, one instance for each type of key in the
68     * key store.
69     *
70     * @return a list of key managers.
71     */
72    protected abstract KeyManager[] engineGetKeyManagers();
73}
74