@ApplicationScoped public class SecurityContextImpl extends Object implements SecurityContext
Modifier and Type | Class and Description |
---|---|
static class |
SecurityContextImpl.SecurityRolesConstraintPage
This page exists so that the existence of pages with
LoginPage and
SecurityError roles can be enforced at compile-time. |
Constructor and Description |
---|
SecurityContextImpl() |
Modifier and Type | Method and Description |
---|---|
User |
getCachedUser()
Remote calls to
AuthenticationService are cached, such that calls
to this method can retrieve the logged in User from memory. |
boolean |
hasCachedUser() |
void |
invalidateCache()
Invalidate the cached
User . |
boolean |
isUserCacheValid() |
void |
navigateBackOrHome()
Navigate to the last page a user was redirected from (via this security context), or to the
DefaultPage if the user has not been redirected. |
void |
navigateBackOrToPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> pageType)
Navigate to the last page a user was redirected from (via this security context), or to the
given page if the user has not been redirected.
|
void |
redirectToLoginPage()
Navigate to the
LoginPage , caching the current page. |
void |
redirectToLoginPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Navigate to the
LoginPage . |
void |
redirectToSecurityErrorPage()
Navigate to the
SecurityError , caching the current page. |
void |
redirectToSecurityErrorPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Navigate to the
SecurityError page. |
void |
setCachedUser(User user)
Validate and set the cached user.
|
public void redirectToLoginPage()
SecurityContext
LoginPage
, caching the current page. This is the same as calling
SecurityContext.redirectToLoginPage(Class)
with the argument Navigation.getCurrentPage().contentType()
.redirectToLoginPage
in interface SecurityContext
public void redirectToLoginPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
SecurityContext
LoginPage
.redirectToLoginPage
in interface SecurityContext
fromPage
- This Page
type is cached so that a subsequent call to
SecurityContext.navigateBackOrHome()
or SecurityContext.navigateBackOrToPage(Class)
will return to
the Page
of this type.public void redirectToSecurityErrorPage()
SecurityContext
SecurityError
, caching the current page. This is the same as calling
SecurityContext.redirectToSecurityErrorPage(Class)
with the argument
Navigation.getCurrentPage().contentType()
.redirectToSecurityErrorPage
in interface SecurityContext
public void redirectToSecurityErrorPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
SecurityContext
SecurityError
page.redirectToSecurityErrorPage
in interface SecurityContext
fromPage
- This Page
type is cached so that a subsequent call to
SecurityContext.navigateBackOrHome()
or SecurityContext.navigateBackOrToPage(Class)
will return to
the Page
of this type.public void invalidateCache()
SecurityContext
User
. Subsequent calls to
SecurityContext.isUserCacheValid()
will return false.invalidateCache
in interface SecurityContext
public void navigateBackOrToPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> pageType)
SecurityContext
navigateBackOrToPage
in interface SecurityContext
pageType
- The type of the page to navigate to if the user has not been redirected. Must not be
null
.public void navigateBackOrHome()
SecurityContext
DefaultPage
if the user has not been redirected.navigateBackOrHome
in interface SecurityContext
public boolean hasCachedUser()
hasCachedUser
in interface SecurityContext
SecurityContext#isCacheValid()
is true and
SecurityContext.getCachedUser()
will not return
User.ANONYMOUS
.public User getCachedUser()
SecurityContext
AuthenticationService
are cached, such that calls
to this method can retrieve the logged in User
from memory.getCachedUser
in interface SecurityContext
User
. If no user is logged in (or
the cache is invalid
)
then User.ANONYMOUS
.public void setCachedUser(User user)
SecurityContext
SecurityContext.getCachedUser()
will return the given user until
this method or SecurityContext.invalidateCache()
is called.
Subsequent calls to SecurityContext#isCacheValid()
will return true
until SecurityContext.invalidateCache()
is called.setCachedUser
in interface SecurityContext
user
- The User
to cache. Must not be null
. To set no
user as logged in, user User.ANONYMOUS
.public boolean isUserCacheValid()
isUserCacheValid
in interface SecurityContext
SecurityContext.getCachedUser()
accurately reflects the User
that would be returned from a
call to AuthenticationService.getUser()
.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.