From bcad5ea7c4877b3ae39e09c94a5dccaf6977c41c Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Wed, 04 Jan 2012 17:02:22 +0100
Subject: [PATCH] emailadresses to pacdomain are not allowed

---
 hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
index 5dbd112..e8447cd 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
@@ -26,7 +26,8 @@
 
 	@Override
 	public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
-		EntityManager em = getTransaction().getEntityManager();
+		Transaction tx = getTransaction();
+		EntityManager em = tx.getEntityManager();
 		EMailAddress adr = (EMailAddress) newEntity;
 		if (adr.getTarget() == null || adr.getTarget().length() == 0) {
 			throw new HSAdminException("target required");
@@ -43,6 +44,10 @@
 		qDomain.setParameter("domName", adr.getDomain().getName());
 		Domain dom = (Domain) qDomain.getSingleResult();
 		adr.setDomain(dom);
+		UnixUser loginUser = tx.getLoginUser();
+		if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) {
+			throw new AuthorisationException(loginUser, "add", adr);
+		}
 		return super.add(newEntity);
 	}
 

--
Gitblit v1.9.3