Package io.milton.http.http11.auth
Class CookieAuthenticationHandler
java.lang.Object
io.milton.http.http11.auth.CookieAuthenticationHandler
- All Implemented Interfaces:
AuthenticationHandler
This wraps a bunch of other authentication handlers, so if any of those
successfully login the user then this will generate a cookie which can be
used subsequently.
Note that it is usually not correct to wrap a Digest auth handler because
that would then defeat the purpose of digest authentication. However, this
can and should wrap Basic and Form authentication handlers
- Author:
- brad
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCookieAuthenticationHandler(NonceProvider nonceProvider, List<AuthenticationHandler> handlers, ResourceFactory principalResourceFactory, List<String> keys) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChallenges(Resource resource, Request request, List<String> challenges) Create a challenge for this authentication method.authenticate(Resource resource, Request request) Authenticate the details in the request for access to the given resource.booleancredentialsPresent(Request request) Determine if there are login credentials present.encodeUserUrl(String userUrl) getHashFromRequest(Request request) getLoginToken(String userUrl, Request request) getLoginToken(String userUrl, Request request, String host) getLoginToken(String userUrl, String urlSigningHash) getUrlSigningHash(String userUrl, Request request) The hmac signs a message in the form nonce || userUrl, where the nonce is requested from the nonceProvider This method returns a signing token in the form nonce || hmacgetUrlSigningHash(String userUrl, Request request, String host) getUserUrl(Request request) Find a previous login token in the request, and if present verify its authenticity via a signing cookiegetUserUrlFromRequest(Request request) booleanisCompatible(Resource resource, Request request) Returns true if this authentication handler is compatible with the given resource This is used when authorisation has failed, in generating challenge responses If you don't want to add a challenge response, return falsebooleanvoidsetLoginCookies(DiscretePrincipal user, Request request) Sets cookies to make the given user the currently logged in user for any subsequent requests.voidsetLoginCookies(String userUrl, Request request) voidsetUseLongLivedCookies(boolean useLongLivedCookies) voidsetUserUrlAttName(String userUrlAttName) booleanReturns true if this supports authenticating with the given Auth data on the given resource.
-
Field Details
-
SECONDS_PER_YEAR
public static final int SECONDS_PER_YEAR- See Also:
-
-
Constructor Details
-
CookieAuthenticationHandler
public CookieAuthenticationHandler(NonceProvider nonceProvider, List<AuthenticationHandler> handlers, ResourceFactory principalResourceFactory, List<String> keys)
-
-
Method Details
-
credentialsPresent
Description copied from interface:AuthenticationHandlerDetermine if there are login credentials present. Should not attempt to validate credentials. Should only determine if something has been provided- Specified by:
credentialsPresentin interfaceAuthenticationHandler- Returns:
-
supports
Description copied from interface:AuthenticationHandlerReturns true if this supports authenticating with the given Auth data on the given resource. Only the first AuthenticationHandler which returns true for supports will be used for authentication. Ie supports implementations should be mutually exclusive- Specified by:
supportsin interfaceAuthenticationHandler- Parameters:
r- - the resource being access- Returns:
-
authenticate
Description copied from interface:AuthenticationHandlerAuthenticate the details in the request for access to the given resource.- Specified by:
authenticatein interfaceAuthenticationHandler- Returns:
-
setLoginCookies
Sets cookies to make the given user the currently logged in user for any subsequent requests. And also makes that user the current on-behalf-of user in CurrentUserService- Parameters:
user-request-
-
setLoginCookies
-
appendChallenges
Description copied from interface:AuthenticationHandlerCreate a challenge for this authentication method. This should be completely formatted as per http://tools.ietf.org/html/rfc2617 and appended to the given list of challenges. It is allowable to append more then one challenge if appropriate- Specified by:
appendChallengesin interfaceAuthenticationHandlerchallenges- - the list of challenges to append to, or not, as appropriate
-
isCompatible
Description copied from interface:AuthenticationHandlerReturns true if this authentication handler is compatible with the given resource This is used when authorisation has failed, in generating challenge responses If you don't want to add a challenge response, return false- Specified by:
isCompatiblein interfaceAuthenticationHandler- Returns:
- - true if this can authenticate the resource, and it should issue a http challenge
-
getUserUrl
Find a previous login token in the request, and if present verify its authenticity via a signing cookie- Parameters:
request-- Returns:
-
getUserUrlFromRequest
-
getHashFromRequest
-
getUrlSigningHash
The hmac signs a message in the form nonce || userUrl, where the nonce is requested from the nonceProvider This method returns a signing token in the form nonce || hmac- Parameters:
userUrl-request-- Returns:
-
getUrlSigningHash
-
getLoginToken
-
getLoginToken
-
getLoginToken
-
encodeUserUrl
-
getCookieNameUserUrlHash
-
getCookieNameUserUrl
-
getUserUrlAttName
-
getLoginTokenName
-
setUserUrlAttName
-
setUseLongLivedCookies
public void setUseLongLivedCookies(boolean useLongLivedCookies) -
isUseLongLivedCookies
public boolean isUseLongLivedCookies()
-