CASC-19
added option of not throwing an exception on validation failure
This commit is contained in:
parent
0fdc07ccda
commit
2c1ad449cc
|
|
@ -45,6 +45,9 @@ public final class TicketValidationFilter extends AbstractCasFilter {
|
|||
*/
|
||||
private final boolean redirectAfterValidation;
|
||||
|
||||
/** Determines whether an exception is thrown when there is a ticket validation failure. */
|
||||
private final boolean exceptionOnValidationFailure;
|
||||
|
||||
/**
|
||||
* Constructor that takes the severName (or serviceUrl) and the TicketValidator. Either serveName or serviceUrl is required (but not both).
|
||||
*
|
||||
|
|
@ -66,15 +69,31 @@ public final class TicketValidationFilter extends AbstractCasFilter {
|
|||
* @param redirectAfterValidation whether to redirect to remove the ticket.
|
||||
*/
|
||||
public TicketValidationFilter(final String serverName, final String serviceUrl, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation) {
|
||||
this(serverName, serviceUrl, useSession, ticketValidator, redirectAfterValidation, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that takes the severName (or serviceUrl), TicketValidator, useSession and redirectAfterValidation. Either serveName or serviceUrl is required (but not both).
|
||||
*
|
||||
* @param serverName the name of the server in <hostname>:<port> combination, if using a non-standard port.
|
||||
* @param serviceUrl the url to always redirect to.
|
||||
* @param useSession flag to set whether to store stuff in the session.
|
||||
* @param ticketValidator the validator to validate the tickets.
|
||||
* @param redirectAfterValidation whether to redirect to remove the ticket.
|
||||
* @param exceptionOnValidationFailure whether to throw an exception if there is a validation failure or not.
|
||||
*/
|
||||
public TicketValidationFilter(final String serverName, final String serviceUrl, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation, final boolean exceptionOnValidationFailure) {
|
||||
super(serverName, serviceUrl, useSession);
|
||||
CommonUtils.assertNotNull(ticketValidator,
|
||||
"ticketValidator cannot be null.");
|
||||
this.ticketValidator = ticketValidator;
|
||||
this.redirectAfterValidation = redirectAfterValidation;
|
||||
this.exceptionOnValidationFailure = exceptionOnValidationFailure;
|
||||
|
||||
log.info("Initialized with the following properties: " +
|
||||
"ticketValidator=" + this.ticketValidator.getClass().getName() + "; " +
|
||||
"redirectAfterValidation=" + this.redirectAfterValidation);
|
||||
"redirectAfterValidation=" + this.redirectAfterValidation + "; exceptionOnValidationFailure=" + exceptionOnValidationFailure);
|
||||
|
||||
}
|
||||
|
||||
protected void doFilterInternal(final HttpServletRequest request,
|
||||
|
|
@ -106,7 +125,10 @@ public final class TicketValidationFilter extends AbstractCasFilter {
|
|||
} catch (final ValidationException e) {
|
||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||
log.warn(e, e);
|
||||
throw new ServletException(e);
|
||||
|
||||
if (this.exceptionOnValidationFailure) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.redirectAfterValidation) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue