What you need is spring-security.
It supports both OpenID and CAS out of the box, but you'll need to do some research on your own on those.
If you need just basic SSO functionality I can recommend just implementing your own UsernamePasswordAuthenticationFilter
and/or AbstractPreAuthenticatedProcessingFilter
and using cookies. This answer will help you do that.
You also should have a look at the spring-security docs and then ask a more specific question if you need to.