Errai 3.0.1-SNAPSHOT

org.jboss.errai.security.client.local.api
Interface SecurityContext

All Known Implementing Classes:
SecurityContextImpl

public interface SecurityContext

Caches information regarding security events and the current user (i.e. which user is logged in, and what was the last page they were rejected from).

Author:
Max Barkley

Method Summary
 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.
 

Method Detail

redirectToLoginPage

void redirectToLoginPage()
Navigate to the LoginPage, caching the current page. This is the same as calling redirectToLoginPage(Class) with the argument Navigation.getCurrentPage().contentType().


redirectToLoginPage

void redirectToLoginPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Navigate to the LoginPage.

Parameters:
fromPage - This Page type is cached so that a subsequent call to navigateBackOrHome() or navigateBackOrToPage(Class) will return to the Page of this type.

redirectToSecurityErrorPage

void redirectToSecurityErrorPage()
Navigate to the SecurityError, caching the current page. This is the same as calling redirectToSecurityErrorPage(Class) with the argument Navigation.getCurrentPage().contentType().


redirectToSecurityErrorPage

void redirectToSecurityErrorPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Navigate to the SecurityError page.

Parameters:
fromPage - This Page type is cached so that a subsequent call to navigateBackOrHome() or navigateBackOrToPage(Class) will return to the Page of this type.

navigateBackOrHome

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.


navigateBackOrToPage

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.

Parameters:
pageType - The type of the page to navigate to if the user has not been redirected. Must not be null.

hasCachedUser

boolean hasCachedUser()
Returns:
True iff SecurityContext#isCacheValid() is true and getCachedUser() will not return User.ANONYMOUS.

getCachedUser

User getCachedUser()
Remote calls to AuthenticationService are cached, such that calls to this method can retrieve the logged in User from memory.

Returns:
The currently logged in User. If no user is logged in (or the cache is invalid) then User.ANONYMOUS.

setCachedUser

void setCachedUser(User user)
Validate and set the cached user. Subsequent calls to getCachedUser() will return the given user until this method or invalidateCache() is called. Subsequent calls to SecurityContext#isCacheValid() will return true until invalidateCache() is called.

Parameters:
user - The User to cache. Must not be null. To set no user as logged in, user User.ANONYMOUS.

isUserCacheValid

boolean isUserCacheValid()
Returns:
True if a call to getCachedUser() accurately reflects the User that would be returned from a call to AuthenticationService.getUser().

invalidateCache

void invalidateCache()
Invalidate the cached User. Subsequent calls to isUserCacheValid() will return false.


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.