Java Code Examples for org.jasypt.encryption.pbe.StandardPBEStringEncryptor#initialize()

The following examples show how to use org.jasypt.encryption.pbe.StandardPBEStringEncryptor#initialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringEncryptor.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private StringEncryptor(final String aglorithm, final String provider, final String key) {
    encryptor = new StandardPBEStringEncryptor();
    encryptor.setAlgorithm(aglorithm);
    encryptor.setProviderName(provider);
    encryptor.setPassword(key);
    encryptor.setStringOutputType("hexadecimal");
    encryptor.initialize();
}
 
Example 2
Source File: AbstractEncryptedAsStringType.java    From jasypt with Apache License 2.0 4 votes vote down vote up
protected synchronized final void checkInitialization() {
    
    if (!this.initialized) {
        
        if (this.useEncryptorName) {

            final HibernatePBEEncryptorRegistry registry = 
                HibernatePBEEncryptorRegistry.getInstance();
            final PBEStringEncryptor pbeEncryptor = 
                registry.getPBEStringEncryptor(this.encryptorName);
            if (pbeEncryptor == null) {
                throw new EncryptionInitializationException(
                        "No string encryptor registered for hibernate " +
                        "with name \"" + this.encryptorName + "\"");
            }
            this.encryptor = pbeEncryptor;
            
        } else {
            
            final StandardPBEStringEncryptor newEncryptor = 
                new StandardPBEStringEncryptor();
            
            newEncryptor.setPassword(this.password);
            
            if (this.algorithm != null) {
                newEncryptor.setAlgorithm(this.algorithm);
            }
            
            if (this.providerName != null) {
                newEncryptor.setProviderName(this.providerName);
            }
            
            if (this.keyObtentionIterations != null) {
                newEncryptor.setKeyObtentionIterations(
                        this.keyObtentionIterations.intValue());
            }
            
            if (this.stringOutputType != null) {
                newEncryptor.setStringOutputType(this.stringOutputType);
            }
            
            newEncryptor.initialize();
            
            this.encryptor = newEncryptor;
            
        }
        
        this.initialized = true;
    }
    
}
 
Example 3
Source File: AbstractEncryptedAsStringType.java    From jasypt with Apache License 2.0 4 votes vote down vote up
protected synchronized final void checkInitialization() {
    
    if (!this.initialized) {
        
        if (this.useEncryptorName) {

            final HibernatePBEEncryptorRegistry registry = 
                HibernatePBEEncryptorRegistry.getInstance();
            final PBEStringEncryptor pbeEncryptor = 
                registry.getPBEStringEncryptor(this.encryptorName);
            if (pbeEncryptor == null) {
                throw new EncryptionInitializationException(
                        "No string encryptor registered for hibernate " +
                        "with name \"" + this.encryptorName + "\"");
            }
            this.encryptor = pbeEncryptor;
            
        } else {
            
            final StandardPBEStringEncryptor newEncryptor = 
                new StandardPBEStringEncryptor();
            
            newEncryptor.setPassword(this.password);
            
            if (this.algorithm != null) {
                newEncryptor.setAlgorithm(this.algorithm);
            }
            
            if (this.providerName != null) {
                newEncryptor.setProviderName(this.providerName);
            }
            
            if (this.keyObtentionIterations != null) {
                newEncryptor.setKeyObtentionIterations(
                        this.keyObtentionIterations.intValue());
            }
            
            if (this.stringOutputType != null) {
                newEncryptor.setStringOutputType(this.stringOutputType);
            }
            
            newEncryptor.initialize();
            
            this.encryptor = newEncryptor;
            
        }
        
        this.initialized = true;
    }
    
}
 
Example 4
Source File: AbstractEncryptedAsStringType.java    From jasypt with Apache License 2.0 4 votes vote down vote up
protected synchronized final void checkInitialization() {
    
    if (!this.initialized) {
        
        if (this.useEncryptorName) {

            final HibernatePBEEncryptorRegistry registry = 
                HibernatePBEEncryptorRegistry.getInstance();
            final PBEStringEncryptor pbeEncryptor = 
                registry.getPBEStringEncryptor(this.encryptorName);
            if (pbeEncryptor == null) {
                throw new EncryptionInitializationException(
                        "No string encryptor registered for hibernate " +
                        "with name \"" + this.encryptorName + "\"");
            }
            this.encryptor = pbeEncryptor;
            
        } else {
            
            final StandardPBEStringEncryptor newEncryptor = 
                new StandardPBEStringEncryptor();
            
            newEncryptor.setPassword(this.password);
            
            if (this.algorithm != null) {
                newEncryptor.setAlgorithm(this.algorithm);
            }
            
            if (this.providerName != null) {
                newEncryptor.setProviderName(this.providerName);
            }
            
            if (this.keyObtentionIterations != null) {
                newEncryptor.setKeyObtentionIterations(
                        this.keyObtentionIterations.intValue());
            }
            
            if (this.stringOutputType != null) {
                newEncryptor.setStringOutputType(this.stringOutputType);
            }
            
            newEncryptor.initialize();
            
            this.encryptor = newEncryptor;
            
        }
        
        this.initialized = true;
    }
    
}
 
Example 5
Source File: AbstractEncryptedAsStringType.java    From jasypt with Apache License 2.0 4 votes vote down vote up
protected synchronized final void checkInitialization() {
    
    if (!this.initialized) {
        
        if (this.useEncryptorName) {

            final HibernatePBEEncryptorRegistry registry = 
                HibernatePBEEncryptorRegistry.getInstance();
            final PBEStringEncryptor pbeEncryptor = 
                registry.getPBEStringEncryptor(this.encryptorName);
            if (pbeEncryptor == null) {
                throw new EncryptionInitializationException(
                        "No string encryptor registered for hibernate " +
                        "with name \"" + this.encryptorName + "\"");
            }
            this.encryptor = pbeEncryptor;
            
        } else {
            
            final StandardPBEStringEncryptor newEncryptor = 
                new StandardPBEStringEncryptor();
            
            newEncryptor.setPassword(this.password);
            
            if (this.algorithm != null) {
                newEncryptor.setAlgorithm(this.algorithm);
            }
            
            if (this.providerName != null) {
                newEncryptor.setProviderName(this.providerName);
            }
            
            if (this.keyObtentionIterations != null) {
                newEncryptor.setKeyObtentionIterations(
                        this.keyObtentionIterations.intValue());
            }
            
            if (this.stringOutputType != null) {
                newEncryptor.setStringOutputType(this.stringOutputType);
            }
            
            newEncryptor.initialize();
            
            this.encryptor = newEncryptor;
            
        }
        
        this.initialized = true;
    }
    
}