Also, just remembered something; the java cas client supports the concept of pluggable redirection strategies via an interface. All this code should be encapsulated into a redirection strategy.