fix: set default options for compatibility, allow update on pac-domain
This commit is contained in:
parent
3f9eda45b6
commit
dbef80b91f
@ -19,6 +19,18 @@ import de.hsadmin.mods.user.UnixUser;
|
|||||||
|
|
||||||
public class DomainModuleImpl extends AbstractModuleImpl {
|
public class DomainModuleImpl extends AbstractModuleImpl {
|
||||||
|
|
||||||
|
public static final String DOMOPT_GREYLISTING = "greylisting";
|
||||||
|
public static final String DOMOPT_MULTIVIEWS = "multiviews";
|
||||||
|
public static final String DOMOPT_INDEXES = "indexes";
|
||||||
|
public static final String DOMOPT_HTDOCSFALLBACK = "htdocsfallback";
|
||||||
|
public static final String DOMOPT_INCLUDES = "includes";
|
||||||
|
public static final String DOMOPT_BACKUPFOREXTERNALMX = "backupmxforexternalmx";
|
||||||
|
|
||||||
|
public static final String[] ALL_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMOPT_MULTIVIEWS,
|
||||||
|
DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES, DOMOPT_BACKUPFOREXTERNALMX };
|
||||||
|
public static final String[] DEFAULT_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMOPT_MULTIVIEWS,
|
||||||
|
DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException {
|
public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException {
|
||||||
AbstractEntity newDom = super.initialize(newEntity);
|
AbstractEntity newDom = super.initialize(newEntity);
|
||||||
@ -123,16 +135,18 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
|||||||
dom.setUser((UnixUser) adminQuery.getSingleResult());
|
dom.setUser((UnixUser) adminQuery.getSingleResult());
|
||||||
needsWriteAccessOn(newEntity, "add");
|
needsWriteAccessOn(newEntity, "add");
|
||||||
em.persist(dom);
|
em.persist(dom);
|
||||||
|
HashSet<DomainOption> domainOptions = new HashSet<DomainOption>();
|
||||||
|
for (String domOpt : DEFAULT_DOMOPTS) {
|
||||||
Query q = em.createQuery("SELECT opt FROM " +
|
Query q = em.createQuery("SELECT opt FROM " +
|
||||||
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||||
" opt WHERE opt.name=:optName");
|
" opt WHERE opt.name=:optName");
|
||||||
HashSet<DomainOption> domainOptions = new HashSet<DomainOption>();
|
q.setParameter("optName", domOpt);
|
||||||
q.setParameter("optName", "greylisting");
|
|
||||||
List<?> list = q.getResultList();
|
List<?> list = q.getResultList();
|
||||||
if (list.size() != 1) {
|
if (list.size() == 1) {
|
||||||
throw new HSAdminException("invalid domain option: " + "greylisting");
|
|
||||||
} else {
|
|
||||||
domainOptions.add((DomainOption) list.get(0));
|
domainOptions.add((DomainOption) list.get(0));
|
||||||
|
} else {
|
||||||
|
throw new HSAdminException("invalid domain option: " + domOpt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dom.setDomainoptions(domainOptions);
|
dom.setDomainoptions(domainOptions);
|
||||||
if (dom.isPacDomain()) {
|
if (dom.isPacDomain()) {
|
||||||
@ -234,9 +248,11 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
|||||||
if (dom.isPacDomain() && !dom.getUser().getName().equals(domPac.getName())) {
|
if (dom.isPacDomain() && !dom.getUser().getName().equals(domPac.getName())) {
|
||||||
throw new AuthorisationException(loginUser, method, dom);
|
throw new AuthorisationException(loginUser, method, dom);
|
||||||
}
|
}
|
||||||
if (dom.isPacDomain() && !isHostmaster && !"add".equals(method)) {
|
if (dom.isPacDomain() && !isHostmaster) {
|
||||||
|
if (!"add".equals(method) && !"update".equals(method)) {
|
||||||
throw new AuthorisationException(loginUser, method, dom);
|
throw new AuthorisationException(loginUser, method, dom);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new AuthorisationException(loginUser, method, entity);
|
throw new AuthorisationException(loginUser, method, entity);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user