KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > acting > SessionIsValidAction


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.acting;
17
18 import org.apache.avalon.framework.parameters.Parameters;
19 import org.apache.avalon.framework.thread.ThreadSafe;
20 import org.apache.cocoon.environment.ObjectModelHelper;
21 import org.apache.cocoon.environment.Redirector;
22 import org.apache.cocoon.environment.Request;
23 import org.apache.cocoon.environment.Session;
24 import org.apache.cocoon.environment.SourceResolver;
25
26 import java.util.Map JavaDoc;
27
28
29 /**
30  * This action just checks if a session exists and whether the current
31  * seesion is still valid.
32  *
33  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
34  * @version CVS $Id: SessionIsValidAction.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class SessionIsValidAction extends AbstractAction implements ThreadSafe
37 {
38     /**
39      * Main invocation routine.
40      */

41     public Map JavaDoc act (Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc src,
42             Parameters parameters) throws Exception JavaDoc {
43         Request req = ObjectModelHelper.getRequest(objectModel);
44
45         /* check session validity */
46         Session session = req.getSession (false);
47         if (session == null) {
48             if (this.getLogger().isDebugEnabled()) {
49                 getLogger().debug("No session object");
50             }
51             return null;
52         }
53         if (!req.isRequestedSessionIdValid()) {
54             if (this.getLogger().isDebugEnabled()) {
55                 getLogger().debug("Requested session id is invalid");
56             }
57             return null;
58         }
59
60         return EMPTY_MAP;
61     }
62 }
63
Popular Tags