java.lang.Object
org.apache.jena.http.auth.AuthEnv
An authentication environment. Multiple
AuthEnv
would exists for a
multi-tenant environment. This is not currently supported but the use of
an object, obtained with get()
, allows for that in the future,-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAuth
(HttpRequest.Builder requestBuilder, String uri) Add authentication, if in the authModifiers registry.void
void
Clear all registrations.static AuthEnv
get()
Get the AuthEnv appropriate to the caller.getBearerToken
(String uri, AuthChallenge aHeader) Return a bearer auth token to use when responding to a 401 challenge.getUsernamePassword
(URI uri) Return the (username, password) for aURI
.boolean
hasRegistation
(URI uri) Check whether there is a registration.void
registerAuthModifier
(String requestTarget, AuthRequestModifier authModifier) Register an AuthRequestModifier for a specific request targetvoid
registerBasicAuthModifier
(String url, String user, String password) Register the user/password which is to be used with basic auth at the given URLvoid
registerUsernamePassword
(String uri, String username, String password) Register (username, password) information for a URI endpoint.void
registerUsernamePassword
(URI uri, String username, String password) Register (username, password) information for a URI endpoint.void
setBearerToken
(String requestTarget, String token) Set the tokens for bearer authentication at an specific endpoint.void
setBearerTokenProvider
(BiFunction<String, AuthChallenge, String> tokenSupplier) Set the creator of tokens for bearer authentication.void
state()
void
unregisterAuthModifier
(String requestTarget) Remove any AuthRequestModifier for a specific request targetvoid
Remove the registration for a URI endpoint.
-
Field Details
-
LOG
public static org.slf4j.Logger LOG
-
-
Method Details
-
get
Get the AuthEnv appropriate to the caller. -
registerUsernamePassword
Register (username, password) information for a URI endpoint. -
registerUsernamePassword
Register (username, password) information for a URI endpoint. -
hasRegistation
Check whether there is a registration. -
unregisterUsernamePassword
Remove the registration for a URI endpoint. -
getUsernamePassword
Return the (username, password) for aURI
.If there is no exact match for the URI, then the information mapped from the longest prefix entry is returned.
-
clearActiveAuthentication
public void clearActiveAuthentication() -
clearAuthEnv
public void clearAuthEnv()Clear all registrations. -
addAuth
Add authentication, if in the authModifiers registry. That is, add the right headers, and for digest, calculate the new digest string. -
registerBasicAuthModifier
Register the user/password which is to be used with basic auth at the given URL -
registerAuthModifier
Register an AuthRequestModifier for a specific request target -
unregisterAuthModifier
Remove any AuthRequestModifier for a specific request target -
setBearerTokenProvider
Set the creator of tokens for bearer authentication. The function must return null (reject a 401 challenge) or a valid token including encoding (e.g. Base64). It must not contain spaces. Requests will fail when the token becomes out-of-date and the application will need to set a new token.The string supplied will be used as-is with no further processing.
Supply a null argument for the tokenSupplier to clear any previous token supplier.
-
setBearerToken
Set the tokens for bearer authentication at an specific endpoint. This is added to all requests sent to this same request target. Requests will fail when the token becomes out-of-date and the application will need to set a new token.The string supplied will be used as-is with no further processing. Supply a null argument to clear any previous token supplier.
-
getBearerToken
Return a bearer auth token to use when responding to a 401 challenge. The token must be in the form required for the "Authorization" header, including encoding (typically base64 URL encoding with no padding). The string supplied is used as-is with no further processing.Return null for "no token" in which case a 401 response is passed back to the application.
-
state
public void state()
-