Code example for InvalidAlgorithmParameterException

0
            AlgorithmParameterSpec  genParamSpec,
            SecureRandom            random)
            throws InvalidAlgorithmParameterException 
        { 
            if (!(genParamSpec instanceof DHGenParameterSpec))
            { 
                throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation");
            } 
            DHGenParameterSpec  spec = (DHGenParameterSpec)genParamSpec;
 
            this.strength = spec.getPrimeSize();
            this.l = spec.getExponentSize();
            this.random = random;
        } 
 
        protected AlgorithmParameters engineGenerateParameters()
        { 
            DHParametersGenerator        pGen = new DHParametersGenerator();
 
            if (random != null)
            {