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 anAzureKeyCredential
to set the authorization key for a request.Requests sent with this pipeline policy are required to use
HTTPS
. If the request isn't usingHTTPS
an 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 providedAzureKeyCredential
to set the specified header name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(HttpPipelinePolicyChain chain)
Applies the policy to aHttpRequest
and the correspondingHttpResponse
.
-
-
-
Constructor Detail
-
AzureKeyCredentialPolicy
public AzureKeyCredentialPolicy(java.lang.String name, com.azure.android.core.credential.AzureKeyCredential credential)
Creates a policy that uses the providedAzureKeyCredential
to set the specified header name.- Parameters:
name
- The name of the key header that will be set toAzureKeyCredential.getKey()
.credential
- TheAzureKeyCredential
containing the authorization key to use.- Throws:
java.lang.NullPointerException
- Ifname
orcredential
isnull
.java.lang.IllegalArgumentException
- Ifname
is empty.
-
-
Method Detail
-
process
public void process(HttpPipelinePolicyChain chain)
Description copied from interface:HttpPipelinePolicy
Applies the policy to aHttpRequest
and 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:
process
in interfaceHttpPipelinePolicy
- Parameters:
chain
- The chain for the policy to access the request and response.
-
-