Example usage for org.apache.wicket.request.flow ResetResponseException ResetResponseException

List of usage examples for org.apache.wicket.request.flow ResetResponseException ResetResponseException

Introduction

In this page you can find the example usage for org.apache.wicket.request.flow ResetResponseException ResetResponseException.

Prototype

protected ResetResponseException(final IRequestHandler handler) 

Source Link

Document

Construct.

Usage

From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java

License:Apache License

/**
 * Determine what caused the unauthorized instantiation of the given
 * component. If access was denied due to being unauthenticated, and
 * the login page specified in the constructor was not {@code null},
 * call {@link #onLoginRequired} and redirect to the login page.
 * <p>/*from   w  w w  .  j a v a  2  s.  c om*/
 * Otherwise, access was denied due to authorization failure (e.g. insufficient privileges),
 * call {@link #onUnauthorized} and render the unauthorized page (which is the home page by
 * default).
 * 
 * @param component The component that failed to initialize due to 
 *                  authorization or authentication failure
 * 
 * @throws {@link ResetResponseException} to render the login page or unauthorized page
 * 
 * @throws UnauthorizedInstantiationException the login page
 *                                            has not been configured (i.e. is {@code null})
 */
public void onUnauthorizedInstantiation(Component component) {
    AuthorizationException cause;
    RequestCycle rc = RequestCycle.get();
    cause = rc.getMetaData(EXCEPTION_KEY);

    // Show appropriate login or error page if possible
    IRequestHandler handler = onException(rc, cause);
    if (handler != null) {
        throw new ResetResponseException(handler) {
        };
    }

    // Otherwise bubble up the error
    UnauthorizedInstantiationException ex;
    ex = new UnauthorizedInstantiationException(component.getClass());
    ex.initCause(cause);
    throw ex;
}

From source file:lt.inventi.wicket.shiro.ShiroWicketPlugin.java

License:Apache License

/**
 * Determine what caused the unauthorized instantiation of the given
 * component. If access was denied due to being unauthenticated, and
 * the login page specified in the constructor was not {@code null},
 * call {@link #onLoginRequired} and redirect to the login page.
 * <p>/* w  w  w .  j a v a2s.  c  om*/
 * Otherwise, access was denied due to authorization failure (e.g. insufficient privileges),
 * call {@link #onUnauthorized} and render the unauthorized page (which is the home page by
 * default).
 *
 * @param component The component that failed to initialize due to
 *                  authorization or authentication failure
 *
 * @throws {@link ResetResponseException} to render the login page or unauthorized page
 *
 * @throws UnauthorizedInstantiationException the login page
 *                                            has not been configured (i.e. is {@code null})
 */
@Override
public void onUnauthorizedInstantiation(Component component) {
    AuthorizationException cause;
    RequestCycle rc = RequestCycle.get();
    cause = rc.getMetaData(EXCEPTION_KEY);

    // Show appropriate login or error page if possible
    IRequestHandler handler = onException(rc, cause);
    if (handler != null) {
        throw new ResetResponseException(handler) {
        };
    }

    // Otherwise bubble up the error
    UnauthorizedInstantiationException ex;
    ex = new UnauthorizedInstantiationException(component.getClass());
    ex.initCause(cause);
    throw ex;
}