1 /*****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 ****************************************************************/
19
20 package org.apache.james.userrepository;
21
22 import org.apache.avalon.framework.activity.Initializable;
23 import org.apache.james.services.JamesUser;
24 import org.apache.mailet.MailAddress;
25
26 /***
27 * Implementation of User Interface.
28 *
29 *
30 * @version $Revision: 494012 $
31 */
32
33 public class DefaultJamesUser
34 extends DefaultUser
35 implements JamesUser, Initializable {
36
37 private static final long serialVersionUID = 6323959976390389529L;
38
39 /***
40 * Whether forwarding is enabled for this user.
41 */
42 private boolean forwarding;
43
44 /***
45 * The mail address to which this user's email is forwarded.
46 */
47 private MailAddress forwardingDestination;
48
49 /***
50 * Is this user an alias for another username on the system.
51 */
52 private boolean aliasing;
53
54
55 /***
56 * The user name that this user name is aliasing.
57 */
58 private String alias;
59
60 public DefaultJamesUser(String name, String alg) {
61 super(name, alg);
62 }
63
64 public DefaultJamesUser(String name, String passwordHash, String hashAlg) {
65 super(name, passwordHash, hashAlg);
66 }
67
68
69 /***
70 * @see org.apache.avalon.framework.activity.Initializable#initialize()
71 */
72 public void initialize() {
73 forwarding = false;
74 forwardingDestination = null;
75 aliasing = false;
76 alias = "";
77 }
78
79 /***
80 * Set whether mail to this user is to be forwarded to another
81 * email address
82 *
83 * @param forward whether mail is forwarded
84 */
85 public void setForwarding(boolean forward) {
86 forwarding = forward;
87 }
88
89 /***
90 * Get whether mail to this user is to be forwarded to another
91 * email address.
92 *
93 * @return forward whether mail is forwarded
94 */
95 public boolean getForwarding() {
96 return forwarding;
97 }
98
99
100 /***
101 * Set the destination address to which mail to this user
102 * will be forwarded.
103 *
104 * @param address the forward-to address
105 */
106 public boolean setForwardingDestination(MailAddress address) {
107
108 forwardingDestination = address;
109 return true;
110 }
111
112 /***
113 * Get the destination address to which mail to this user
114 * will be forwarded.
115 *
116 * @return the forward-to address
117 */
118 public MailAddress getForwardingDestination() {
119 return forwardingDestination;
120 }
121
122 /***
123 * Set whether this user id is an alias.
124 *
125 * @param alias whether this id is an alias
126 */
127 public void setAliasing(boolean alias) {
128 aliasing = alias;
129 }
130
131 /***
132 * Get whether this user id is an alias.
133 *
134 * @return whether this id is an alias
135 */
136 public boolean getAliasing() {
137 return aliasing;
138 }
139
140 /***
141 * Set the user id for which this id is an alias.
142 *
143 * @param address the user id for which this id is an alias
144 */
145 public boolean setAlias(String address) {
146
147 alias = address;
148 return true;
149 }
150
151 /***
152 * Get the user id for which this id is an alias.
153 *
154 * @return the user id for which this id is an alias
155 */
156 public String getAlias() {
157 return alias;
158 }
159 }