public class AuthToken
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
canonicFromAddr(javax.servlet.http.HttpServletRequest request)
Extract a textual description of the machine the request came from
using the remoteAddr and X-Forwarded-For Header variables
|
static java.lang.String |
canonicFromAddr(org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest request) |
static java.lang.String |
createAndGetCredential(java.lang.String serviceName,
Benutzer user,
javax.servlet.http.HttpServletRequest request,
int validitySeconds)
Same as
createAndGetCredential(String,Benutzer,String,int), but with an automatic handling of the from data of the given request. |
static java.lang.String |
createAndGetCredential(java.lang.String serviceName,
Benutzer user,
javax.servlet.http.HttpServletRequest request,
java.lang.String document,
int validitySeconds)
Same as
createAndGetCredential(String,Benutzer,String,String,byte[],int), but with an automatic handling of the from data of the given request, without auxData. |
static java.lang.String |
createAndGetCredential(java.lang.String serviceName,
Benutzer user,
java.lang.String machine,
int validitySeconds)
Same as
createAndGetCredential(String,Benutzer,String,String,byte[],int) for minimum requirements such as automatic Website logon,
without document and auxData. |
static java.lang.String |
createAndGetCredential(java.lang.String serviceName,
Benutzer user,
java.lang.String machine,
java.lang.String document,
byte[] auxData,
int validitySeconds)
Creates an AuthToken with given Benutzer object, a machine and document identifier,
a not-to-encrypt auxiliary data and a validity in seconds, persisting it and returning
a url encoded String to retrieve that information on a later occasion.
|
void |
destroy(java.lang.String serviceName,
BOLoaderI loader)
Destroy this AuthToken immediately
|
byte[] |
getAuxData()
return the auxiliary data stored on the server not included in the credential
|
java.lang.String |
getCredential()
Return a url encoded (using only [a-zA-Z0-9_\-]) credential string
having user, document and machine encoded with a random password,
which can be used to retrieve that AuthToken from the
ExpiringTokenStorageProviderI.
|
java.lang.String |
getDocument()
get the name of the document the access was granted to
|
static AuthToken |
getInstance(java.lang.String serviceName,
Benutzer user,
java.lang.String machine,
java.lang.String document,
byte[] auxData,
int validitySeconds)
Creates an AuthToken with given Benutzer object, a machine and document identifier,
a not-to-encrypt auxiliary data and a validity in seconds, persisting and returning it.
|
java.lang.String |
getMachine()
get a textual description of the machine the request came from
|
long |
getUserId()
get the userId associated
|
static AuthToken |
parse(java.lang.String serviceName,
java.lang.String cred,
BOLoaderI loader)
Recovers an AuthToken from the given credential
|
void |
renew(java.lang.String serviceName,
BOLoaderI loader,
int validitySeconds)
Renew this AuthToken, eventually with updated auxData
|
void |
setAuxData(byte[] auxData)
set the auxiliary data stored on the server not included in the credential
|
void |
validate(BOLoaderI loader,
javax.servlet.http.HttpServletRequest request)
minimum version of the
validate(BOLoaderI,String,String) call without a document, automatically handling a request as machine substitute. |
void |
validate(BOLoaderI loader,
org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest request) |
void |
validate(BOLoaderI loader,
java.lang.String machine,
java.lang.String document)
check if the encoded user id is available and a valid user object,
and, if given, check restrictions upon machine and document.
|
public static java.lang.String createAndGetCredential(java.lang.String serviceName,
Benutzer user,
java.lang.String machine,
java.lang.String document,
byte[] auxData,
int validitySeconds)
serviceName - a name for the service provided (such as 'dav', 'u2f' or 'weblogon')user - Benutzer which wants access to a resource, must be !=nullmachine - a text describing the machine from which that access came from,
ideally from request.remoteAddr or X-Forwarded-For headerdocument - a string describing the document the access was granted toauxData - a payload which will be stored unencrypted on the server not to
be encoded into the token (could be a remark in case of an error)validitySeconds - the duration in seconds after which this AuthToken will expirepublic static java.lang.String createAndGetCredential(java.lang.String serviceName,
Benutzer user,
javax.servlet.http.HttpServletRequest request,
java.lang.String document,
int validitySeconds)
createAndGetCredential(String,Benutzer,String,String,byte[],int), but with an automatic handling of the from data of the given request, without auxData.String - serviceName
a name for the service provided (such as 'dav', 'u2f' or 'weblogon')user - Benutzer which wants access to a resource, must be !=nullrequest - an HttpServletRequest from the servlet; will be analyzed via
remoteAddr and X-Forwarded-For headers to extract the machine the
request came fromdocument - the name of the document we granted access tovaliditySeconds - the duration in seconds after which this AuthToken will expirepublic static java.lang.String createAndGetCredential(java.lang.String serviceName,
Benutzer user,
java.lang.String machine,
int validitySeconds)
createAndGetCredential(String,Benutzer,String,String,byte[],int) for minimum requirements such as automatic Website logon,
without document and auxData.public static java.lang.String createAndGetCredential(java.lang.String serviceName,
Benutzer user,
javax.servlet.http.HttpServletRequest request,
int validitySeconds)
createAndGetCredential(String,Benutzer,String,int), but with an automatic handling of the from data of the given request.serviceName - a name for the service provided (such as 'dav', 'u2f' or 'weblogon')user - Benutzer which wants access to a resource, must be !=nullrequest - an HttpServletRequest from the servlet; will be analyzed via
remoteAddr and X-Forwarded-For headers to extract the machine the
request came fromvaliditySeconds - the duration in seconds after which this AuthToken will expirepublic static AuthToken getInstance(java.lang.String serviceName, Benutzer user, java.lang.String machine, java.lang.String document, byte[] auxData, int validitySeconds)
serviceName - a name for the service provided (such as 'dav', 'u2f' or 'weblogon')user - Benutzer which wants access to a resource, must be !=nullmachine - a text describing the machine from which that access came from,
ideally from request.remoteAddr or X-Forwarded-For headerdocument - the name of the document the access was granted toauxData - a payload which will be stored unencrypted on the server not to
be encoded into the token (could be a remark in case of an error)validitySeconds - the duration in seconds after which this AuthToken will expirepublic java.lang.String getCredential()
public void renew(java.lang.String serviceName,
BOLoaderI loader,
int validitySeconds)
loader - loader to usevaliditySeconds - duration in seconds after which this AuthToken will expirepublic void destroy(java.lang.String serviceName,
BOLoaderI loader)
loader - loader to usepublic static AuthToken parse(java.lang.String serviceName, java.lang.String cred, BOLoaderI loader) throws AuthenticationException
serviceName - a name for the service provided (such as 'dav', 'u2f' or 'weblogon')cred - the credential to recoverloader - the loader to usejava.lang.IllegalArgumentException - if cred or loader is null or cred doesn't consist of two parts concatted with a dot.AuthenticationException - in case the token is expired or we're unable to decrypt the credentialpublic void validate(BOLoaderI loader, java.lang.String machine, java.lang.String document) throws AuthenticationException
loader - loader to fetch user and checkmachine - a text describing the machine from which that access came from,
ideally from request.remoteAddr or X-Forwarded-For headerdocument - string describing the document the request wants access toAuthenticationException - if the userId in the encoded payload is non-existent or invalid
(read: no Benutzer object).public void validate(BOLoaderI loader, javax.servlet.http.HttpServletRequest request) throws AuthenticationException
validate(BOLoaderI,String,String) call without a document, automatically handling a request as machine substitute.loader - loader to fetch user and checkrequest - an HttpServletRequest from the servletAuthenticationExceptionpublic void validate(BOLoaderI loader, org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest request) throws AuthenticationException
AuthenticationExceptionpublic long getUserId()
public java.lang.String getMachine()
public java.lang.String getDocument()
public byte[] getAuxData()
public void setAuxData(byte[] auxData)
auxData - the data to be stored on the server aside the encryption passwordpublic static java.lang.String canonicFromAddr(javax.servlet.http.HttpServletRequest request)
request - the request from the http server, must be !=nullpublic static java.lang.String canonicFromAddr(org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest request)
Copyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.