Class AzureKeyCredentialPolicy
- java.lang.Object
-
- com.azure.android.core.http.policy.AzureKeyCredentialPolicy
-
- All Implemented Interfaces:
HttpPipelinePolicy
public class AzureKeyCredentialPolicy extends java.lang.Object implements HttpPipelinePolicy
Pipeline policy that uses anAzureKeyCredentialto set the authorization key for a request.Requests sent with this pipeline policy are required to use
HTTPS. If the request isn't usingHTTPSan exception will be thrown to prevent leaking the key.
-
-
Constructor Summary
Constructors Constructor Description AzureKeyCredentialPolicy(java.lang.String name, com.azure.android.core.credential.AzureKeyCredential credential)Creates a policy that uses the providedAzureKeyCredentialto set the specified header name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocess(HttpPipelinePolicyChain chain)Applies the policy to aHttpRequestand the correspondingHttpResponse.
-
-
-
Constructor Detail
-
AzureKeyCredentialPolicy
public AzureKeyCredentialPolicy(java.lang.String name, com.azure.android.core.credential.AzureKeyCredential credential)Creates a policy that uses the providedAzureKeyCredentialto set the specified header name.- Parameters:
name- The name of the key header that will be set toAzureKeyCredential.getKey().credential- TheAzureKeyCredentialcontaining the authorization key to use.- Throws:
java.lang.NullPointerException- Ifnameorcredentialisnull.java.lang.IllegalArgumentException- Ifnameis empty.
-
-
Method Detail
-
process
public void process(HttpPipelinePolicyChain chain)
Description copied from interface:HttpPipelinePolicyApplies the policy to aHttpRequestand the correspondingHttpResponse.Policy implementations are expected to use
HttpPipelinePolicyChain.getRequest()to access and intercept the request, then proceed to next policy by callingHttpPipelinePolicyChain.processNextPolicy(HttpRequest)orHttpPipelinePolicyChain.processNextPolicy(HttpRequest, NextPolicyCallback). The policy can intercept the resulting response notified toNextPolicyCallback.onSuccess(HttpResponse, PolicyCompleter)or error notified toNextPolicyCallback.onError(Throwable, PolicyCompleter)and must signal the completion of the policy by callingPolicyCompleter.completed(HttpResponse)orPolicyCompleter.completedError(Throwable).- Specified by:
processin interfaceHttpPipelinePolicy- Parameters:
chain- The chain for the policy to access the request and response.
-
-