Java 类org.apache.camel.component.jasypt.JasyptPropertiesParser 实例源码

项目:camelinaction2    文件:SecuringConfigTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

 // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master password
    jasypt.setPassword("supersecret");   

    // we can avoid keeping the master password in plaintext in the application
    // by referencing a environment variable
    // export CAMEL_ENCRYPTION_PASSWORD=supersecret
    // jasypt.setPassword("sysenv:CAMEL_ENCRYPTION_PASSWORD");

    // setup the properties component to use the production file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-test.properties");

    // and use the jasypt properties parser so we can decrypt values
    prop.setPropertiesParser(jasypt);

    return context;
}
项目:camel-cookbook-examples    文件:EncryptedPropertiesPasswordInSystemPropertyTest.java   
@Override
public CamelContext createCamelContext() {
    // normally this would be set along the lines of -DjasyptMasterPassword=encryptionPassword
    // in a place appropriate to the runtime
    System.setProperty("jasyptMasterPassword", "encryptionPassword");

    JasyptPropertiesParser propParser = new JasyptPropertiesParser();
    propParser.setPassword("sys:jasyptMasterPassword");

    PropertiesComponent propComponent = new PropertiesComponent();
    propComponent.setLocation("classpath:placeholder.properties");
    propComponent.setPropertiesParser(propParser);

    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addComponent("properties", propComponent);
    return camelContext;
}
项目:camel-cookbook-examples    文件:EncryptedPropertiesTest.java   
@Override
public CamelContext createCamelContext() {
    JasyptPropertiesParser propParser = new JasyptPropertiesParser();
    propParser.setPassword("encryptionPassword");

    PropertiesComponent propComponent = new PropertiesComponent();
    propComponent.setLocation("classpath:placeholder.properties");
    propComponent.setPropertiesParser(propParser);

    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addComponent("properties", propComponent);
    return camelContext;
}
项目:wildfly-camel    文件:JasyptIntegrationTest.java   
@Test
public void testPasswordDecryption() throws Exception {

    // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master password
    jasypt.setPassword("secret");

    // create the properties component
    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation("classpath:password.properties");
    // and use the jasypt properties parser so we can decrypt values
    pc.setPropertiesParser(jasypt);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addComponent("properties", pc);
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").transform().simple("Hi ${body} the decrypted password is: ${properties:cool.password}");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBody("direct:start", "John", String.class);
        Assert.assertEquals("Hi John the decrypted password is: tiger", result.trim());
    } finally {
        camelctx.stop();
    }
}