Code example for InvalidAlgorithmParameterException

0
            SecureRandom            random)
            throws InvalidAlgorithmParameterException 
        { 
            if (!(params instanceof DSAParameterSpec))
            { 
                throw new InvalidAlgorithmParameterException("parameter object not a DSAParameterSpec");
            } 
            DSAParameterSpec     dsaParams = (DSAParameterSpec)params;
 
            param = new DSAKeyGenerationParameters(random, new DSAParameters(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG()));
 
            engine.init(param);
            initialised = true;
        } 
 
        public KeyPair generateKeyPair()
        { 
            if (!initialised)
            { 
                DSAParametersGenerator   pGen = new DSAParametersGenerator();