KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > userrepository > DefaultJamesUser


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.userrepository;
19
20 import org.apache.avalon.framework.activity.Initializable;
21 import org.apache.james.services.JamesUser;
22 import org.apache.mailet.MailAddress;
23
24 /**
25  * Implementation of User Interface.
26  *
27  *
28  * @version $Revision: 1.6.4.3 $
29  */

30
31 public class DefaultJamesUser
32         extends DefaultUser
33         implements JamesUser, Initializable {
34
35     /**
36      * Whether forwarding is enabled for this user.
37      */

38     private boolean forwarding;
39
40     /**
41      * The mail address to which this user's email is forwarded.
42      */

43     private MailAddress forwardingDestination;
44
45     /**
46      * Is this user an alias for another username on the system.
47      */

48     private boolean aliasing;
49
50
51     /**
52      * The user name that this user name is aliasing.
53      */

54     private String JavaDoc alias;
55
56     public DefaultJamesUser(String JavaDoc name, String JavaDoc alg) {
57         super(name, alg);
58     }
59
60     public DefaultJamesUser(String JavaDoc name, String JavaDoc passwordHash, String JavaDoc hashAlg) {
61         super(name, passwordHash, hashAlg);
62     }
63
64
65     /**
66      * @see org.apache.avalon.framework.activity.Initializable#initialize()
67      */

68     public void initialize() {
69         forwarding = false;
70         forwardingDestination = null;
71         aliasing = false;
72         alias = "";
73     }
74
75     /**
76      * Set whether mail to this user is to be forwarded to another
77      * email address
78      *
79      * @param forward whether mail is forwarded
80      */

81     public void setForwarding(boolean forward) {
82         forwarding = forward;
83     }
84
85     /**
86      * Get whether mail to this user is to be forwarded to another
87      * email address.
88      *
89      * @return forward whether mail is forwarded
90      */

91     public boolean getForwarding() {
92         return forwarding;
93     }
94
95     
96     /**
97      * Set the destination address to which mail to this user
98      * will be forwarded.
99      *
100      * @param address the forward-to address
101      */

102     public boolean setForwardingDestination(MailAddress address) {
103         /* TODO: Some verification would be good */
104         forwardingDestination = address;
105         return true;
106     }
107
108     /**
109      * Get the destination address to which mail to this user
110      * will be forwarded.
111      *
112      * @return the forward-to address
113      */

114     public MailAddress getForwardingDestination() {
115         return forwardingDestination;
116     }
117
118     /**
119      * Set whether this user id is an alias.
120      *
121      * @param alias whether this id is an alias
122      */

123     public void setAliasing(boolean alias) {
124         aliasing = alias;
125     }
126
127     /**
128      * Get whether this user id is an alias.
129      *
130      * @return whether this id is an alias
131      */

132     public boolean getAliasing() {
133         return aliasing;
134     }
135
136     /**
137      * Set the user id for which this id is an alias.
138      *
139      * @param address the user id for which this id is an alias
140      */

141     public boolean setAlias(String JavaDoc address) {
142         /* TODO: Some verification would be good */
143         alias = address;
144         return true;
145     }
146
147     /**
148      * Get the user id for which this id is an alias.
149      *
150      * @return the user id for which this id is an alias
151      */

152     public String JavaDoc getAlias() {
153         return alias;
154     }
155 }
156
Popular Tags