001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.userrepository;
019:
020: import org.apache.avalon.framework.activity.Initializable;
021: import org.apache.james.services.JamesUser;
022: import org.apache.mailet.MailAddress;
023:
024: /**
025: * Implementation of User Interface.
026: *
027: *
028: * @version $Revision: 494012 $
029: */
030:
031: public class DefaultJamesUser extends DefaultUser implements JamesUser,
032: Initializable {
033:
034: private static final long serialVersionUID = 6323959976390389529L;
035:
036: /**
037: * Whether forwarding is enabled for this user.
038: */
039: private boolean forwarding;
040:
041: /**
042: * The mail address to which this user's email is forwarded.
043: */
044: private MailAddress forwardingDestination;
045:
046: /**
047: * Is this user an alias for another username on the system.
048: */
049: private boolean aliasing;
050:
051: /**
052: * The user name that this user name is aliasing.
053: */
054: private String alias;
055:
056: public DefaultJamesUser(String name, String alg) {
057: super (name, alg);
058: }
059:
060: public DefaultJamesUser(String name, String passwordHash,
061: String hashAlg) {
062: super (name, passwordHash, hashAlg);
063: }
064:
065: /**
066: * @see org.apache.avalon.framework.activity.Initializable#initialize()
067: */
068: public void initialize() {
069: forwarding = false;
070: forwardingDestination = null;
071: aliasing = false;
072: alias = "";
073: }
074:
075: /**
076: * Set whether mail to this user is to be forwarded to another
077: * email address
078: *
079: * @param forward whether mail is forwarded
080: */
081: public void setForwarding(boolean forward) {
082: forwarding = forward;
083: }
084:
085: /**
086: * Get whether mail to this user is to be forwarded to another
087: * email address.
088: *
089: * @return forward whether mail is forwarded
090: */
091: public boolean getForwarding() {
092: return forwarding;
093: }
094:
095: /**
096: * Set the destination address to which mail to this user
097: * will be forwarded.
098: *
099: * @param address the forward-to address
100: */
101: public boolean setForwardingDestination(MailAddress address) {
102: /* TODO: Some verification would be good */
103: forwardingDestination = address;
104: return true;
105: }
106:
107: /**
108: * Get the destination address to which mail to this user
109: * will be forwarded.
110: *
111: * @return the forward-to address
112: */
113: public MailAddress getForwardingDestination() {
114: return forwardingDestination;
115: }
116:
117: /**
118: * Set whether this user id is an alias.
119: *
120: * @param alias whether this id is an alias
121: */
122: public void setAliasing(boolean alias) {
123: aliasing = alias;
124: }
125:
126: /**
127: * Get whether this user id is an alias.
128: *
129: * @return whether this id is an alias
130: */
131: public boolean getAliasing() {
132: return aliasing;
133: }
134:
135: /**
136: * Set the user id for which this id is an alias.
137: *
138: * @param address the user id for which this id is an alias
139: */
140: public boolean setAlias(String address) {
141: /* TODO: Some verification would be good */
142: alias = address;
143: return true;
144: }
145:
146: /**
147: * Get the user id for which this id is an alias.
148: *
149: * @return the user id for which this id is an alias
150: */
151: public String getAlias() {
152: return alias;
153: }
154: }
|