KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.servlet.http.HttpServletResponse JavaDoc;
21 import java.io.IOException JavaDoc;
22
23
24 /**
25  * Exception thrown when:
26  * <ul>
27  * <li>
28  * An action ({@link org.apache.beehive.netui.pageflow.annotations.Jpf.Action &#64;Jpf.Action}
29  * or {@link org.apache.beehive.netui.pageflow.annotations.Jpf.SimpleAction &#64;Jpf.SimpleAction})
30  * marked with <code>loginRequired=true</code> is hit when there is no logged-in user, or,
31  * </li>
32  * <li>
33  * An action marked with <code>rolesAllowed="</code><i>list of roles</i><code>"</code> is hit when there is
34  * no logged-in user.
35  * </li>
36  * </ul>
37  * If the requested session-ID is different than the current session-ID, the {@link LoginExpiredException}
38  * will be thrown instead of the <code>NotLoggedInException</code>.
39  */

40 public class NotLoggedInException
41         extends PageFlowException
42         implements ResponseErrorCodeSender
43 {
44     public NotLoggedInException( String JavaDoc actionName, FlowController fc )
45     {
46         super( actionName, fc );
47     }
48
49     protected Object JavaDoc[] getMessageArgs()
50     {
51         return new Object JavaDoc[]{ getActionName(), getFlowControllerURI() };
52     }
53
54     public String JavaDoc[] getMessageParts()
55     {
56         return new String JavaDoc[]
57         {
58             "Action ", " on page flow ", " requires a current user, but there is no logged-in user."
59         };
60     }
61
62     public void sendResponseErrorCode( HttpServletResponse JavaDoc response ) throws IOException JavaDoc
63     {
64         response.sendError( HttpServletResponse.SC_BAD_REQUEST, getLocalizedMessage() );
65     }
66
67     /**
68      * Tell whether the root cause may be session expiration in cases where the requested session ID is different than
69      * the actual session ID. In this case, the answer is <code>true</code>.
70      */

71     public boolean causeMayBeSessionExpiration()
72     {
73         return true;
74     }
75 }
76
Popular Tags