Class BasicAuthHttpServiceFilter.Builder<UserInfo>
- Type Parameters:
UserInfo
- a type for authenticated user info object
- Enclosing class:
- BasicAuthHttpServiceFilter<UserInfo>
StreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder
(BasicAuthHttpServiceFilter.CredentialsVerifier<UserInfo> credentialsVerifier, String realm) Creates a new builder for anStreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance for proxy service.Creates a new instance for non-proxy service.setCharsetUtf8
(boolean utf8) Sets an advice for a user agent to useUTF-8
charset when it generatesuser-id:password
pair.userInfoAsyncContextKey
(ContextMap.Key<UserInfo> userInfoAsyncContextKey) Sets akey
to store a user info object of authenticated user inAsyncContext
.userInfoRequestContextKey
(ContextMap.Key<UserInfo> userInfoRequestContextKey) Sets akey
to store a user info object of authenticated user inrequest context
.
-
Constructor Details
-
Builder
public Builder(BasicAuthHttpServiceFilter.CredentialsVerifier<UserInfo> credentialsVerifier, String realm) Creates a new builder for anStreamingHttpServiceFilter
, which filters HTTP requests using RFC7617: The 'Basic' HTTP Authentication Scheme.It accepts credentials as
user-id:password
pairs, encoded usingBase64
forAuthorization
orProxy-Authorization
header values. Use of the formatuser:password
in theuserinfo
field is deprecated by RFC3986.User info object of authenticated user can be stored in
AsyncContext
ifContextMap.Key
is configured viauserInfoAsyncContextKey(ContextMap.Key)
orrequest context
ifContextMap.Key
is configured viauserInfoRequestContextKey(ContextMap.Key)
. The samekey
can be reused for both context storages.Note: This scheme is not considered to be a secure method of user authentication unless used in conjunction with some external secure system such as TLS (Transport Layer Security, [RFC5246]), as the
user-id
andpassword
are passed over the network as cleartext.- Parameters:
credentialsVerifier
- aBasicAuthHttpServiceFilter.CredentialsVerifier
foruser-id
andpasswords
pairrealm
- a protection space (realm)
-
-
Method Details
-
userInfoAsyncContextKey
public BasicAuthHttpServiceFilter.Builder<UserInfo> userInfoAsyncContextKey(ContextMap.Key<UserInfo> userInfoAsyncContextKey) Sets akey
to store a user info object of authenticated user inAsyncContext
.- Parameters:
userInfoAsyncContextKey
- a key to store a user info object inAsyncContext
- Returns:
this
-
userInfoRequestContextKey
public BasicAuthHttpServiceFilter.Builder<UserInfo> userInfoRequestContextKey(ContextMap.Key<UserInfo> userInfoRequestContextKey) Sets akey
to store a user info object of authenticated user inrequest context
.- Parameters:
userInfoRequestContextKey
- a key to store a user info object inrequest context
- Returns:
this
-
setCharsetUtf8
Sets an advice for a user agent to useUTF-8
charset when it generatesuser-id:password
pair.It will result in adding an optional charset="UTF-8" parameter for an authenticate header.
- Parameters:
utf8
- iftrue
, an optionalcharset="UTF-8"
parameter will be added for an authenticate header- Returns:
this
-
buildServer
Creates a new instance for non-proxy service.It will use the following constants to handle authentication:
Response status code, authenticate and authorization headers for non-proxy Basic auth Response status code 401 (Unauthorized) Authenticate header WWW-Authenticate Authorization header Authorization - Returns:
- a new
BasicAuthHttpServiceFilter.Builder
-
buildProxy
Creates a new instance for proxy service.It will use the following constants to handle authentication:
Response status code, authenticate and authorization headers for proxy Basic auth Response status code 407 (Proxy Authentication Required) Authenticate header Proxy-Authenticate Authorization header Proxy-Authorization - Returns:
- a new
StreamingHttpServiceFilterFactory
-