1 /*
2  * Copyright (c) 1999, 2001, 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 javax.net.ssl;
27 
28 import java.security.*;
29 
30 /**
31  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
32  * for the <code>KeyManagerFactory</code> class.
33  *
34  * <p> All the abstract methods in this class must be implemented by each
35  * cryptographic service provider who wishes to supply the implementation
36  * of a particular key manager factory.
37  *
38  * @since 1.4
39  * @see KeyManagerFactory
40  * @see KeyManager
41  */
42 public abstract class KeyManagerFactorySpi {
43     /**
44      * Initializes this factory with a source of key material.
45      *
46      * @param ks the key store or null
47      * @param password the password for recovering keys
48      * @throws KeyStoreException if this operation fails
49      * @throws NoSuchAlgorithmException if the specified algorithm is not
50      *          available from the specified provider.
51      * @throws UnrecoverableKeyException if the key cannot be recovered
52      * @see KeyManagerFactory#init(KeyStore, char[])
53      */
engineInit(KeyStore ks, char[] password)54     protected abstract void engineInit(KeyStore ks, char[] password) throws
55         KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException;
56 
57     /**
58      * Initializes this factory with a source of key material.
59      * <P>
60      * In some cases, initialization parameters other than a keystore
61      * and password may be needed by a provider.  Users of that
62      * particular provider are expected to pass an implementation of
63      * the appropriate <CODE>ManagerFactoryParameters</CODE> as
64      * defined by the provider.  The provider can then call the
65      * specified methods in the ManagerFactoryParameters
66      * implementation to obtain the needed information.
67      *
68      * @param spec an implementation of a provider-specific parameter
69      *          specification
70      * @throws InvalidAlgorithmParameterException if there is problem
71      *          with the parameters
72      * @see KeyManagerFactory#init(ManagerFactoryParameters spec)
73      */
engineInit(ManagerFactoryParameters spec)74     protected abstract void engineInit(ManagerFactoryParameters spec)
75         throws InvalidAlgorithmParameterException;
76 
77     /**
78      * Returns one key manager for each type of key material.
79      *
80      * @return the key managers
81      * @throws IllegalStateException
82      *         if the KeyManagerFactorySpi is not initialized
83      */
engineGetKeyManagers()84     protected abstract KeyManager[] engineGetKeyManagers();
85 }
86