KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > imapserver > ImapSessionImpl


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

17
18 package org.apache.james.imapserver;
19
20 import org.apache.avalon.framework.logger.AbstractLogEnabled;
21 import org.apache.avalon.framework.logger.Logger;
22 import org.apache.james.services.User;
23 import org.apache.james.services.UsersRepository;
24 import org.apache.james.imapserver.store.ImapMailbox;
25
26 /**
27  *
28  *
29  * @version $Revision: 1.1.2.3 $
30  */

31 public final class ImapSessionImpl implements ImapSession
32 {
33     private ImapSessionState state = ImapSessionState.NON_AUTHENTICATED;
34     private User user = null;
35     private ImapMailbox selectedMailbox = null;
36     // TODO: Use a session-specific wrapper for user's view of mailbox
37
// this wrapper would provide access control and track if the mailbox
38
// is opened read-only.
39
private boolean selectedIsReadOnly = false;
40
41     private String JavaDoc clientHostName;
42     private String JavaDoc clientAddress;
43
44     // TODO these shouldn't be in here - they can be provided directly to command components.
45
private ImapHandler handler;
46     private ImapHost imapHost;
47     private UsersRepository users;
48
49     public ImapSessionImpl( ImapHost imapHost,
50                             UsersRepository users,
51                             ImapHandler handler,
52                             String JavaDoc clientHostName,
53                             String JavaDoc clientAddress )
54     {
55         this.imapHost = imapHost;
56         this.users = users;
57         this.handler = handler;
58         this.clientHostName = clientHostName;
59         this.clientAddress = clientAddress;
60     }
61
62     public ImapHost getHost()
63     {
64         return imapHost;
65     }
66
67     public void unsolicitedResponses( ImapResponse request )
68     {
69     }
70
71     public void closeConnection()
72     {
73         handler.resetHandler();
74     }
75
76     public UsersRepository getUsers()
77     {
78         return users;
79     }
80
81     public String JavaDoc getClientHostname()
82     {
83         return clientHostName;
84     }
85
86     public String JavaDoc getClientIP()
87     {
88         return clientAddress;
89     }
90
91     public void setAuthenticated( User user )
92     {
93         this.state = ImapSessionState.AUTHENTICATED;
94         this.user = user;
95     }
96
97     public User getUser()
98     {
99         return this.user;
100     }
101
102     public void deselect()
103     {
104         this.state = ImapSessionState.AUTHENTICATED;
105     }
106
107     public void setSelected( ImapMailbox mailbox, boolean readOnly )
108     {
109         this.state = ImapSessionState.SELECTED;
110         this.selectedMailbox = mailbox;
111         this.selectedIsReadOnly = readOnly;
112     }
113
114     public ImapMailbox getSelected()
115     {
116         return this.selectedMailbox;
117     }
118
119     public boolean selectedIsReadOnly()
120     {
121         return this.selectedIsReadOnly;
122     }
123
124     public ImapSessionState getState()
125     {
126         return this.state;
127     }
128 }
129
Popular Tags