nur erlaubte aliases anlegen

This commit is contained in:
Peter Hormanns 2011-05-20 14:12:39 +00:00
parent 73ba138ac4
commit 32e231850e
2 changed files with 18 additions and 2 deletions

View File

@ -79,10 +79,11 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
for (String queueName : mailServerQueues) { for (String queueName : mailServerQueues) {
relayDomainsProcessor = new CompoundProcessor( relayDomainsProcessor = new CompoundProcessor(
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
domName + " anything" + "\n." + domName + " anything"), domName + " anything\n" +
"." + domName + " anything\n"),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n" + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n" +
"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n.") "." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
); );
mainProcessor.appendProcessor(queueName, relayDomainsProcessor, queueName + ".hostsharing.net"); mainProcessor.appendProcessor(queueName, relayDomainsProcessor, queueName + ".hostsharing.net");
} }

View File

@ -4,6 +4,7 @@ import java.util.List;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
public class EMailAliasModuleImpl extends AbstractModuleImpl { public class EMailAliasModuleImpl extends AbstractModuleImpl {
@ -17,4 +18,18 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl {
return super.search(entityClass, condition, orderBy); return super.search(entityClass, condition, orderBy);
} }
@Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
EMailAlias alias = (EMailAlias) newEntity;
String name = alias.getName();
String pacname = alias.getPac().getName();
if (!name.startsWith(pacname)) {
throw new AuthenticationException("alias not allowed");
}
if (name.length() > 5 && (name.charAt(5) != '-') || name.length() == 6) {
throw new AuthenticationException("alias not allowed");
}
return super.add(newEntity);
}
} }