Package org.jasypt.exceptions

Examples of org.jasypt.exceptions.EncryptionInitializationException


     *
     * @param algorithm the algorithm to be set for the internal encryptor
     */
    public void setAlgorithm(String algorithm) {
        if (this.encryptorSet) {
            throw new EncryptionInitializationException(
                    "An encryptor has been already set: no " +
                    "further configuration possible on hibernate wrapper");
        }
        StandardPBEBigDecimalEncryptor standardPBEBigDecimalEncryptor =
            (StandardPBEBigDecimalEncryptor) this.encryptor;
View Full Code Here


     *
     * @param keyObtentionIterations to be set for the internal encryptor
     */
    public void setKeyObtentionIterations(int keyObtentionIterations) {
        if (this.encryptorSet) {
            throw new EncryptionInitializationException(
                    "An encryptor has been already set: no " +
                    "further configuration possible on hibernate wrapper");
        }
        StandardPBEBigDecimalEncryptor standardPBEBigDecimalEncryptor =
            (StandardPBEBigDecimalEncryptor) this.encryptor;
View Full Code Here

     * @param saltGenerator the salt generator to be set for the internal
     *                      encryptor.
     */
    public void setSaltGenerator(SaltGenerator saltGenerator) {
        if (this.encryptorSet) {
            throw new EncryptionInitializationException(
                    "An encryptor has been already set: no " +
                    "further configuration possible on hibernate wrapper");
        }
        StandardPBEBigDecimalEncryptor standardPBEBigDecimalEncryptor =
            (StandardPBEBigDecimalEncryptor) this.encryptor;
View Full Code Here

     *
     * @param config the PBEConfig to be set for the internal encryptor
     */
    public void setConfig(PBEConfig config) {
        if (this.encryptorSet) {
            throw new EncryptionInitializationException(
                    "An encryptor has been already set: no " +
                    "further configuration possible on hibernate wrapper");
        }
        StandardPBEBigDecimalEncryptor standardPBEBigDecimalEncryptor =
            (StandardPBEBigDecimalEncryptor) this.encryptor;
View Full Code Here

     * @param message the message to be encrypted.
     * @return the encryption result.
     */
    public BigDecimal encrypt(BigDecimal message) {
        if (this.encryptor == null) {
            throw new EncryptionInitializationException(
                    "Encryptor has not been set into Hibernate wrapper");
        }
        return this.encryptor.encrypt(message);
    }
View Full Code Here

     * @param encryptedMessage the message to be decrypted.
     * @return the result of decryption.
     */
    public BigDecimal decrypt(BigDecimal encryptedMessage) {
        if (this.encryptor == null) {
            throw new EncryptionInitializationException(
                    "Encryptor has not been set into Hibernate wrapper");
        }
        return this.encryptor.decrypt(encryptedMessage);
    }
View Full Code Here

     * @param lengthBytes length in bytes.
     * @return the generated salt.
     */
    public byte[] generateSalt(final int lengthBytes) {
        if (this.salt == null) {
            throw new EncryptionInitializationException(
                    "Salt has not been set");
        }
        if (this.saltBytes == null) {
            try {
                this.saltBytes = this.salt.getBytes(this.charset);
            } catch (UnsupportedEncodingException e) {
                throw new EncryptionInitializationException(
                    "Invalid charset specified: " + this.charset);
            }
        }
        if (this.saltBytes.length < lengthBytes) {
            throw new EncryptionInitializationException(
                    "Requested salt larger than set");
        }
        final byte[] generatedSalt = new byte[lengthBytes];
        System.arraycopy(this.saltBytes, 0, generatedSalt, 0, lengthBytes);
        return generatedSalt;
View Full Code Here

     * @param lengthBytes length in bytes.
     * @return the generated salt.
     */
    public byte[] generateSalt(final int lengthBytes) {
        if (this.salt == null) {
            throw new EncryptionInitializationException(
                    "Salt has not been set");
        }
        if (this.salt.length < lengthBytes) {
            throw new EncryptionInitializationException(
                    "Requested salt larger than set");
        }
        final byte[] generatedSalt = new byte[lengthBytes];
        System.arraycopy(this.salt, 0, generatedSalt, 0, lengthBytes);
        return generatedSalt;
View Full Code Here

    public RandomSaltGenerator(final String secureRandomAlgorithm) {
        super();
        try {
            this.random = SecureRandom.getInstance(secureRandomAlgorithm);
        } catch (NoSuchAlgorithmException e) {
            throw new EncryptionInitializationException(e);
        }
    }
View Full Code Here

             * Test compatibility of salt generator with salt size checking
             * behaviour
             */
            if (this.useLenientSaltSizeCheck) {
                if (!this.saltGenerator.includePlainSaltInEncryptionResults()) {
                    throw new EncryptionInitializationException(
                            "The configured Salt Generator (" +
                            this.saltGenerator.getClass().getName() +
                            ") does not include plain salt " +
                            "in encryption results, which is not compatible" +
                            "with setting the salt size checking behaviour to \"lenient\".");
                }
            }
           
            /*
             * MessageDigest is initialized the usual way, and the digester
             * is marked as "initialized" so that configuration cannot be
             * changed in the future.
             */
            try {
                if (this.provider != null) {
                    this.md =
                        MessageDigest.getInstance(
                                this.algorithm,
                                this.provider);
                } else if (this.providerName != null) {
                    this.md =
                        MessageDigest.getInstance(
                                this.algorithm,
                                this.providerName);
                } else {
                    this.md = MessageDigest.getInstance(this.algorithm);
                }
            } catch (NoSuchAlgorithmException e) {
                throw new EncryptionInitializationException(e);
            } catch (NoSuchProviderException e) {
                throw new EncryptionInitializationException(e);
            }
           
           
            /*
             * Store the digest length (algorithm-dependent) and check
             * the operation is supported by the provider.
             */
            this.digestLengthBytes = this.md.getDigestLength();
            if (this.digestLengthBytes <= 0) {
                throw new EncryptionInitializationException(
                        "The configured algorithm (" +
                        this.algorithm + ") or its provider do  " +
                        "not allow knowing the digest length beforehand " +
                        "(getDigestLength() operation), which is not compatible" +
                        "with setting the salt size checking behaviour to \"lenient\".");
View Full Code Here

TOP

Related Classes of org.jasypt.exceptions.EncryptionInitializationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.