Errai 3.0.1-SNAPSHOT

org.jboss.errai.security.client.local.callback
Class DefaultRestSecurityErrorCallback

java.lang.Object
  extended by org.jboss.errai.security.client.local.callback.DefaultRestSecurityErrorCallback
All Implemented Interfaces:
ErrorCallback<com.google.gwt.http.client.Request>, RestErrorCallback

@Dependent
public class DefaultRestSecurityErrorCallback
extends Object
implements RestErrorCallback

A RestErrorCallback that catches UnauthenticatedExceptions and UnauthorizedExceptions and navigates to the page with the LoginPage or SecurityError role, respectively. Optionally, this class can wrap a given RestErrorCallback that it will call first, in which case this class will only perform the actions described above if the wrapped callback returns true.

Author:
Max Barkley

Constructor Summary
DefaultRestSecurityErrorCallback(RestErrorCallback wrapped, SecurityContext context)
          Create a DefaultRestSecurityErrorCallback wrapping a given RestErrorCallback.
DefaultRestSecurityErrorCallback(SecurityContext context)
          Create a DefaultRestSecurityErrorCallback.
 
Method Summary
 boolean error(com.google.gwt.http.client.Request message, Throwable throwable)
          Called when an error occurs on the bus.
 RestErrorCallback setWrappedErrorCallback(RestErrorCallback wrapped)
          Set the wrapped callback that will be invoked first when RestErrorCallback#error(Request, Throwable) is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRestSecurityErrorCallback

public DefaultRestSecurityErrorCallback(RestErrorCallback wrapped,
                                        SecurityContext context)
Create a DefaultRestSecurityErrorCallback wrapping a given RestErrorCallback.

Parameters:
wrapped - The wrapped callback (should never be null, that will be invoked first when RestErrorCallback#error(Request, Throwable) is called. If the error method on the wrapped returns false, the whole callback returns false immediately.
context - The SecurityContext.

DefaultRestSecurityErrorCallback

@Inject
public DefaultRestSecurityErrorCallback(SecurityContext context)
Create a DefaultRestSecurityErrorCallback.

Parameters:
context - The SecurityContext.
Method Detail

error

public boolean error(com.google.gwt.http.client.Request message,
                     Throwable throwable)
              throws MissingPageRoleException
Description copied from interface: ErrorCallback
Called when an error occurs on the bus.

Specified by:
error in interface ErrorCallback<com.google.gwt.http.client.Request>
Parameters:
message - The message or request for which the failure occurred.
throwable - The exception thrown or null if not available
Returns:
boolean indicating whether or not the default error handling should be performed.
Throws:
MissingPageRoleException

setWrappedErrorCallback

public RestErrorCallback setWrappedErrorCallback(RestErrorCallback wrapped)
Set the wrapped callback that will be invoked first when RestErrorCallback#error(Request, Throwable) is called. If the error method on the wrapped callback returns false, the whole callback returns false immediately.

Parameters:
wrapped - The wrapped callback. Passing in null clears any previous wrapped callback.
Returns:
A reference to this callback for chaining.

Errai 3.0.1-SNAPSHOT

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