azure-docs-sdk-java/docs-ref-autogen/com.azure.core.http.policy....

92 строки
10 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.core.http.policy.KeyCredentialPolicy"
fullName: "com.azure.core.http.policy.KeyCredentialPolicy"
name: "KeyCredentialPolicy"
nameWithType: "KeyCredentialPolicy"
summary: "The `KeyCredentialPolicy` class is an implementation of the <xref uid=\"com.azure.core.http.policy.HttpPipelinePolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpPipelinePolicy\"></xref> interface."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public class **KeyCredentialPolicy**</br> implements <xref href=\"com.azure.core.http.policy.HttpPipelinePolicy?alt=com.azure.core.http.policy.HttpPipelinePolicy&text=HttpPipelinePolicy\" data-throw-if-not-resolved=\"False\" />"
constructors:
- uid: "com.azure.core.http.policy.KeyCredentialPolicy.KeyCredentialPolicy(java.lang.String,com.azure.core.credential.KeyCredential)"
fullName: "com.azure.core.http.policy.KeyCredentialPolicy.KeyCredentialPolicy(String name, KeyCredential credential)"
name: "KeyCredentialPolicy(String name, KeyCredential credential)"
nameWithType: "KeyCredentialPolicy.KeyCredentialPolicy(String name, KeyCredential credential)"
summary: "Creates a policy that uses the passed <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> to set the specified header name."
parameters:
- description: "The name of the key header that will be set to <xref uid=\"com.azure.core.credential.KeyCredential.getKey()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential#getKey()\"></xref>."
name: "name"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> containing the authorization key to use."
name: "credential"
type: "<xref href=\"com.azure.core.credential.KeyCredential?alt=com.azure.core.credential.KeyCredential&text=KeyCredential\" data-throw-if-not-resolved=\"False\" />"
syntax: "public KeyCredentialPolicy(String name, KeyCredential credential)"
desc: "Creates a policy that uses the passed <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> to set the specified header name."
- uid: "com.azure.core.http.policy.KeyCredentialPolicy.KeyCredentialPolicy(java.lang.String,com.azure.core.credential.KeyCredential,java.lang.String)"
fullName: "com.azure.core.http.policy.KeyCredentialPolicy.KeyCredentialPolicy(String name, KeyCredential credential, String prefix)"
name: "KeyCredentialPolicy(String name, KeyCredential credential, String prefix)"
nameWithType: "KeyCredentialPolicy.KeyCredentialPolicy(String name, KeyCredential credential, String prefix)"
summary: "Creates a policy that uses the passed <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> to set the specified header name."
parameters:
- description: "The name of the key header that will be set to <xref uid=\"com.azure.core.credential.KeyCredential.getKey()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential#getKey()\"></xref>."
name: "name"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> containing the authorization key to use."
name: "credential"
type: "<xref href=\"com.azure.core.credential.KeyCredential?alt=com.azure.core.credential.KeyCredential&text=KeyCredential\" data-throw-if-not-resolved=\"False\" />"
- description: "The prefix to apply before the credential, for example \"SharedAccessKey credential\"."
name: "prefix"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public KeyCredentialPolicy(String name, KeyCredential credential, String prefix)"
desc: "Creates a policy that uses the passed <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> to set the specified header name.\n\nThe `prefix` will be applied before the <xref uid=\"com.azure.core.credential.KeyCredential.getKey()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential#getKey()\"></xref> when setting the header. A space will be inserted between `prefix` and credential."
methods:
- uid: "com.azure.core.http.policy.KeyCredentialPolicy.process(com.azure.core.http.HttpPipelineCallContext,com.azure.core.http.HttpPipelineNextPolicy)"
fullName: "com.azure.core.http.policy.KeyCredentialPolicy.process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
name: "process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
nameWithType: "KeyCredentialPolicy.process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
summary: "Processes provided request context and invokes the next policy."
parameters:
- name: "context"
type: "<xref href=\"com.azure.core.http.HttpPipelineCallContext?alt=com.azure.core.http.HttpPipelineCallContext&text=HttpPipelineCallContext\" data-throw-if-not-resolved=\"False\" />"
- name: "next"
type: "<xref href=\"com.azure.core.http.HttpPipelineNextPolicy?alt=com.azure.core.http.HttpPipelineNextPolicy&text=HttpPipelineNextPolicy\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
desc: "Processes provided request context and invokes the next policy."
returns:
type: "<a href=\"https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html\">Mono</a>&lt;<xref href=\"com.azure.core.http.HttpResponse?alt=com.azure.core.http.HttpResponse&text=HttpResponse\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.core.http.policy.KeyCredentialPolicy.processSync(com.azure.core.http.HttpPipelineCallContext,com.azure.core.http.HttpPipelineNextSyncPolicy)"
fullName: "com.azure.core.http.policy.KeyCredentialPolicy.processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
name: "processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
nameWithType: "KeyCredentialPolicy.processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
summary: "Processes provided request context and invokes the next policy synchronously."
parameters:
- name: "context"
type: "<xref href=\"com.azure.core.http.HttpPipelineCallContext?alt=com.azure.core.http.HttpPipelineCallContext&text=HttpPipelineCallContext\" data-throw-if-not-resolved=\"False\" />"
- name: "next"
type: "<xref href=\"com.azure.core.http.HttpPipelineNextSyncPolicy?alt=com.azure.core.http.HttpPipelineNextSyncPolicy&text=HttpPipelineNextSyncPolicy\" data-throw-if-not-resolved=\"False\" />"
syntax: "public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
desc: "Processes provided request context and invokes the next policy synchronously."
returns:
type: "<xref href=\"com.azure.core.http.HttpResponse?alt=com.azure.core.http.HttpResponse&text=HttpResponse\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "The `KeyCredentialPolicy` class is an implementation of the <xref uid=\"com.azure.core.http.policy.HttpPipelinePolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpPipelinePolicy\"></xref> interface. This policy uses a <xref uid=\"com.azure.core.credential.KeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"KeyCredential\"></xref> to set the authorization key for a request in the form of a header.\n\nThis class is useful when you need to authorize requests with a key. It ensures that the requests are sent over HTTPS to prevent the key from being leaked. The key is set in the header of the HTTP request.\n\n**Code sample:**\n\nIn this example, a `KeyCredentialPolicy` is created with a key and a header name. The policy can then be added to the pipeline. The request sent by the pipeline will then include the specified header with the key as its value.\n\n```java\nKeyCredential credential = new KeyCredential(\"my_key\");\n KeyCredentialPolicy policy = new KeyCredentialPolicy(\"my_header\", credential);\n```"
implements:
- "<xref href=\"com.azure.core.http.policy.HttpPipelinePolicy?alt=com.azure.core.http.policy.HttpPipelinePolicy&text=HttpPipelinePolicy\" data-throw-if-not-resolved=\"False\" />"
metadata: {}
package: "com.azure.core.http.policy"
artifact: com.azure:azure-core:1.54.0