I general, I think it would be best to have this entire method be re-factored to only use a RequestMatcher to determine if the Gateway Exception is thrown. This makes it completely pluggable. You would thus move the GatewayResolver as a member of a custom RequestMatcher (i.e. DefaultCasGatewayRequestMatcher...perhaps you can think on that name and make it better though).