camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brendan Long <bren...@realgo.com>
Subject Re: Problem with AWS-Component => accessKey + secretKey Parameters not working
Date Mon, 29 Aug 2011 15:59:36 GMT
You'll need to URL encode any +'s in your secret key (otherwise, they'll
be treated as spaces). + = %2B, so if your secretkey was
"my+secret\key", your Camel URL should have "secretKey=my%2Bsecret\key".

"Within the query string, the plus sign is reserved as shorthand
notation for a space. Therefore, real plus signs must be encoded. This
method was used to make query URIs easier to pass in systems which did
not allow spaces."

Source: WC3 URI Recommendations
<http://www.w3.org/Addressing/URL/4_URI_Recommentations.html#z5>

On 2011-08-29 3:28 AM, megachucky wrote:
> Hello,
>
> I am playing around with the Camel AWS component. The problems exist for SQS
> and S3, same problem! Everything works fine if I use the AmazonSQSClient as
> it is used in the source code of the aws component tests:
>
>    @Test
>     public void testFileToAmazonSQSToFileRoute() throws Exception {
>         System.out.println("testing is starting...");
>         
>         template.sendBodyAndHeader("file://files/inbox", "Content for Amazon
> SQS Cloud Service", Exchange.FILE_NAME, "SQS-file.txt");
>
>         Thread.sleep(1000);
>
>         InputStream is =
> FileToAmazonSQSToFileTest.class.getResourceAsStream("AwsCredentials.properties");
>         AmazonSQS sqs = new AmazonSQSClient(new PropertiesCredentials(is));
>
>         ListQueuesResult listQueues = sqs.listQueues();
>     
>         for (String s : listQueues.getQueueUrls()) {
>           System.out.println(s);
>         }
>         
>         // TODO assertions !!!
>         
>         System.out.println("testing finished...");
>         
>     }
>     
>     @Override
>     protected JndiRegistry createRegistry() throws Exception {
>         JndiRegistry registry = super.createRegistry();
>         
>         AWSCredentials awsCredentials = new
> BasicAWSCredentials("AKIAJJ7GO5PHMTBKSN4A",
> "VM7NQ2MImmMBBaH+atIAJEpAwjSTF5sQYP/jUMU4");
>         ClientConfiguration clientConfiguration = new ClientConfiguration();
>         AmazonSQSClient client = new AmazonSQSClient(awsCredentials,
> clientConfiguration);
>         
>         registry.bind("amazonSQSClient", client);
>         
>         return registry;
>     }
>
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new SQSRoute();
>     }
>
> There are no assertions yet, but there is no excpetion, and the println
> shows all existing queues which it got from AWS.
>
> But I do not need a (complex) Amazon configuration, I just want to use the
> two parameters "accessKey" and "secretKey" (which should also be possible as
> described at http://camel.apache.org/aws-sqs.html). 
> Here you can see my route, trying both alternatives:
>
> public class SQSRoute extends RouteBuilder {
>
> 	@Override
> 	public void configure() throws Exception {
> 		// FROM INBOX TO AWS-SQS TO OUTBOX
>         from("file:inbox")
>         	.tracing().routeId("inbox-to-sqs")
>         
>         // Not working:
>        
> //.to("aws-sqs://camel-integration-queue-mwea-kw?accessKey=AKIAJJ7GO5PHMTBKSN4A&secretKey=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")
>         
>         // Working:
>        
> .to("aws-sqs://camel-integration-queue-mwea-kw?amazonSQSClient=#amazonSQSClient");
>    ;
>         
>         
>         // FROM AWS-SQS TO OUTBOX
>        
> from("aws-sqs://camel-integration-queue-mwea-kw?amazonSQSClient=#amazonSQSClient")
>         	.tracing().routeId("sqs-to-outbox")
>         .to("file:outbox");
> 		
> 	}
>
> }
>
>
> AwsCredentials.properties file:
>
> accessKey=AKIAJJ7GO5PHMTBKSN4A
> secretKey=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
>
>
> Using the AmazonClient is working. If I use the two parameters (which
> contain exactly the same values as the AwsCredentials.properties, the
> following exception occurs:
>
> "The request signature we calculated does not match the signature you
> provided. Check your AWS Secret Access Key and signing method. Consult the
> service documentation for details."
>
> Full strack trace:
>
> org.apache.camel.FailedToCreateRouteException: Failed to create route
> inbox-to-sqs at: >>>
> To[aws-sqs://camel-integration-queue-mwea-kw?accessKey=AKIAJJ7GO5PHMTBKSN4A&secretKey=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]
> <<< in route: Route[[From[file:inbox]] ->
> [To[aws-sqs://camel-integration-... because of Failed to resolve endpoint:
> aws-sqs://camel-integration-queue-mwea-kw?accessKey=AKIAJJ7GO5PHMTBKSN4A&secretKey=VM7NQ2MImmMBBaH+atIAJEpAwjSTF5sQYP%2FjUMU4
> due to: The request signature we calculated does not match the signature you
> provided. Check your AWS Secret Access Key and signing method. Consult the
> service documentation for details.
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:794)
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
> 	at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:705)
> 	at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1659)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1448)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1346)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
> 	at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1324)
> 	at
> org.apache.camel.test.junit4.CamelTestSupport.startCamelContext(CamelTestSupport.java:344)
> 	at
> org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:228)
> 	at
> org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:167)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> 	at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> 	at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48)
> 	at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
> 	at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
> 	at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint:
> aws-sqs://camel-integration-queue-mwea-kw?accessKey=AKIAJJ7GO5PHMTBKSN4A&secretKey=VM7NQ2MImmMBBaH+atIAJEpAwjSTF5sQYP%2FjUMU4
> due to: The request signature we calculated does not match the signature you
> provided. Check your AWS Secret Access Key and signing method. Consult the
> service documentation for details.
> 	at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:450)
> 	at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:48)
> 	at
> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:180)
> 	at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
> 	at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
> 	at
> org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
> 	at
> org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
> 	at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:437)
> 	at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:183)
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:791)
> 	... 36 more
> Caused by: Status Code: 403, AWS Request ID:
> a7c01a60-3533-404e-bb91-c1886d2ec3cd, AWS Error Code: SignatureDoesNotMatch,
> AWS Error Message: The request signature we calculated does not match the
> signature you provided. Check your AWS Secret Access Key and signing method.
> Consult the service documentation for details.
> 	at com.amazonaws.http.HttpClient.handleErrorResponse(HttpClient.java:519)
> 	at com.amazonaws.http.HttpClient.execute(HttpClient.java:215)
> 	at
> com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:554)
> 	at
> com.amazonaws.services.sqs.AmazonSQSClient.createQueue(AmazonSQSClient.java:287)
> 	at
> org.apache.camel.component.aws.sqs.SqsEndpoint.doStart(SqsEndpoint.java:86)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
> 	at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
> 	at
> org.apache.camel.impl.DefaultCamelContext.startServices(DefaultCamelContext.java:1629)
> 	at
> org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:911)
> 	at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:446)
> 	... 45 more
>
>
>
>
>
> I looked at the source code of this component and saw that the tests are
> using a mock. Thus, the real connection to AWS is not tested. It is a AWS
> exception, but I wonder if there is a bug in the implementation of the camel
> component? Or otherwise: What am I doing wrong here?
>
> Best regards,
> Kai Wähner
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-AWS-Component-accessKey-secretKey-Parameters-not-working-tp4745604p4745604.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message