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.api.vut.management;
23
24 import java.util.Collection;
25 import java.util.Map;
26
27 import org.apache.james.api.vut.VirtualUserTable;
28
29 public interface VirtualUserTableManagement extends VirtualUserTable{
30
31 /**
32 * The component role used by components implementing this service
33 */
34 public static final String ROLE = "org.apache.james.api.vut.management.VirtualUserTableManagement";
35
36 /**
37 * Add regex mapping
38 *
39 * @param user the username. Null if no username should be used
40 * @param domain the domain. Null if no domain should be used
41 * @param regex the regex.
42 * @return true if successfully
43 * @throws InvalidMappingException get thrown if an invalid argument was given
44 */
45 public boolean addRegexMapping(String user, String domain, String regex) throws InvalidMappingException;
46
47 /**
48 * Remove regex mapping
49 *
50 * @param user the username. Null if no username should be used
51 * @param domain the domain. Null if no domain should be used
52 * @param regex the regex.
53 * @return true if successfully
54 * @throws InvalidMappingException get thrown if an invalid argument was given
55 */
56 public boolean removeRegexMapping(String user,String domain, String regex) throws InvalidMappingException;
57
58 /***
59 * Add address mapping
60 *
61 * @param user the username. Null if no username should be used
62 * @param domain the domain. Null if no domain should be used
63 * @param address
64 * @return true if successfully
65 * @throws InvalidMappingException get thrown if an invalid argument was given
66 */
67 public boolean addAddressMapping(String user, String domain, String address) throws InvalidMappingException;
68
69 /**
70 * Remove address mapping
71 *
72 * @param user the username. Null if no username should be used
73 * @param domain the domain. Null if no domain should be used
74 * @param address
75 * @return true if successfully
76 * @throws InvalidMappingException get thrown if an invalid argument was given
77 */
78 public boolean removeAddressMapping(String user,String domain, String address) throws InvalidMappingException;
79
80 /**
81 * Add error mapping
82 *
83 * @param user the username. Null if no username should be used
84 * @param domain the domain. Null if no domain should be used
85 * @param error the regex.
86 * @return true if successfully
87 * @throws InvalidMappingException get thrown if an invalid argument was given
88 */
89 public boolean addErrorMapping(String user, String domain, String error) throws InvalidMappingException;
90
91 /**
92 * Remove error mapping
93 *
94 * @param user the username. Null if no username should be used
95 * @param domain the domain. Null if no domain should be used
96 * @param error
97 * @return true if successfully
98 * @throws InvalidMappingException get thrown if an invalid argument was given
99 */
100 public boolean removeErrorMapping(String user,String domain, String error) throws InvalidMappingException;
101
102 /**
103 * Return the explicit mapping stored for the given user and domain. Return null
104 * if no mapping was found
105 *
106 * @param user the username
107 * @param domain the domain
108 * @return the collection which holds the mappings.
109 * @throws InvalidMappingException get thrown if an invalid use or domain was given
110 */
111 public Collection getUserDomainMappings(String user, String domain) throws InvalidMappingException;
112
113 /**
114 * Add mapping
115 *
116 * @param user the username. Null if no username should be used
117 * @param domain the domain. Null if no domain should be used
118 * @param mapping the mapping
119 * @return true if successfully
120 * @throws InvalidMappingException
121 */
122 public boolean addMapping(String user, String domain, String mapping) throws InvalidMappingException;
123
124 /**
125 * Remove mapping
126 *
127 * @param user the username. Null if no username should be used
128 * @param domain the domain. Null if no domain should be used
129 * @param mapping the mapping
130 * @return true if successfully
131 * @throws InvalidMappingException
132 */
133 public boolean removeMapping(String user, String domain, String mapping) throws InvalidMappingException;
134
135
136 /**
137 * Return a Map which holds all mappings. The key is the user@domain and the value is a Collection
138 * which holds all mappings
139 *
140 * @return Map which holds all mappings
141 */
142 public Map getAllMappings();
143
144 /**
145 * Add aliasDomain mapping
146 *
147 * @param aliasDomain the aliasdomain which should be mapped to the realDomain
148 * @param realDomain the realDomain
149 * @return true if successfilly
150 * @throws InvalidMappingException
151 */
152 public boolean addAliasDomainMapping(String aliasDomain, String realDomain) throws InvalidMappingException;
153
154 /**
155 * Remove aliasDomain mapping
156 *
157 * @param aliasDomain the aliasdomain which should be mapped to the realDomain
158 * @param realDomain the realDomain
159 * @return true if successfilly
160 * @throws InvalidMappingException
161 */
162 public boolean removeAliasDomainMapping(String aliasDomain, String realDomain) throws InvalidMappingException;
163 }