1 /*
2  * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights
3  * Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License").
6  * You may not use this file except in compliance with the License.
7  * A copy of the License is located at
8  *
9  *  http://aws.amazon.com/apache2.0
10  *
11  * or in the "license" file accompanying this file. This file is distributed
12  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */

16 package com.amazonaws.services.sqs.internal.auth;
17
18 import com.amazonaws.AmazonWebServiceClient;
19 import com.amazonaws.auth.Signer;
20 import com.amazonaws.internal.auth.SignerProviderContext;
21 import com.amazonaws.internal.auth.SignerProvider;
22
23 /**
24  * SQS alters the request endpoint as part of a request handler which inspects
25  * the request's parameters.  As a result we must always look up the signer
26  * by the resulting request URI.  This signer provider always does that lookup
27  * instead of defaulting to a cached signer.
28  */

29 public class SQSSignerProvider extends SignerProvider {
30
31     private final AmazonWebServiceClient awsClient;
32
33     public SQSSignerProvider(AmazonWebServiceClient awsClient,
34                              Signer signer) {
35         this.awsClient = awsClient;
36     }
37
38     @Override
39     public Signer getSigner(SignerProviderContext context) {
40         return awsClient.getSignerByURI(context.getUri());
41     }
42
43 }