View Javadoc

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  
21  
22  package org.apache.james.impl.user;
23  
24  import org.apache.james.api.user.JamesUser;
25  import org.apache.mailet.MailAddress;
26  
27  /**
28   * Implementation of User Interface.
29   *
30   *
31   * @version $Revision: 521427 $
32   */
33  
34  public class DefaultJamesUser 
35          extends DefaultUser
36          implements JamesUser {
37  
38      private static final long serialVersionUID = 6323959976390389529L;
39  
40      /**
41       * Whether forwarding is enabled for this user.
42       */
43      private boolean forwarding;
44  
45      /**
46       * The mail address to which this user's email is forwarded.
47       */
48      private MailAddress forwardingDestination;
49  
50      /**
51       * Is this user an alias for another username on the system.
52       */
53      private boolean aliasing;
54  
55  
56      /**
57       * The user name that this user name is aliasing.
58       */
59      private String alias;
60  
61      public DefaultJamesUser(String name, String alg) {
62          super(name, alg);
63          initialize();
64      }
65  
66      public DefaultJamesUser(String name, String passwordHash, String hashAlg) {
67          super(name, passwordHash, hashAlg);
68          initialize();
69      }
70  
71  
72      /**
73       * Initializes default values for local fields.
74       */
75      public void initialize() {
76          forwarding = false;
77          forwardingDestination = null;
78          aliasing = false;
79          alias = "";
80      }
81  
82      /**
83       * @see org.apache.james.api.user.JamesUser#setForwarding(boolean)
84       */
85      public void setForwarding(boolean forward) {
86          forwarding = forward;
87      }
88  
89      /**
90       * @see org.apache.james.api.user.JamesUser#getForwarding()
91       */
92      public boolean getForwarding() {
93          return forwarding;
94      }
95  
96      /**
97       * @see org.apache.james.api.user.JamesUser#setForwardingDestination(org.apache.mailet.MailAddress)
98       */
99      public boolean setForwardingDestination(MailAddress address) {
100         /* TODO: Some verification would be good */
101         forwardingDestination = address;
102         return true;
103     }
104 
105     /**
106      * @see org.apache.james.api.user.JamesUser#getForwardingDestination()
107      */
108     public MailAddress getForwardingDestination() {
109         return forwardingDestination;
110     }
111 
112     /**
113      * @see org.apache.james.api.user.JamesUser#setAliasing(boolean)
114      */
115     public void setAliasing(boolean alias) {
116         aliasing = alias;
117     }
118 
119     /**
120      * @see org.apache.james.api.user.JamesUser#getAliasing()
121      */
122     public boolean getAliasing() {
123         return aliasing;
124     }
125 
126     /**
127      * @see org.apache.james.api.user.JamesUser#setAlias(java.lang.String)
128      */
129     public boolean setAlias(String address) {
130         /* TODO: Some verification would be good */
131         alias = address;
132         return true;
133     }
134 
135     /**
136      * @see org.apache.james.api.user.JamesUser#getAlias()
137      */
138     public String getAlias() {
139         return alias;
140     }
141 }