org.jasypt.encryption.pbe.config.EnvironmentPBEConfig Java Examples

The following examples show how to use org.jasypt.encryption.pbe.config.EnvironmentPBEConfig. 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: EncryptorConfigBeanDefinitionParser.java    From jasypt with Apache License 2.0 5 votes vote down vote up
private static Class<?> computeConfigClass(final Element element) {
    
    boolean isSimpleConfig = false;
    boolean isStringConfig = false;
    boolean isEnvironmentConfig = false;
    boolean isStringEnvironmentConfig = false;

    final NamedNodeMap attributesMap = element.getAttributes();
    final int attributesLen = attributesMap.getLength();
    for (int i = 0; i < attributesLen; i++) {
        final Node attribute = attributesMap.item(i);
        final String attributeName = attribute.getNodeName();
        if (!isSimpleConfig && PARAMS_SIMPLE.contains(attributeName)) {
            isSimpleConfig = true;
        }
        if (!isStringConfig && PARAMS_STRING.contains(attributeName)) {
            isStringConfig = true;
        }
        if (!isEnvironmentConfig && PARAMS_ENVIRONMENT.contains(attributeName)) {
            isEnvironmentConfig = true;
        }
        if (!isStringEnvironmentConfig && PARAMS_STRING_ENVIRONMENT.contains(attributeName)) {
            isStringEnvironmentConfig = true;
        }
    }
    
    if (isStringEnvironmentConfig || (isEnvironmentConfig && isStringConfig)) {
        return EnvironmentStringPBEConfig.class;
    }
    if (isEnvironmentConfig) {
        return EnvironmentPBEConfig.class;
    }
    if (isStringConfig) {
        return SimpleStringPBEConfig.class;
    }
    return SimplePBEConfig.class;
    
}
 
Example #2
Source File: EncryptorConfigBeanDefinitionParser.java    From jasypt with Apache License 2.0 5 votes vote down vote up
private static Class<?> computeConfigClass(final Element element) {
    
    boolean isSimpleConfig = false;
    boolean isStringConfig = false;
    boolean isEnvironmentConfig = false;
    boolean isStringEnvironmentConfig = false;

    final NamedNodeMap attributesMap = element.getAttributes();
    final int attributesLen = attributesMap.getLength();
    for (int i = 0; i < attributesLen; i++) {
        final Node attribute = attributesMap.item(i);
        final String attributeName = attribute.getNodeName();
        if (!isSimpleConfig && PARAMS_SIMPLE.contains(attributeName)) {
            isSimpleConfig = true;
        }
        if (!isStringConfig && PARAMS_STRING.contains(attributeName)) {
            isStringConfig = true;
        }
        if (!isEnvironmentConfig && PARAMS_ENVIRONMENT.contains(attributeName)) {
            isEnvironmentConfig = true;
        }
        if (!isStringEnvironmentConfig && PARAMS_STRING_ENVIRONMENT.contains(attributeName)) {
            isStringEnvironmentConfig = true;
        }
    }
    
    if (isStringEnvironmentConfig || (isEnvironmentConfig && isStringConfig)) {
        return EnvironmentStringPBEConfig.class;
    }
    if (isEnvironmentConfig) {
        return EnvironmentPBEConfig.class;
    }
    if (isStringConfig) {
        return SimpleStringPBEConfig.class;
    }
    return SimplePBEConfig.class;
    
}
 
Example #3
Source File: EncryptorConfigBeanDefinitionParser.java    From jasypt with Apache License 2.0 5 votes vote down vote up
private static Class<?> computeConfigClass(final Element element) {
    
    boolean isSimpleConfig = false;
    boolean isStringConfig = false;
    boolean isEnvironmentConfig = false;
    boolean isStringEnvironmentConfig = false;

    final NamedNodeMap attributesMap = element.getAttributes();
    final int attributesLen = attributesMap.getLength();
    for (int i = 0; i < attributesLen; i++) {
        final Node attribute = attributesMap.item(i);
        final String attributeName = attribute.getNodeName();
        if (!isSimpleConfig && PARAMS_SIMPLE.contains(attributeName)) {
            isSimpleConfig = true;
        }
        if (!isStringConfig && PARAMS_STRING.contains(attributeName)) {
            isStringConfig = true;
        }
        if (!isEnvironmentConfig && PARAMS_ENVIRONMENT.contains(attributeName)) {
            isEnvironmentConfig = true;
        }
        if (!isStringEnvironmentConfig && PARAMS_STRING_ENVIRONMENT.contains(attributeName)) {
            isStringEnvironmentConfig = true;
        }
    }
    
    if (isStringEnvironmentConfig || (isEnvironmentConfig && isStringConfig)) {
        return EnvironmentStringPBEConfig.class;
    }
    if (isEnvironmentConfig) {
        return EnvironmentPBEConfig.class;
    }
    if (isStringConfig) {
        return SimpleStringPBEConfig.class;
    }
    return SimplePBEConfig.class;
    
}
 
Example #4
Source File: BaseWebApplicationTests.java    From hdw-dubbo with Apache License 2.0 5 votes vote down vote up
/**
 * 加密
 * @throws Exception
 */
@Test
public void testEncrypt() throws Exception {
    StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
    EnvironmentPBEConfig config = new EnvironmentPBEConfig();
    //TODO: 加密的算法,这个算法是默认的
    config.setAlgorithm("PBEWithMD5AndDES");
    //TODO: 加密的密钥
    config.setPassword(CommonConstant.JWT_DEFAULT_ISSUER);
    standardPBEStringEncryptor.setConfig(config);
    //[email protected]
    String plainText = "abc123";
    String encryptedText = standardPBEStringEncryptor.encrypt(plainText);
    System.out.println(encryptedText);
}
 
Example #5
Source File: BaseWebApplicationTests.java    From hdw-dubbo with Apache License 2.0 5 votes vote down vote up
/**
 * 解密
 * @throws Exception
 */
@Test
public void testDecrypt() throws Exception {
    StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
    EnvironmentPBEConfig config = new EnvironmentPBEConfig();
    //TODO: 加密的算法,这个算法是默认的
    config.setAlgorithm("PBEWithMD5AndDES");
    //TODO: 加密的密钥
    config.setPassword(CommonConstant.JWT_DEFAULT_ISSUER);
    standardPBEStringEncryptor.setConfig(config);
    String encryptedText = "xRL1CVgzfFKBnPxCr+xjkg==";
    String plainText = standardPBEStringEncryptor.decrypt(encryptedText);
    System.out.println(plainText);
}
 
Example #6
Source File: PasswordUtilTest.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public  void test(){
    StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
    EnvironmentPBEConfig config = new EnvironmentPBEConfig();
    config.setAlgorithm("PBEWithMD5AndDES");          // 加密的算法,这个算法是默认的
    config.setPassword("ueboot");                        // 加密的密钥
    standardPBEStringEncryptor.setConfig(config);
    String plainText = "";
    String encryptedText = standardPBEStringEncryptor.encrypt(plainText);
    System.out.println(encryptedText);
}