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 java.security;
19
20import java.security.spec.AlgorithmParameterSpec;
21
22/**
23 * {@code KeyPairGeneratorSpi} is the Service Provider Interface (SPI)
24 * definition for {@link KeyPairGenerator}.
25 *
26 * @see KeyPairGenerator
27 */
28public abstract class KeyPairGeneratorSpi {
29    /**
30     * Constructs a new instance of {@code KeyPairGeneratorSpi}.
31     */
32    public KeyPairGeneratorSpi() {
33    }
34
35    /**
36     * Computes and returns a new unique {@code KeyPair} each time this method
37     * is called.
38     *
39     * @return a new unique {@code KeyPair} each time this method is called.
40     */
41    public abstract KeyPair generateKeyPair();
42
43    /**
44     * Initializes this {@code KeyPairGeneratorSpi} with the given key size and
45     * the given {@code SecureRandom}. The default parameter set will be used.
46     *
47     * @param keysize
48     *            the key size (number of bits).
49     * @param random
50     *            the source of randomness.
51     */
52    public abstract void initialize(int keysize, SecureRandom random);
53
54    /**
55     * Initializes this {@code KeyPairGeneratorSpi} with the given {@code
56     * AlgorithmParameterSpec} and the given {@code SecureRandom}.
57     *
58     * @param params
59     *            the parameters to use.
60     * @param random
61     *            the source of randomness.
62     * @throws InvalidAlgorithmParameterException
63     *             if the specified parameters are not supported.
64     */
65    public void initialize(AlgorithmParameterSpec params, SecureRandom random)
66            throws InvalidAlgorithmParameterException {
67        throw new UnsupportedOperationException();
68    }
69}
70