@Singleton
public class AuthService
extends java.lang.Object
Signin
controller and the @AuthAction.Auth
annotation defined in AuthAction
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SESSION_KEEP_SIGNEDIN
Parameter name in Play's session cookie: true if the user wants to be kept signed in.
|
static java.lang.String |
SESSION_LAST_ACTIVITY_TIME
Parameter name in Play's session cookie: It contains a timestamp of the last HTTP request done by the browser
with this cookie
|
static java.lang.String |
SESSION_SIGNIN_TIME
Parameter name in Play's session cookie: It contains the timestamp of the sign-in time
|
static java.lang.String |
SESSION_USERNAME
Parameter name in Play's session cookie: It contains the username of the signed-in user
|
static java.lang.String |
SIGNEDIN_USER
Key name used in RequestScope to store the signed-in User
|
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(User user,
java.lang.String password)
Authenticates the user with the given password.
|
java.lang.String |
getRedirectPageAfterSignin(User user)
Returns the URL of the page the user visited last - or the URL of the home page.
|
User |
getSignedinUser()
Gets the signed-in user from the RequestScope.
|
User |
getSignedinUserBySessionCookie(play.mvc.Http.Session session)
Retrieves the signed-in user from Play's session.
|
boolean |
isInactivityTimeout(play.mvc.Http.Session session)
Returns true if the session inactivity time as saved in Play's session
cookie is older than allowed.
|
boolean |
isRepeatedSigninAttempt(java.lang.String normalizedUsername)
Returns true if there were already 3 sign-in attempts within the last minute with this username
|
boolean |
isSessionKeepSignedin(play.mvc.Http.Session session)
Returns true if the user decided to be kept signed (checkbox on the sign-in page) AND if it is allowed to be kept
signed in.
|
boolean |
isSessionTimeout(play.mvc.Http.Session session)
Returns true if the session sign-in time as saved in Play's session cookie
is older than allowed.
|
void |
writeSessionCookie(play.mvc.Http.Session session,
java.lang.String normalizedUsername,
boolean keepSignedin)
Prepares Play's session cookie for the user with the given username to be signed-in.
|
public static final java.lang.String SESSION_USERNAME
public static final java.lang.String SESSION_SIGNIN_TIME
public static final java.lang.String SESSION_LAST_ACTIVITY_TIME
public static final java.lang.String SESSION_KEEP_SIGNEDIN
public static final java.lang.String SIGNEDIN_USER
public boolean authenticate(User user, java.lang.String password) throws javax.naming.NamingException
javax.naming.NamingException
public boolean isRepeatedSigninAttempt(java.lang.String normalizedUsername)
public User getSignedinUserBySessionCookie(play.mvc.Http.Session session)
In most cases, getSignedinUser() is faster since it doesn't have to query the database.
public User getSignedinUser()
public void writeSessionCookie(play.mvc.Http.Session session, java.lang.String normalizedUsername, boolean keepSignedin)
public boolean isSessionKeepSignedin(play.mvc.Http.Session session)
public boolean isSessionTimeout(play.mvc.Http.Session session)
public boolean isInactivityTimeout(play.mvc.Http.Session session)
public java.lang.String getRedirectPageAfterSignin(User user)