Errai 3.0.1-SNAPSHOT

org.jboss.errai.security.client.local.context
Class SecurityContextImpl

java.lang.Object
  extended by org.jboss.errai.security.client.local.context.SecurityContextImpl
All Implemented Interfaces:
SecurityContext

@ApplicationScoped
public class SecurityContextImpl
extends Object
implements SecurityContext

Author:
Max Barkley

Nested Class Summary
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 Summary
SecurityContextImpl()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityContextImpl

public SecurityContextImpl()
Method Detail

redirectToLoginPage

public void redirectToLoginPage()
Description copied from interface: SecurityContext
Navigate to the LoginPage, caching the current page. This is the same as calling SecurityContext.redirectToLoginPage(Class) with the argument Navigation.getCurrentPage().contentType().

Specified by:
redirectToLoginPage in interface SecurityContext

redirectToLoginPage

public void redirectToLoginPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Description copied from interface: SecurityContext
Navigate to the LoginPage.

Specified by:
redirectToLoginPage in interface SecurityContext
Parameters:
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.

redirectToSecurityErrorPage

public void redirectToSecurityErrorPage()
Description copied from interface: SecurityContext
Navigate to the SecurityError, caching the current page. This is the same as calling SecurityContext.redirectToSecurityErrorPage(Class) with the argument Navigation.getCurrentPage().contentType().

Specified by:
redirectToSecurityErrorPage in interface SecurityContext

redirectToSecurityErrorPage

public void redirectToSecurityErrorPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> fromPage)
Description copied from interface: SecurityContext
Navigate to the SecurityError page.

Specified by:
redirectToSecurityErrorPage in interface SecurityContext
Parameters:
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.

invalidateCache

public void invalidateCache()
Description copied from interface: SecurityContext
Invalidate the cached User. Subsequent calls to SecurityContext.isUserCacheValid() will return false.

Specified by:
invalidateCache in interface SecurityContext

navigateBackOrToPage

public void navigateBackOrToPage(Class<? extends com.google.gwt.user.client.ui.IsWidget> pageType)
Description copied from interface: SecurityContext
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.

Specified by:
navigateBackOrToPage in interface SecurityContext
Parameters:
pageType - The type of the page to navigate to if the user has not been redirected. Must not be null.

navigateBackOrHome

public void navigateBackOrHome()
Description copied from interface: SecurityContext
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.

Specified by:
navigateBackOrHome in interface SecurityContext

hasCachedUser

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

getCachedUser

public User getCachedUser()
Description copied from interface: SecurityContext
Remote calls to AuthenticationService are cached, such that calls to this method can retrieve the logged in User from memory.

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

setCachedUser

public void setCachedUser(User user)
Description copied from interface: SecurityContext
Validate and set the cached user. Subsequent calls to 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.

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

isUserCacheValid

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

Errai 3.0.1-SNAPSHOT

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