public class Authentication extends Object
| Constructor and Description |
|---|
Authentication() |
Authentication(LocalDateTime expires,
String authenticatedUser) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
authenticate(String password,
String hash)
Creates a hashed value of a given clear text password and checks if the
value matches a given, already hashed password
|
String |
getAuthenticatedUser()
Retrieves the current authenticated user
|
LocalDateTime |
getExpires()
Returns the LocalDateTime when the authentication expires
|
String |
getHashedPassword(String password)
Hashes a given clear text password using JBCrypt
|
OAuthUser |
getOAuthUser()
Retrieves the current OAuthUser from the authentication
Note: This is only available during a OAuth authentication in a
method that is annotated with @OAuthCallbackFilter
|
boolean |
hasAuthenticatedUser()
Checks if the authentication contains an authenticated user
|
boolean |
isAuthenticated(String username)
Checks if the given user name is authenticated
|
boolean |
isLogout() |
boolean |
isRemember() |
void |
login(String username)
Convenient method that calls
login with
remember set to false |
void |
login(String username,
boolean remember)
Performs a login for a given user name
|
void |
logout()
Performs a logout of the currently authenticated user
|
void |
setOAuthUser(OAuthUser oAuthUser)
Sets an OAuthUser to the current authentication.
|
public Authentication()
public Authentication(LocalDateTime expires, String authenticatedUser)
public String getAuthenticatedUser()
public LocalDateTime getExpires()
public boolean isLogout()
public boolean isRemember()
public void setOAuthUser(OAuthUser oAuthUser)
oAuthUser - An OAuthUserpublic OAuthUser getOAuthUser()
public String getHashedPassword(String password)
password - The clear text passwordpublic boolean authenticate(String password, String hash)
password - The clear text passwordhash - The previously hashed password to checkpublic void logout()
public void login(String username, boolean remember)
username - The user name to loginremember - If true, the user will stay logged in for (default) 2 weekspublic void login(String username)
login with
remember set to falseusername - The user name to loginpublic boolean hasAuthenticatedUser()
public boolean isAuthenticated(String username)
username - The user name to checkCopyright © 2016. All rights reserved.