public class AuthServiceBuilder extends Object
AuthService.| Modifier and Type | Method and Description |
|---|---|
AuthServiceBuilder |
add(Authorizer<HttpRequest> authorizer)
Adds an
Authorizer. |
AuthServiceBuilder |
add(Iterable<? extends Authorizer<HttpRequest>> authorizers)
Adds multiple
Authorizers. |
AuthServiceBuilder |
addBasicAuth(Authorizer<? super BasicToken> authorizer)
Adds an HTTP basic
Authorizer. |
AuthServiceBuilder |
addBasicAuth(Authorizer<? super BasicToken> authorizer,
CharSequence header)
Adds an HTTP basic
Authorizer for the given header. |
AuthServiceBuilder |
addOAuth1a(Authorizer<? super OAuth1aToken> authorizer)
Adds an OAuth1a
Authorizer. |
AuthServiceBuilder |
addOAuth1a(Authorizer<? super OAuth1aToken> authorizer,
CharSequence header)
Adds an OAuth1a
Authorizer for the given header. |
AuthServiceBuilder |
addOAuth2(Authorizer<? super OAuth2Token> authorizer)
Adds an OAuth2
Authorizer. |
AuthServiceBuilder |
addOAuth2(Authorizer<? super OAuth2Token> authorizer,
CharSequence header)
Adds an OAuth2
Authorizer for the given header. |
<T> AuthServiceBuilder |
addTokenAuthorizer(Function<? super RequestHeaders,T> tokenExtractor,
Authorizer<? super T> authorizer)
Adds a token-based
Authorizer. |
AuthService |
build(HttpService delegate)
Returns a newly-created
AuthService based on the Authorizers added to this builder. |
Function<? super HttpService,AuthService> |
newDecorator()
Returns a newly-created decorator that decorates an
HttpService with a new
AuthService based on the Authorizers added to this builder. |
AuthServiceBuilder |
onFailure(AuthFailureHandler<HttpRequest,HttpResponse> failureHandler)
Sets the
AuthFailureHandler which handles the requests with failed authorization. |
AuthServiceBuilder |
onSuccess(AuthSuccessHandler<HttpRequest,HttpResponse> successHandler)
Sets the
AuthSuccessHandler which handles successfully authorized requests. |
public AuthServiceBuilder add(Authorizer<HttpRequest> authorizer)
Authorizer.public AuthServiceBuilder add(Iterable<? extends Authorizer<HttpRequest>> authorizers)
Authorizers.public AuthServiceBuilder addBasicAuth(Authorizer<? super BasicToken> authorizer)
Authorizer.public AuthServiceBuilder addBasicAuth(Authorizer<? super BasicToken> authorizer, CharSequence header)
Authorizer for the given header.public AuthServiceBuilder addOAuth1a(Authorizer<? super OAuth1aToken> authorizer)
Authorizer.public AuthServiceBuilder addOAuth1a(Authorizer<? super OAuth1aToken> authorizer, CharSequence header)
Authorizer for the given header.public AuthServiceBuilder addOAuth2(Authorizer<? super OAuth2Token> authorizer)
Authorizer.public AuthServiceBuilder addOAuth2(Authorizer<? super OAuth2Token> authorizer, CharSequence header)
Authorizer for the given header.public <T> AuthServiceBuilder addTokenAuthorizer(Function<? super RequestHeaders,T> tokenExtractor, Authorizer<? super T> authorizer)
Authorizer.public AuthServiceBuilder onSuccess(AuthSuccessHandler<HttpRequest,HttpResponse> successHandler)
AuthSuccessHandler which handles successfully authorized requests.
By default, the request will be delegated to the next HttpService.public AuthServiceBuilder onFailure(AuthFailureHandler<HttpRequest,HttpResponse> failureHandler)
AuthFailureHandler which handles the requests with failed authorization.
By default, an exception thrown during authorization is logged at WARN level (if any) and a
401 Unauthorized response will be sent.public AuthService build(HttpService delegate)
AuthService based on the Authorizers added to this builder.public Function<? super HttpService,AuthService> newDecorator()
HttpService with a new
AuthService based on the Authorizers added to this builder.Copyright © 2020 LeanCloud. All rights reserved.