This example shows how Java EE 6 app (JBoss AS 7 resp. EAP 6.2) can be integrated with CAS Single Sign On server.
In Addition to the CAS integration it shows how to write simple JAAS Login Module.
Example demonstrates securing:
- JAX-RS REST via @PermitAll resp. @RolesAllowed annotations
- Servlet via @ServletSecurity
After deployment you get:
- / - main page with information about currently logged in user
- Filter which examine HTTP Basic authentication. If present then triggers JAAS login.
- /login/cas - single point for login to CAS server
- /secured-servlet - secured servlet via @ServletSecurity annotation
- /rest/test/public - public REST api
- /rest/test/secure - secured REST api
Test secured content without authentication
curl http://localhost:8080/rest/test/secure
output:
401
Test secured content with authentication
curl -u username:password http://localhost:8080/rest/test/secure
output:
OK, principal from security context: username
Test public content
curl http://localhost:8080/rest/test/public
output:
OK PUBLIC
Add Security Domain CasSecurityDomain
to AS. See JBoss AS 7 / EAP 6.2 example in .openshift/config/standalone.xml