This example demonstrates how to develop secure RESTful hello world web service with a Servlet 2.5 container.
The example consists of just one Java class:
com.sun.jersey.samples.helloworldwebapp.resources.HelloWorldResource
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods |
---|---|---|
/helloworld | HelloWorldResource | GET |
Run the example as follows:
create war package
mvn clean package
setup GlassFish v2.x and v3:
Name | myRealm |
---|---|
Class Name | com.sun.enterprise.security.auth.realm.file.FileRealm |
JAAS context | fileRealm |
Key File | ${com.sun.aas.instanceRoot}/config/myRealm-keyfile |
/path/to/glassfishv2/glassfish/bin/asadmin deploy ./target/httpsBasicAuth-webapp.war
From a web browser, visit:
https://localhost:8181/httpsBasicAuth-webapp/helloworld
(you have to add security exception for GlassFish server certificate / ignore all warnings about security)