001    /*
002     * Cumulus4j - Securing your data in the cloud - http://cumulus4j.org
003     * Copyright (C) 2011 NightLabs Consulting GmbH
004     *
005     * This program is free software: you can redistribute it and/or modify
006     * it under the terms of the GNU Affero General Public License as
007     * published by the Free Software Foundation, either version 3 of the
008     * License, or (at your option) any later version.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013     * GNU Affero General Public License for more details.
014     *
015     * You should have received a copy of the GNU Affero General Public License
016     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017     */
018    package org.cumulus4j.crypto;
019    
020    import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;
021    
022    /**
023     * <p>
024     * Factory creating instances of {@link AsymmetricCipherKeyPairGenerator}.
025     * </p><p>
026     * Implementations of this interface are used by {@link CryptoRegistry#createKeyPairGenerator(String, boolean)}
027     * to provide instances of <code>AsymmetricCipherKeyPairGenerator</code>.
028     * </p>
029     *
030     * @author Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de
031     */
032    public interface AsymmetricCipherKeyPairGeneratorFactory
033    {
034            /**
035             * Create and optionally initialise a new instance of {@link AsymmetricCipherKeyPairGenerator}.
036             * @param initWithDefaults whether to
037             * {@link AsymmetricCipherKeyPairGenerator#init(org.bouncycastle.crypto.KeyGenerationParameters) initialise} the <code>AsymmetricCipherKeyPairGenerator</code> with default values
038             * so that it can be used immediately as-is.
039             * @return a new instance of {@link AsymmetricCipherKeyPairGenerator} (iff <code>initWithDefaults==true</code> ready-to-use;
040             * otherwise requiring {@link AsymmetricCipherKeyPairGenerator#init(org.bouncycastle.crypto.KeyGenerationParameters) initialisation}
041             * before it can be used).
042             */
043            AsymmetricCipherKeyPairGenerator createAsymmetricCipherKeyPairGenerator(boolean initWithDefaults);
044    
045            /**
046             * Get the name of the encryption algorithm for which keys should be generated. For example "RSA".
047             * See <a target="_blank" href="http://cumulus4j.org/1.2.0/documentation/supported-algorithms.html">Supported algorithms</a>
048             * for a list of supported algorithms.
049             * @return the name of the encryption algorithm for which keys are to be generated.
050             */
051            String getAlgorithmName();
052    
053            /**
054             * Set the name of the encryption algorithm for which keys are to be generated. This method
055             * should never be called by API consumers! It should throw an {@link IllegalStateException}, if
056             * it is called again, after an algorithm name was already set before.
057             * @param algorithmName the name of the encryption algorithm; never <code>null</code>.
058             * @see #getAlgorithmName()
059             */
060            void setAlgorithmName(String algorithmName);
061    }