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

The following examples show how to use org.jasypt.encryption.pbe.StandardPBEStringEncryptor#setStringOutputType() . 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: HibernatePBEStringEncryptor.java    From jasypt with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the type of String output ("base64" (default), "hexadecimal") to 
 * be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param stringOutputType the type of String output
 */
public void setStringOutputType(final String stringOutputType) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setStringOutputType(stringOutputType);
}
 
Example 2
Source File: HibernatePBEStringEncryptor.java    From jasypt with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the type of String output ("base64" (default), "hexadecimal") to 
 * be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param stringOutputType the type of String output
 */
public void setStringOutputType(final String stringOutputType) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setStringOutputType(stringOutputType);
}
 
Example 3
Source File: HibernatePBEStringEncryptor.java    From jasypt with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the type of String output ("base64" (default), "hexadecimal") to 
 * be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param stringOutputType the type of String output
 */
public void setStringOutputType(final String stringOutputType) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setStringOutputType(stringOutputType);
}
 
Example 4
Source File: HibernatePBEStringEncryptor.java    From jasypt with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the type of String output ("base64" (default), "hexadecimal") to 
 * be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param stringOutputType the type of String output
 */
public void setStringOutputType(final String stringOutputType) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setStringOutputType(stringOutputType);
}
 
Example 5
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 6
Source File: TestSpringConfiguration.java    From jasypt with Apache License 2.0 4 votes vote down vote up
public void testNamespace() throws Exception {
    
    StandardPBEByteEncryptor standardPBEByteEncryptor = 
           new StandardPBEByteEncryptor();
    standardPBEByteEncryptor.setPassword("jasypt");
    standardPBEByteEncryptor.setAlgorithm("PBEWithMD5AndDES");
       
    ByteEncryptor byteEncryptor = 
           (ByteEncryptor) ctx.getBean(BYTE_ENCRYPTOR_BEAN_NAME);
       assertTrue(ArrayUtils.isEquals(new byte[] {5, 7, 13}, 
               standardPBEByteEncryptor.decrypt(byteEncryptor.encrypt(new byte[] {5, 7, 13}))));
       
       
       
       
    StandardPBEStringEncryptor standardPBEStringEncryptor = 
           new StandardPBEStringEncryptor();
       standardPBEStringEncryptor.setPassword("jasypt");
       standardPBEStringEncryptor.setAlgorithm("PBEWithMD5AndDES");
       standardPBEStringEncryptor.setStringOutputType("hexadecimal");
       
    StringEncryptor stringEncryptor = 
           (StringEncryptor) ctx.getBean(STRING_ENCRYPTOR_BEAN_NAME);
       assertEquals("jasypt", 
               standardPBEStringEncryptor.decrypt(stringEncryptor.encrypt("jasypt")));
       
    
       
       StandardStringDigester standardStringDigester = 
           new StandardStringDigester();
       standardStringDigester.setAlgorithm("SHA-1");
       standardStringDigester.setStringOutputType("hexa");
       
       StringDigester stringDigester = 
           (StringDigester) ctx.getBean(STRING_DIGESTER_BEAN_NAME);
       assertTrue(stringDigester.matches("jasypt", 
               standardStringDigester.digest("jasypt")));
       assertTrue(standardStringDigester.matches("jasypt", 
               stringDigester.digest("jasypt")));
       
}
 
Example 7
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 8
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 9
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 10
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;
    }
    
}