emailadresses to pacdomain are not allowed

This commit is contained in:
Peter Hormanns 2012-01-04 16:02:22 +00:00
parent d8ac72d343
commit bcad5ea7c4

View File

@ -26,7 +26,8 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
@Override @Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
EntityManager em = getTransaction().getEntityManager(); Transaction tx = getTransaction();
EntityManager em = tx.getEntityManager();
EMailAddress adr = (EMailAddress) newEntity; EMailAddress adr = (EMailAddress) newEntity;
if (adr.getTarget() == null || adr.getTarget().length() == 0) { if (adr.getTarget() == null || adr.getTarget().length() == 0) {
throw new HSAdminException("target required"); throw new HSAdminException("target required");
@ -43,6 +44,10 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
qDomain.setParameter("domName", adr.getDomain().getName()); qDomain.setParameter("domName", adr.getDomain().getName());
Domain dom = (Domain) qDomain.getSingleResult(); Domain dom = (Domain) qDomain.getSingleResult();
adr.setDomain(dom); adr.setDomain(dom);
UnixUser loginUser = tx.getLoginUser();
if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) {
throw new AuthorisationException(loginUser, "add", adr);
}
return super.add(newEntity); return super.add(newEntity);
} }