subdomains to pacdomain are not allowed

This commit is contained in:
Peter Hormanns 2012-01-04 15:12:47 +00:00
parent 9188fd5e42
commit 4d31afc018

View File

@ -100,16 +100,16 @@ public class DomainModuleImpl extends AbstractModuleImpl {
Query domainQuery = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domainName"); Query domainQuery = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domainName");
String superior = dom.getName(); String superior = dom.getName();
while (superior.contains(".")) { while (superior.contains(".")) {
superior = superior.substring(superior.indexOf('.') + 1);
if (dom.isPacDomain()) { if (dom.isPacDomain()) {
break; break;
} }
superior = superior.substring(superior.indexOf('.') + 1);
domainQuery.setParameter("domainName", superior); domainQuery.setParameter("domainName", superior);
List<?> resultList = domainQuery.getResultList(); List<?> resultList = domainQuery.getResultList();
if (resultList.size() > 0) { if (resultList.size() > 0) {
Domain superDom = (Domain) resultList.get(0); Domain superDom = (Domain) resultList.get(0);
if (superDom.isPacDomain()) { if (superDom.isPacDomain()) {
throw new HSAdminException("subdomains to pacdomain " + superDom.getName() + " are not allowed"); throw new HSAdminException("subdomains to pacdomain " + superDom.getName() + " is not allowed");
} }
if (loginUser.hasPacAdminRoleFor(superDom.getUser().getPac())) { if (loginUser.hasPacAdminRoleFor(superDom.getUser().getPac())) {
break; // same pac break; // same pac
@ -131,13 +131,15 @@ public class DomainModuleImpl extends AbstractModuleImpl {
adminQuery.setParameter("adminName", admin.getName()); adminQuery.setParameter("adminName", admin.getName());
dom.setUser((UnixUser) adminQuery.getSingleResult()); dom.setUser((UnixUser) adminQuery.getSingleResult());
needsWriteAccessOn(newEntity, "add"); needsWriteAccessOn(newEntity, "add");
// Entity addedEntity = super.add(dom);
// Domain addedDomain = (Domain) addedEntity;
em.persist(dom); em.persist(dom);
String[] emailAddresses = new String[] { "abuse", "postmaster", "webmaster" }; if (dom.isPacDomain()) {
for (String emailLocalpart : emailAddresses) { em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getContractualContact().getEmail()));
EMailAddress eMailAddress = new EMailAddress(emailLocalpart, "", dom, admin.getName()); em.persist(new EMailAddress("admin", "", dom, admin.getName()));
em.persist(eMailAddress); em.persist(new EMailAddress(dom.getUser().getPac().getName(), "", dom, admin.getName()));
} else {
em.persist(new EMailAddress("abuse", "", dom, admin.getName()));
em.persist(new EMailAddress("postmaster", "", dom, admin.getName()));
em.persist(new EMailAddress("webmaster", "", dom, admin.getName()));
} }
return super.add(dom); return super.add(dom);
} }