public class BearerAuthentication
extends org.apache.http.impl.auth.RFC2617Scheme
AuthScheme that conforms to OAuth 2.0 specification (which handles
"bearer" tokens). This object contains the challenge of
www-authenticate HTTP headers.BearerCredentialsSupport| Modifier and Type | Field and Description |
|---|---|
static String |
NAME
The scheme name, which is "bearer".
|
| Constructor and Description |
|---|
BearerAuthentication(org.apache.http.protocol.HttpContext context)
Creates an instance specifying the
HttpContext. |
| Modifier and Type | Method and Description |
|---|---|
org.apache.http.Header |
authenticate(org.apache.http.auth.Credentials credentials,
org.apache.http.HttpRequest request)
Implements authentication by delegating to the credentials object.
|
Map<String,String> |
getParameters()
Returns authentication parameters, which typically are the contents of
the
www-authenticate HTTP header. |
String |
getSchemeName()
Always returns "bearer".
|
boolean |
isComplete()
Always returns
false to avoid caching the token. |
boolean |
isConnectionBased()
Always returns
false because the same token can be used in
multiple connections. |
getCredentialsCharset, getParameter, getRealm, parseChallengepublic static final String NAME
public BearerAuthentication(org.apache.http.protocol.HttpContext context)
HttpContext.public boolean isConnectionBased()
false because the same token can be used in
multiple connections.public boolean isComplete()
false to avoid caching the token.public Map<String,String> getParameters()
www-authenticate HTTP header. Use this to determine the
challenge to be answered.
The returned map is shared and not thread-safe.
getParameters in class org.apache.http.impl.auth.RFC2617Schemepublic org.apache.http.Header authenticate(org.apache.http.auth.Credentials credentials,
org.apache.http.HttpRequest request)
throws org.apache.http.auth.AuthenticationException
This method checks if the credentials parameter implements
BearerCredentialsSupport. If not, it silently returns
null, which tells the HTTP stack that no authentication has
been performed (typically the user will see a 401 error).
BearerCredentialsSupport.authenticate(ServiceRequestContext, BearerAuthentication)
and returns whatever that call returns.org.apache.http.auth.AuthenticationException/**
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/