KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > ServletContainerAdapter


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.pageflow;
19
20 import org.apache.beehive.netui.pageflow.adapter.Adapter;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24 import javax.security.auth.login.LoginException JavaDoc;
25
26
27 /**
28  * Adapter interface for plugging into various Servlet containers. An implementor of this interface is "discovered" at
29  * runtime. The discovery process is as follows:
30  * <ul>
31  * <li>
32  * A list of META-INF/services/org.apache.beehive.netui.pageflow.ServletContainerAdapter resources is obtained
33  * from classpath. This means, for example, that a file called
34  * "org.apache.beehive.netui.pageflow.ServletContainerAdapter" under directory META-INF/services would be
35  * found inside any JAR file on classpath.
36  * </li>
37  * <li>
38  * Inside each of these resources is the name of a class that implements ServletContainerAdapter. This class
39  * is loaded, and its {@link #accept} method is called.
40  * </li>
41  * <li>
42  * If {@link #accept} returns <code>true</code>, then that implementation class is chosen as the current
43  * adapter; otherwise, the next one in the list is tried.
44  * </li>
45  * <li>If no adapters are discovered, an instance of {@link DefaultServletContainerAdapter} is used.
46  * </ul>
47  */

48 public interface ServletContainerAdapter
49         extends Adapter
50 {
51     /**
52      * Tell whether the server is running in production mode.
53      * @return <code>true</code> if the server is running in production mode.
54      */

55     public boolean isInProductionMode();
56     
57     /**
58      * Tell whether a web application resource requires a secure transport protocol. This is
59      * determined from web.xml; for example, the following block specifies that all resources under
60      * /login require a secure transport protocol.
61      * <pre>
62      * &lt;security-constraint&gt;
63      * &lt;web-resource-collection&gt;
64      * &lt;web-resource-name&gt;Secure PageFlow - begin&lt;/web-resource-name&gt;
65      * &lt;url-pattern&gt;/login/*&lt;/url-pattern&gt;
66      * &lt;/web-resource-collection&gt;
67      * &lt;user-data-constraint&gt;
68      * &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
69      * &lt;/user-data-constraint&gt;
70      * &lt;/security-constraint&gt;
71      * </pre>
72      *
73      * @param path a webapp-relative path for a resource.
74      * @param request the current HttpServletRequest.
75      * @return <code>Boolean.TRUE</code> if a transport-guarantee of <code>CONFIDENTIAL</code> or
76      * <code>INTEGRAL</code> is associated with the given resource; <code>Boolean.FALSE</code>
77      * a transport-guarantee of <code>NONE</code> is associated with the given resource; or
78      * <code>null</code> if there is no transport-guarantee associated with the given resource.
79      */

80     public SecurityProtocol getSecurityProtocol( String JavaDoc path, HttpServletRequest JavaDoc request );
81
82     /**
83      * Cause the server to do a security check for the given path. If required, it does a redirect to
84      * change the scheme (http/https).
85      *
86      * @param path the webapp-relative path on which to run security checks.
87      * @param request the current HttpServletRequest.
88      * @param response the current HttpServletResponse.
89      * @return <code>true</code> if a redirect occurred.
90      */

91     boolean doSecurityRedirect( String JavaDoc path, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response );
92                            
93     
94     /**
95      * Get the port on which the server is listening for unsecure connections.
96      *
97      * @param request the current HttpServletRequest.
98      * @return the port on which the server is listening for unsecure connections.
99      */

100     public int getListenPort( HttpServletRequest JavaDoc request );
101
102     /**
103      * Get the port on which the server is listening for secure connections.
104      *
105      * @param request the current HttpServletRequest.
106      * @return the port on which the server is listening for secure connections.
107      */

108     public int getSecureListenPort( HttpServletRequest JavaDoc request );
109
110     /**
111      * Log in the user, using "weak" username/password authentication.
112      *
113      * @param username the user's login name.
114      * @param password the user's password.
115      * @param request the current HttpServletRequest.
116      * @param response the current HttpServletResponse.
117      *
118      * @exception LoginException if the authentication failed
119      */

120     public void login( String JavaDoc username, String JavaDoc password, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response )
121         throws LoginException JavaDoc;
122     
123     /**
124      * Log out the current user.
125      *
126      * @param invalidateSessions if <code>true</code>, the session is invalidated (on all single-signon webapps);
127      * otherwise the session and its data are left intact. To invalidate the session in only the
128      * current webapp, set this parameter to <code>false</code> and call invalidate() on the HttpSession.
129      * @param request the current HttpServletRequest.
130      * @param response the current HttpServletResponse.
131      */

132     public void logout( boolean invalidateSessions, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response );
133     
134     /**
135      * Return the webapp context path for the given request. This differs from HttpServletRequest.getContextPath()
136      * only in that it will return a valid value even if the request is for the default webapp.
137      *
138      * @param request the current HttpServletRequest.
139      */

140     public String JavaDoc getFullContextPath( HttpServletRequest JavaDoc request );
141     
142     /**
143      * Ensure that the given session attribute is replicated in a cluster for session failover.
144      * This method does not need to be implemented for servers that do not support clustering and
145      * session failover.
146      *
147      * @param attrName the name of the session attribute for which failover should be ensured.
148      * @param attrVal the value of the given session attribute.
149      * @param request the current HttpServletRequest.
150      */

151     public void ensureFailover( String JavaDoc attrName, Object JavaDoc attrVal, HttpServletRequest JavaDoc request );
152     
153     /**
154      * Called at the beginning of each processed request.
155      *
156      * @param request the current HttpServletRequest.
157      * @param response the current HttpServletResponse.
158      */

159     public void beginRequest( HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response );
160     
161     /**
162      * Called at the end of each processed request.
163      *
164      * @param request the current HttpServletRequest.
165      * @param response the current HttpServletResponse.
166      */

167     public void endRequest( HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response );
168     
169     /**
170      * Get a context object to support Beehive Controls.
171      *
172      * @param request the current HttpServletRequest.
173      * @param response the current HttpServletResponse.
174      * @return a new ControlBeanContext.
175      */

176     public Object JavaDoc createControlBeanContext( HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response );
177     
178     /**
179      * Get the name of the platform, which may be used to find platform-specific configuration files.
180      *
181      * @return the name of the platform
182      */

183     public String JavaDoc getPlatformName();
184     
185     /**
186      * Get an event reporter, which will be notified of events like "page flow created", "action raised", etc.
187      */

188     public PageFlowEventReporter getEventReporter();
189 }
190
Popular Tags