package de.hsadmin.mods.email; import java.util.List; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.HSAdminException; public class EMailAliasModuleImpl extends AbstractModuleImpl { @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { if (orderBy == null || orderBy.length() == 0) { orderBy = "ORDER BY obj.name ASC"; } 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); } }