Package org.jasypt.exceptions

Examples of org.jasypt.exceptions.EncryptionInitializationException


     * Clones will NOT be initialized.
     */
    synchronized StandardPBEByteEncryptor[] cloneAndInitializeEncryptor(final int size) {

        if (isInitialized()) {
            throw new EncryptionInitializationException(
                    "Cannot clone encryptor if it has been already initialized");
        }

        // If there is a config object, this forces the password configured value
        // (if any) into the this.password property.
View Full Code Here


           
            try {
           
                // Password cannot be null.
                if (this.password == null) {
                    throw new EncryptionInitializationException(
                            "Password not set for Password Based Encryptor");
                }
               
                // Normalize password to NFC form
                final char[] normalizedPassword = Normalizer.normalizeToNfc(this.password);
               
                /*
                 * Encryption and decryption Ciphers are created the usual way.
                 */
                PBEKeySpec pbeKeySpec = new PBEKeySpec(normalizedPassword);
               
                // We don't need the char[] passwords anymore -> clean!
                cleanPassword(this.password);
                cleanPassword(normalizedPassword);
               
               
                if (this.provider != null) {
                   
                    SecretKeyFactory factory =
                        SecretKeyFactory.getInstance(
                                this.algorithm,
                                this.provider);
                   
                    this.key = factory.generateSecret(pbeKeySpec);
                   
                    this.encryptCipher =
                        Cipher.getInstance(this.algorithm, this.provider);
                    this.decryptCipher =
                        Cipher.getInstance(this.algorithm, this.provider);
                   
                } else if (this.providerName != null) {
                   
                    SecretKeyFactory factory =
                        SecretKeyFactory.getInstance(
                                this.algorithm,
                                this.providerName);
                   
                    this.key = factory.generateSecret(pbeKeySpec);
                   
                    this.encryptCipher =
                        Cipher.getInstance(this.algorithm, this.providerName);
                    this.decryptCipher =
                        Cipher.getInstance(this.algorithm, this.providerName);
                   
                } else {
                   
                    SecretKeyFactory factory =
                        SecretKeyFactory.getInstance(this.algorithm);
                   
                    this.key = factory.generateSecret(pbeKeySpec);
                   
                    this.encryptCipher = Cipher.getInstance(this.algorithm);
                    this.decryptCipher = Cipher.getInstance(this.algorithm);
                   
                }

            } catch (EncryptionInitializationException e) {
                throw e;
            } catch (Throwable t) {
                throw new EncryptionInitializationException(t);
            }
           

            // The salt size for the chosen algorithm is set to be equal
            // to the algorithm's block size (if it is a block algorithm).
View Full Code Here

    public void setKeyObtentionIterations(final String keyObtentionIterations) {
        if (keyObtentionIterations != null) {
            try {
                this.keyObtentionIterations = new Integer(keyObtentionIterations);
            } catch (NumberFormatException e) {
                throw new EncryptionInitializationException(e);
            }
        } else {
            this.keyObtentionIterations = null;
        }
    }
View Full Code Here

                final Class saltGeneratorClass =
                    Thread.currentThread().getContextClassLoader().loadClass(saltGeneratorClassName);
                this.saltGenerator =
                    (SaltGenerator) saltGeneratorClass.newInstance();
            } catch (Exception e) {
                throw new EncryptionInitializationException(e);
            }
        } else {
            this.saltGenerator = null;
        }
    }
View Full Code Here

            try {
                final Class providerClass =
                    Thread.currentThread().getContextClassLoader().loadClass(providerClassName);
                this.provider = (Provider) providerClass.newInstance();
            } catch (Exception e) {
                throw new EncryptionInitializationException(e);
            }
        } else {
            this.provider = null;
        }
    }
View Full Code Here

    public void setPoolSize(final String poolSize) {
        if (poolSize != null) {
            try {
                this.poolSize = new Integer(poolSize);
            } catch (NumberFormatException e) {
                throw new EncryptionInitializationException(e);
            }
        } else {
            this.poolSize = null;
        }
    }
View Full Code Here

        final String className =
            sce.getServletContext().getInitParameter(
                    INIT_PARAM_INITIALIZER_CLASS_NAME);
       
        if (CommonUtils.isEmpty(className)) {
            throw new EncryptionInitializationException(
                    INIT_PARAM_INITIALIZER_CLASS_NAME + " context " +
                    "initialization parameter not set in web.xml");
        }

        Class initializerClass = null;
        try {
            initializerClass =
                Thread.currentThread().getContextClassLoader().loadClass(className);
        } catch (ClassNotFoundException e) {
            throw new EncryptionInitializationException(e);
        }
       
        if (!WebPBEInitializer.class.isAssignableFrom(initializerClass)) {
            throw new EncryptionInitializationException("Class " +
                    className + " does not implement interface " +
                    WebPBEInitializer.class.getName());
        }
       
        WebPBEInitializer initializer = null;
        try {
            initializer =
                (WebPBEInitializer) initializerClass.newInstance();
        } catch (InstantiationException e) {
            throw new EncryptionInitializationException(e);
        } catch (IllegalAccessException e) {
            throw new EncryptionInitializationException(e);
        }

        // Let the user initialize his/her encryptors and WebPBEConfig objects.
        initializer.initializeWebPBEConfigs();
       
View Full Code Here

           
            WebPBEConfig config =
                (WebPBEConfig) configsIter.next();
           
            if (!config.isComplete()) {
                throw new EncryptionInitializationException("Incomplete " +
                        "WebPBEConfig object: all configs must specify " +
                        "both a name and a validation word");
            }
           
            strBuff.append("     <fieldset>\n");
View Full Code Here

    }
   
   
    public synchronized void registerConfig(final WebPBEConfig config) {
        if (this.webConfigurationDone) {
            throw new EncryptionInitializationException(
                    "Cannot register: Web configuration is already done");
        }
        // Avoid duplication of encryptors because of the initialization
        // class being called more than once.
        if (!this.names.contains(config.getName())) {
View Full Code Here

                useIcuNormalizer = Boolean.TRUE;
            } catch (ClassNotFoundException e) {
                try {
                    Thread.currentThread().getContextClassLoader().loadClass(JDK_NORMALIZER_CLASS_NAME);
                } catch (ClassNotFoundException e2) {
                    throw new EncryptionInitializationException(
                            "Cannot find a valid UNICODE normalizer: neither " + JDK_NORMALIZER_CLASS_NAME + " nor " +
                            ICU_NORMALIZER_CLASS_NAME + " have been found at the classpath. If you are using " +
                            "a version of the JDK older than JavaSE 6, you should include the icu4j library in " +
                            "your classpath.");
                }
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.