Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / gnu / java / security / jce / sig / KeyPairGeneratorAdapter.java
blobedf19f627e024d9da41b9581b331607082ab7b6f
1 /* KeyPairGeneratorAdapter.java --
2 Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
4 This file is a part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at
9 your option) any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 USA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.java.security.jce.sig;
41 import gnu.java.security.key.IKeyPairGenerator;
42 import gnu.java.security.key.KeyPairGeneratorFactory;
44 import java.security.InvalidAlgorithmParameterException;
45 import java.security.KeyPair;
46 import java.security.KeyPairGenerator;
47 import java.security.SecureRandom;
48 import java.security.spec.AlgorithmParameterSpec;
50 /**
51 * The implementation of a generic {@link java.security.KeyPairGenerator}
52 * adapter class to wrap gnu.crypto keypair generator instances.<p>
54 * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
55 * {@link java.security.KeyPairGenerator} class, which is used to generate pairs
56 * of public and private keys.<p>
58 * All the abstract methods in the {@link java.security.KeyPairGeneratorSpi}
59 * class are implemented by this class and all its sub-classes.<p>
61 * In case the client does not explicitly initialize the KeyPairGenerator (via
62 * a call to an <code>initialize()</code> method), the GNU Crypto provider
63 * supplies (and document) default values to be used. For example, the GNU
64 * Crypto provider uses a default <i>modulus</i> size (keysize) of 1024 bits for
65 * the DSS (Digital Signature Standard) a.k.a <i>DSA</i>.<p>
67 public abstract class KeyPairGeneratorAdapter extends KeyPairGenerator
70 // Constants and variables
71 // -------------------------------------------------------------------------
73 /** Our underlying keypair instance. */
74 protected IKeyPairGenerator adaptee;
76 // Constructor(s)
77 // -------------------------------------------------------------------------
79 /**
80 * Trivial protected constructor.
82 * @param kpgName the canonical name of the keypair generator algorithm.
84 protected KeyPairGeneratorAdapter(String kpgName)
86 super(kpgName);
88 this.adaptee = KeyPairGeneratorFactory.getInstance(kpgName);
91 // Class methods
92 // -------------------------------------------------------------------------
94 // java.security.KeyPairGeneratorSpi interface implementation
95 // -------------------------------------------------------------------------
97 public abstract void initialize(int keysize, SecureRandom random);
99 public abstract void initialize(AlgorithmParameterSpec params,
100 SecureRandom random)
101 throws InvalidAlgorithmParameterException;
103 public KeyPair generateKeyPair()
105 return adaptee.generate();