Example usage for javax.crypto Cipher getMaxAllowedParameterSpec

List of usage examples for javax.crypto Cipher getMaxAllowedParameterSpec

Introduction

In this page you can find the example usage for javax.crypto Cipher getMaxAllowedParameterSpec.

Prototype

public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(String transformation)
        throws NoSuchAlgorithmException 

Source Link

Document

Returns an AlgorithmParameterSpec object which contains the maximum cipher parameter value according to the jurisdiction policy file.

Usage

From source file:org.jumpmind.security.SecurityService.java

protected void initializeCipher(Cipher cipher, int mode) throws Exception {
    AlgorithmParameterSpec paramSpec = Cipher.getMaxAllowedParameterSpec(cipher.getAlgorithm());

    if (paramSpec instanceof PBEParameterSpec
            || (paramSpec == null && cipher.getAlgorithm().startsWith("PBE"))) {
        paramSpec = new PBEParameterSpec(SecurityConstants.SALT, SecurityConstants.ITERATION_COUNT);
        cipher.init(mode, secretKey, paramSpec);
    } else if (paramSpec instanceof IvParameterSpec) {
        paramSpec = new IvParameterSpec(SecurityConstants.SALT);
        cipher.init(mode, secretKey, paramSpec);
    } else {/* w  w w  .j  av  a  2s .  c  om*/
        cipher.init(mode, secretKey, (AlgorithmParameterSpec) null);
    }
}