Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-12851

Camel: Master component URI with RAW() let parameter value to be partially encoded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • fuse-7.6-CR1
    • fuse-7.4-GA
    • Camel
    • None
    • % %
    • Hide

      The workaround is to use a PropertiesFunction with Base64.

      public class CamelRouteWorkaround extends RouteBuilder {
      
      	@Override
      	public void configure() throws Exception {
      
      		PropertiesComponent pc = (PropertiesComponent) getContext().getComponent("properties");
      		pc.addFunction(new PropertiesFunction() {
      
      			@Override
      			public String getName() {
      				return "base64";
      			}
      
      			@Override
      			public String apply(String encodedPassword) {
      				return new String(Base64.getDecoder().decode(encodedPassword));
      			}
      		});
      
      		String username = "agagliar";
      		String password = "*d=c7q}10Iw;Pit*";
      		String encrypt = Base64.getEncoder().encodeToString(password.getBytes());
      
      		from("master:mymaster:imap://fakeimap?"
      				+ "username=" + username
      				+ "&password={{base64:" + encrypt
      				+ "}}&delete=false"
      				+ "&unseen=true"
      				+ "&peek=true"
      				+ "&consumer.delay=2000")
      						.routeId("mail.username=" + username)
      						.log("Polling Emails")
      						.log("Uploading Attachments")
      						.log("Creating case on sfc")
      						.log("Case created");
      
      	}
      
      }
      
      
      Show
      The workaround is to use a PropertiesFunction with Base64. public class CamelRouteWorkaround extends RouteBuilder { @Override public void configure() throws Exception { PropertiesComponent pc = (PropertiesComponent) getContext().getComponent( "properties" ); pc.addFunction( new PropertiesFunction() { @Override public String getName() { return "base64" ; } @Override public String apply( String encodedPassword) { return new String (Base64.getDecoder().decode(encodedPassword)); } }); String username = "agagliar" ; String password = "*d=c7q}10Iw;Pit*" ; String encrypt = Base64.getEncoder().encodeToString(password.getBytes()); from( "master:mymaster:imap: //fakeimap?" + "username=" + username + "&password={{base64:" + encrypt + "}}&delete= false " + "&unseen= true " + "&peek= true " + "&consumer.delay=2000" ) .routeId( "mail.username=" + username) .log( "Polling Emails" ) .log( "Uploading Attachments" ) .log( "Creating case on sfc" ) .log( "Case created" ); } }
    • Hide

      MasterComponentURIEncodingTest.zip is the reproducer, it contains also a route with a tested workaround.

      Show
      MasterComponentURIEncodingTest.zip is the reproducer, it contains also a route with a tested workaround.

      • The master component with and endpoint URI without a path works as expected
      master:mymaster2:test1?password=RAW(*d=c7q}10Iw;Pit*)
       as expected the body contains *d=c7q}10Iw;Pit*
      
      • The master component with and endpoint URI with a path fail to use the RAW syntax and let the curly bracket to be encoded
      master:mymaster1:test1://pippo?password=RAW(*d=c7q}10Iw;Pit*)
       fail, body contains *d=c7q[%7D]10Iw;Pit*
      

      *test1 is a custom consumer EP that put the password parameter value as body exchange.

              rhn-support-tasato Tadayoshi Sato
              rhn-support-agagliar Antonio Gagliardi
              Vratislav Hais Vratislav Hais (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: