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