File: README.html

package info (click to toggle)
jersey1 1.19.3-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,944 kB
  • sloc: java: 158,166; xml: 31,914; jsp: 330; python: 42; sh: 17; makefile: 8
file content (164 lines) | stat: -rw-r--r-- 8,223 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    http://glassfish.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->
<html><head><title>HTTPS Server GlassFish Example</title></head>

  <body>
      <h1>HTTPS Server Example - GlassFish</h1>
      
      <p>This example demonstrates how to develop secure RESTful hello world web service with a Servlet 2.5 container.</p>
      
      <h2>Contents</h2>
      <p>The example consists of just one Java class:</p>
      <dl>
          <dt><code>com.sun.jersey.samples.helloworldwebapp.resources.HelloWorldResource</code></dt>
          <dd>A resource class that produces a textual response to an HTTP GET.</dd>
      </dl>
    <p>The mapping of the URI path space is presented in the following table:</p>
	<table border="1">
	<tr>
	<th>URI path</th>
	<th>Resource class</th>
	<th>HTTP methods</th>
	</tr>
	<tr>
	<td>/helloworld</td>
	<td>HelloWorldResource</td>
	<td>GET</td>
	</tr>
	</table>

      <h2>Running the Example</h2>
      <p>Run the example as follows:</p>
      <p> create war package</p>
      <blockquote><code>mvn clean package</code><p></blockquote>

      <p> setup GlassFish 3.1 (installed at <code>AS_HOME=&lt;install_dir&gt;/glassfish</code>):
      <ul>
          <li>Add new security realm called "<code>myRealm</code>"</li>
          <ul>
              <li>Start GlassFish using asadmin <code>$AS_HOME/bin/asadmin start-domain</code> </li>
              <li>Access Admin console, assuming the use of default admin port, here <a href="http://localhost:4848">http://localhost:4848</a></li>
              <li>Navigate in Admin console to: <code>Configurations -&gt; server-config -&gt; Security -&gt; Realms</code>, click on "<code>New...</code>"</li>
              <table border="1px">
                  <tr><th>Name</th><td><code>myRealm</code></td></tr>
                  <tr><th>Class Name</th><td><code>com.sun.enterprise.security.auth.realm.file.FileRealm</code></td></tr>
                  <tr><th>JAAS context</th><td><code>fileRealm</code></td></tr>
                  <tr><th>Key File</th><td><code>${com.sun.aas.instanceRoot}/config/myRealm-keyfile</code></td></tr>
              </table>
              <li>Create user and set password for user <code>myUser</code> (click on "<code>myRealm</code>", "<code>Manage Users</code>", "<code>New...</code>");
				  <ul>
					  <li><strong>Ensure</strong> "<code>User ID:</code>" set to "<code>myUser</code>" <strong>and</strong> "<code>Group List:</code>" set to "<code>Users</code>"</li>
					  <li>Enter password <strong><code>myPass</code></strong> in "<code>New Password:</code>" and "<code>Confirm New Password:</code>" text fields</li>
				  </ul>
			  </li>
              <li>Add one other user name <code>joeUser</code> (click on "<code>myRealm</code>", "<code>Manage Users</code>", "<code>New...</code>");
				  <ul>
					  <li><strong>Ensure</strong> "<code>User ID:</code>" set to "<code>joeUser</code>" <strong>and</strong> "<code>Group List:</code>" set to "<code>Users</code>"</li>
					  <li>Enter password <strong><code>joePass</code></strong> in "<code>New Password:</code>" and "<code>Confirm New Password:</code>" text fields</li>
		  		  </ul>
          </ul>
          <li>Check <code>web.xml</code> and <code>sun-web.xml</code> to understand how role mappings are configured.  This blog is also helpful to clarify role mappings <a href="http://blogs.oracle.com/bobby/entry/simplified_security_role_mapping">http://blogs.oracle.com/bobby/entry/simplified_security_role_mapping</a> </li>
          <li>Deploy <code>httpsBasicAuth-webapp.war</code> as a Web Application</li>
          <ul>
              <li>Admin console: select <code>Applications</code>, click on "<code>Deploy...</code>". Select file <code>./target/httpsBasicAuth-webapp.war</code></li>
              <li>or you can use command line: <code>$AS_HOME/bin/asadmin deploy ./target/httpsBasicAuth-webapp.war</code></li>
          </ul>

      </ul>

	  <p>From a web browser, visit:</p>
	  <blockquote><code><a href="https://localhost:8181/httpsBasicAuth-webapp/helloworld">https://localhost:8181/httpsBasicAuth-webapp/helloworld</a></code>
		  (you have to add security exception for GlassFish server certificate / ignore all warnings about security)
	  </blockquote>
	  <ul>
		  <li>Enter either Username <code>myUser</code> and Password <code>myPass</code> or, Username
			  <code>joeUser</code> and Password <code>joePass</code></li>
		  <li> If entered Username <code>myUser</code> and Password <code>myPass</code>, verify that <b>expected
			  output</b>: <code>Sending "Hello World" to user "myUser"</code> was displayed
		  </li>
		  <li> If entered Username <code>joeUser</code> and Password <code>joePass</code>, verify that <b>expected
			  output</b>: <code>Sending "Hello World" to user "joeUser"</code> was displayed
		  </li>
	  </ul>

	  <h2>Running the Negative Example</h2>

	  <p>Run the example as follows:</p>
	  <p> create war package</p>
	  <blockquote><code>mvn clean package</code><p></blockquote>

	  <p>setup GlassFish 3.1 (installed at <code>AS_HOME=&lt;install_dir&gt;/glassfish</code>):</p>
	  <ul>
		  <li>
			  Follow the steps described in the "<strong>setup GlassFish 3.1</strong>" section from the previous chapter "<strong>Running the Example</strong>"
			  but instead of adding the user "<code>joeUser</code>" to the "<code>Group List:</code>" of "<code>Users</code>" set
			  "<code>Group List:</code>" for this user to "<code>OtherUsers</code>"
		  </li>
	  </ul>

	  <p>From a web browser, visit:</p>
	  <blockquote><code><a href="https://localhost:8181/httpsBasicAuth-webapp/helloworld">https://localhost:8181/httpsBasicAuth-webapp/helloworld</a></code>
		  (you have to add security exception for GlassFish server certificate / ignore all warnings about security)
	  </blockquote>
	  <ul>
		  <li>Enter Username <code>joeUser</code> and Password <code>joePass</code>, verify that <b>expected
			  output</b> looks like: <code>HTTP Status 403 - Access to the requested resource has been denied</code>
		  </li>
	  </ul>



 </body></html>


 <!--

 Resources:
 http://java.sun.com/developer/technicalArticles/J2EE/security_annotation/
 http://www.ryandelaplante.com/rdelaplante/entry/ssl_and_http_basic_authentication

-->