/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package javax.net.ssl;

import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;

/**
 * The <i>Service Provider Interface</i> (SPI) for the
 * {@code KeyManagerFactory} class.
 * 
 * @since Android 1.0
 */

public abstract class KeyManagerFactorySpi {

    /**
     * Creates a new {@code KeyManagerFactorySpi} instance.
     * 
     * @since Android 1.0
     */
    public KeyManagerFactorySpi() {
    }

    /**
     * Initializes this instance with the specified key store and password.
     * 
     * @param ks
     *            the key store or {@code null} to use the default key store.
     * @param password
     *            the key store password.
     * @throws KeyStoreException
     *             if initializing this instance fails.
     * @throws NoSuchAlgorithmException
     *             if a required algorithm is not available.
     * @throws UnrecoverableKeyException
     *             if a key cannot be recovered.
     * @since Android 1.0
     */
    protected abstract void engineInit(KeyStore ks, char[] password)
            throws KeyStoreException, NoSuchAlgorithmException,
            UnrecoverableKeyException;

    /**
     * Initializes this instance with the specified factory parameters.
     * 
     * @param spec
     *            the factory parameters.
     * @throws InvalidAlgorithmParameterException
     *             if an error occurs.
     * @since Android 1.0
     */
    protected abstract void engineInit(ManagerFactoryParameters spec)
            throws InvalidAlgorithmParameterException;

    /**
     * Returns a list of key managers, one instance for each type of key in the
     * key store.
     * 
     * @return a list of key managers.
     * @since Android 1.0
     */
    protected abstract KeyManager[] engineGetKeyManagers();
}