KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > security > jauth > HttpServletAuthParam


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.security.jauth;
25
26 import javax.servlet.http.HttpServletRequest JavaDoc;
27 import javax.servlet.http.HttpServletResponse JavaDoc;
28
29 /**
30  * An HTTP Servlet authentication parameter that encapsulates
31  * HTTP Servlet request and response objects.
32  *
33  * <p> HttpServletAuthParam may be created with null request or response
34  * objects. The following table describes when it is appropriate to pass null:
35  *
36  * <pre>
37  * Request Response
38  * ------- --------
39  *
40  * ClientAuthModule.secureRequest non-null null
41  * ClientAuthModule.validateResponse null non-null
42  *
43  * ServerAuthModule.validateRequest non-null null
44  * ServerAuthModule.secureResponse null non-null
45  * </pre>
46  *
47  * <p> As noted above, in the case of
48  * <code>ServerAuthModule.validateRequest</code> the module receives
49  * a null response object. If the implementation of
50  * <code>validateRequest</code> encounters an authentication error,
51  * it may construct the appropriate response object itself and set it
52  * into the HttpServletAuthParam via the <code>setResponse</code> method.
53  *
54  * @version %I%, %G%
55  */

56 public class HttpServletAuthParam implements AuthParam {
57
58     private HttpServletRequest JavaDoc request;
59     private HttpServletResponse JavaDoc response;
60     //private static final MessageLayer layer =
61
// new MessageLayer(MessageLayer.HTTP_SERVLET);
62

63     /**
64      * Create an HTTPServletAuthParam with HTTP request and response objects.
65      *
66      * @param request the HTTP Servlet request object, or null.
67      * @param response the HTTP Servlet response object, or null.
68      */

69     public HttpServletAuthParam(HttpServletRequest JavaDoc request,
70                 HttpServletResponse JavaDoc response) {
71     this.request = request;
72     this.response = response;
73     }
74
75     /**
76      * Get the HTTP Servlet request object.
77      *
78      * @return the HTTP Servlet request object, or null.
79      */

80     public HttpServletRequest JavaDoc getRequest() {
81     return this.request;
82     }
83
84     /**
85      * Get the HTTP Servlet response object.
86      *
87      * @return the HTTP Servlet response object, or null.
88      */

89     public HttpServletResponse JavaDoc getResponse() {
90     return this.response;
91     }
92
93     /**
94      * Set a new HTTP Servlet response object.
95      *
96      * <p> If a response has already been set (it is non-null),
97      * this method returns. The original response is not overwritten.
98      *
99      * @param response the HTTP Servlet response object.
100      *
101      * @exception IllegalArgumentException if the specified response is null.
102      */

103     public void setResponse(HttpServletResponse JavaDoc response) {
104     if (response == null) {
105         throw new IllegalArgumentException JavaDoc("invalid null response");
106     }
107
108     if (this.response == null) {
109         this.response = response;
110     }
111     }
112
113     /**
114      * Get a MessageLayer instance that identifies HttpServlet
115      * as the message layer.
116      *
117      * @return a MessageLayer instance that identifies HttpServlet
118      * as the message layer.
119      */

120     //public MessageLayer getMessageLayer() {
121
// return layer;
122
//};
123

124     /**
125      * Get the operation related to the encapsulated HTTP Servlet
126      * request and response objects.
127      *
128      * @return the operation related to the encapsulated request and response
129      * objects, or null.
130      */

131     public String JavaDoc getOperation() {
132     return null;
133     }
134 }
135
Popular Tags