1 /************************************************************************
2 * Copyright (c) 2000-2006 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: 450935 $
29 */
30
31 public class DefaultJamesUser
32 extends DefaultUser
33 implements JamesUser, Initializable {
34
35 private static final long serialVersionUID = 6323959976390389529L;
36
37 /***
38 * Whether forwarding is enabled for this user.
39 */
40 private boolean forwarding;
41
42 /***
43 * The mail address to which this user's email is forwarded.
44 */
45 private MailAddress forwardingDestination;
46
47 /***
48 * Is this user an alias for another username on the system.
49 */
50 private boolean aliasing;
51
52
53 /***
54 * The user name that this user name is aliasing.
55 */
56 private String alias;
57
58 public DefaultJamesUser(String name, String alg) {
59 super(name, alg);
60 }
61
62 public DefaultJamesUser(String name, String passwordHash, String hashAlg) {
63 super(name, passwordHash, hashAlg);
64 }
65
66
67 /***
68 * @see org.apache.avalon.framework.activity.Initializable#initialize()
69 */
70 public void initialize() {
71 forwarding = false;
72 forwardingDestination = null;
73 aliasing = false;
74 alias = "";
75 }
76
77 /***
78 * Set whether mail to this user is to be forwarded to another
79 * email address
80 *
81 * @param forward whether mail is forwarded
82 */
83 public void setForwarding(boolean forward) {
84 forwarding = forward;
85 }
86
87 /***
88 * Get whether mail to this user is to be forwarded to another
89 * email address.
90 *
91 * @return forward whether mail is forwarded
92 */
93 public boolean getForwarding() {
94 return forwarding;
95 }
96
97
98 /***
99 * Set the destination address to which mail to this user
100 * will be forwarded.
101 *
102 * @param address the forward-to address
103 */
104 public boolean setForwardingDestination(MailAddress address) {
105
106 forwardingDestination = address;
107 return true;
108 }
109
110 /***
111 * Get the destination address to which mail to this user
112 * will be forwarded.
113 *
114 * @return the forward-to address
115 */
116 public MailAddress getForwardingDestination() {
117 return forwardingDestination;
118 }
119
120 /***
121 * Set whether this user id is an alias.
122 *
123 * @param alias whether this id is an alias
124 */
125 public void setAliasing(boolean alias) {
126 aliasing = alias;
127 }
128
129 /***
130 * Get whether this user id is an alias.
131 *
132 * @return whether this id is an alias
133 */
134 public boolean getAliasing() {
135 return aliasing;
136 }
137
138 /***
139 * Set the user id for which this id is an alias.
140 *
141 * @param address the user id for which this id is an alias
142 */
143 public boolean setAlias(String address) {
144
145 alias = address;
146 return true;
147 }
148
149 /***
150 * Get the user id for which this id is an alias.
151 *
152 * @return the user id for which this id is an alias
153 */
154 public String getAlias() {
155 return alias;
156 }
157 }