Hack: Check multi options and pac types.

This commit is contained in:
Michael Hierweck 2013-04-29 18:49:16 +02:00
parent aa82ca8ad1
commit f05c2ea1f8
15 changed files with 159 additions and 41 deletions

View File

@ -2,61 +2,69 @@
-- Table: basepacket -- Table: basepacket
-- --
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('DW/B', 'Dynamic-Web/Base', 300, true, 100); VALUES ('PAC/DW', 'Dynamic-Web/Base', 300, true, 100);
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('SW/B', 'Static-Web/Base', 400, true, 200); VALUES ('PAC/SW', 'Static-Web/Base', 400, true, 200);
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('WEB', 'Web/Base', 100, true, 300); VALUES ('PAC/WEB', 'Web/Base', 100, true, 300);
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('HIVE', 'Managed Server', 200, true, 400); VALUES ('SRV/MGD', 'Managed Server', 200, true, 400);
-- --
-- Table: basecomponent -- Table: basecomponent
-- --
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('TRAFFIC', 'Monatliches Datenvolumen in GB', 100, true); VALUES ('MULTI', 'Monatliches Datenvolumen in GB', 100, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('QUOTA', 'Festplattenspeicherplatz in MB', 200, true); VALUES ('TRAFFIC', 'Monatliches Datenvolumen in GB', 200, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('DAEMON', 'Nutzung eines eigenen Servers/Daemons', 300, true); VALUES ('QUOTA', 'Festplattenspeicherplatz in MB', 300, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('MIRROR', 'Echtzeitspiegelung der Daten', 400, true); VALUES ('DAEMON', 'Nutzung eines eigenen Servers/Daemons', 400, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('BACKUP', 'Nächtliches Backup', 500, true); VALUES ('MIRROR', 'Echtzeitspiegelung der Daten', 500, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('BACKUP', 'Nächtliches Backup', 600, true);
-- --
-- Table: component -- Table: component
-- --
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 128, 40960, 128, 128, 128, false, 101 FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='QUOTA'; SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 1, false, 100 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='MULTI';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 512, false, 201 FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='QUOTA'; SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 1, false, 200 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='MULTI';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 0, false, 301 FROM basepacket, basecomponent WHERE basepacket_code='WEB' AND basecomponent_code='QUOTA'; SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 1, false, 300 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='MULTI';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 2, 40960, 2, 2, 2, false, 102 FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='TRAFFIC'; SELECT basepacket_id, basecomponent_id, 128, 40960, 128, 128, 128, false, 101 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='QUOTA';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 4, 40960, 4, 4, 4, false, 202 FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='TRAFFIC'; SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 512, false, 201 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='QUOTA';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 5, 40960, 5, 5, 0, false, 302 FROM basepacket, basecomponent WHERE basepacket_code='WEB' AND basecomponent_code='TRAFFIC'; SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 0, false, 301 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='QUOTA';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 103 FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='DAEMON'; SELECT basepacket_id, basecomponent_id, 2, 40960, 2, 2, 2, false, 102 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='TRAFFIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 0, 0, 1, 0, false, 203 FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='DAEMON'; SELECT basepacket_id, basecomponent_id, 4, 40960, 4, 4, 4, false, 202 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='TRAFFIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 303 FROM basepacket, basecomponent WHERE basepacket_code='WEB' AND basecomponent_code='DAEMON'; SELECT basepacket_id, basecomponent_id, 5, 40960, 5, 5, 0, false, 302 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='TRAFFIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 104 FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='MIRROR'; SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 103 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='DAEMON';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 204 FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='MIRROR'; SELECT basepacket_id, basecomponent_id, 0, 0, 0, 1, 0, false, 203 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='DAEMON';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 304 FROM basepacket, basecomponent WHERE basepacket_code='WEB' AND basecomponent_code='MIRROR'; SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false, 303 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='DAEMON';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 105 FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='BACKUP'; SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 104 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='MIRROR';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 205 FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='BACKUP'; SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 204 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='MIRROR';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 305 FROM basepacket, basecomponent WHERE basepacket_code='WEB' AND basecomponent_code='BACKUP'; SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 304 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='MIRROR';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 105 FROM basepacket, basecomponent WHERE basepacket_code='PAC/DW' AND basecomponent_code='BACKUP';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 205 FROM basepacket, basecomponent WHERE basepacket_code='PAC/SW' AND basecomponent_code='BACKUP';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 1, 1, 1, false, 305 FROM basepacket, basecomponent WHERE basepacket_code='PAC/WEB' AND basecomponent_code='BACKUP';
-- --
-- Table: business_partner -- Table: business_partner

View File

@ -3,7 +3,7 @@
-- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) -- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
-- JOIN packet on ( unixuser.packet_id = packet.packet_id ) -- JOIN packet on ( unixuser.packet_id = packet.packet_id )
-- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ), domain_option -- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ), domain_option
-- WHERE basepacket.basepacket_code = 'DW/B' -- WHERE basepacket.basepacket_code = 'PAC/DW'
-- AND domain_option.domain_option_name = 'php' ; -- AND domain_option.domain_option_name = 'php' ;
-- DELETE FROM domain__domain_option -- DELETE FROM domain__domain_option
@ -11,7 +11,7 @@
-- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) -- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
-- JOIN packet on ( unixuser.packet_id = packet.packet_id ) -- JOIN packet on ( unixuser.packet_id = packet.packet_id )
-- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ) -- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
-- WHERE basepacket.basepacket_code != 'DW/B' -- WHERE basepacket.basepacket_code != 'PAC/DW'
-- AND domain__domain_option.domain_option_id = domain_option.domain_option_id -- AND domain__domain_option.domain_option_id = domain_option.domain_option_id
-- AND domain_option.domain_option_name = 'php' ; -- AND domain_option.domain_option_name = 'php' ;

View File

@ -15,6 +15,8 @@ import de.hsadmin.mods.user.UnixUser;
public class MySqlDatabaseModuleImpl extends AbstractModuleImpl { public class MySqlDatabaseModuleImpl extends AbstractModuleImpl {
private static final int DBS_PER_MULTI_OPTION = 25;
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
@ -54,6 +56,17 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl {
if (!pac.getName().equals(pacPrefix)) { if (!pac.getName().equals(pacPrefix)) {
throw new HSAdminException("wrong database owner"); throw new HSAdminException("wrong database owner");
} }
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qDatabases = em.createQuery("SELECT obj FROM Databases obj WHERE obj.packet_id = :pacId");
qDatabases.setParameter("pacId", pac.getId());
if (qDatabases.getResultList().size() >= DBS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included number of databases exceeded");
}
database.setPac(pac); database.setPac(pac);
return super.add(newEntity); return super.add(newEntity);
} }

View File

@ -15,6 +15,8 @@ import de.hsadmin.mods.user.UnixUser;
public class MySqlUserModuleImpl extends AbstractModuleImpl { public class MySqlUserModuleImpl extends AbstractModuleImpl {
private static final int DBUSERS_PER_MULTI_OPTION = 25;
@Override @Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
Transaction transaction = getTransaction(); Transaction transaction = getTransaction();
@ -35,6 +37,17 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl {
if (pac == null || !pac.isReadAllowedFor(loginUser)) { if (pac == null || !pac.isReadAllowedFor(loginUser)) {
throw new AuthorisationException(loginUser, "add", newEntity); throw new AuthorisationException(loginUser, "add", newEntity);
} }
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qDatabaseUsers = em.createQuery("SELECT obj FROM DatabaseUsers obj WHERE obj.packet_id = :pacId");
qDatabaseUsers.setParameter("pacId", pac.getId());
if (qDatabaseUsers.getResultList().size() >= DBUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included database users exceeded");
}
user.setPac(pac); user.setPac(pac);
return super.add(newEntity); return super.add(newEntity);
} }

View File

@ -15,6 +15,8 @@ import de.hsadmin.mods.user.UnixUser;
public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl { public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl {
private static final int DBS_PER_MULTI_OPTION = 25;
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException { public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
@ -51,6 +53,18 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl {
} }
if (!pac.getName().equals(pacPrefix)) { if (!pac.getName().equals(pacPrefix)) {
throw new HSAdminException("wrong database owner"); throw new HSAdminException("wrong database owner");
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qDatabases = em.createQuery("SELECT obj FROM Databases obj WHERE obj.packet_id = :pacId");
qDatabases.setParameter("pacId", pac.getId());
if (qDatabases.getResultList().size() >= DBS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included databases exceeded");
} }
database.setPac(pac); database.setPac(pac);
return super.add(newEntity); return super.add(newEntity);

View File

@ -14,6 +14,8 @@ import de.hsadmin.mods.user.UnixUser;
public class PgSqlUserModuleImpl extends AbstractModuleImpl { public class PgSqlUserModuleImpl extends AbstractModuleImpl {
private static final int DBUSERS_PER_MULTI_OPTION = 5;
@Override @Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
UnixUser loginUser = getTransaction().getLoginUser(); UnixUser loginUser = getTransaction().getLoginUser();
@ -30,6 +32,17 @@ public class PgSqlUserModuleImpl extends AbstractModuleImpl {
if (pac == null || !pac.isReadAllowedFor(loginUser)) { if (pac == null || !pac.isReadAllowedFor(loginUser)) {
throw new AuthorisationException(loginUser, "add", newEntity); throw new AuthorisationException(loginUser, "add", newEntity);
} }
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qDatabaseUsers = em.createQuery("SELECT obj FROM DatabaseUsers obj WHERE obj.packet_id = :pacId");
qDatabaseUsers.setParameter("pacId", pac.getId());
if (qDatabaseUsers.getResultList().size() >= DBUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included database users exceeded");
}
user.setPac(pac); user.setPac(pac);
return super.add(newEntity); return super.add(newEntity);
} }

View File

@ -20,15 +20,15 @@ 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_GREYLISTING = "greylisting";
public static final String DOMOPT_MULTIVIEWS = "multiviews"; public static final String DOMMULTIVIEWS = "multiviews";
public static final String DOMOPT_INDEXES = "indexes"; public static final String DOMOPT_INDEXES = "indexes";
public static final String DOMOPT_HTDOCSFALLBACK = "htdocsfallback"; public static final String DOMOPT_HTDOCSFALLBACK = "htdocsfallback";
public static final String DOMOPT_INCLUDES = "includes"; public static final String DOMOPT_INCLUDES = "includes";
public static final String DOMOPT_BACKUPFOREXTERNALMX = "backupmxforexternalmx"; public static final String DOMOPT_BACKUPFOREXTERNALMX = "backupmxforexternalmx";
public static final String[] ALL_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMOPT_MULTIVIEWS, public static final String[] ALL_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMMULTIVIEWS,
DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES, DOMOPT_BACKUPFOREXTERNALMX }; DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES, DOMOPT_BACKUPFOREXTERNALMX };
public static final String[] DEFAULT_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMOPT_MULTIVIEWS, public static final String[] DEFAULT_DOMOPTS = new String[] { DOMOPT_GREYLISTING, DOMMULTIVIEWS,
DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES }; DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, DOMOPT_INCLUDES };
@Override @Override
@ -102,6 +102,11 @@ public class DomainModuleImpl extends AbstractModuleImpl {
if (admin == null || admin.getName() == null || admin.getName().length() == 0) { if (admin == null || admin.getName() == null || admin.getName().length() == 0) {
throw new HSAdminException("domain admin required"); throw new HSAdminException("domain admin required");
} }
//TODO: Needs better implementation
String pacType = admin.getPac().getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
// Standard domainoptions setzen. TODO: Alle defaults über eigene Klasse aus der Datenbank holen. // Standard domainoptions setzen. TODO: Alle defaults über eigene Klasse aus der Datenbank holen.
EntityManager em = getTransaction().getEntityManager(); EntityManager em = getTransaction().getEntityManager();
UnixUser loginUser = getTransaction().getLoginUser(); UnixUser loginUser = getTransaction().getLoginUser();

View File

@ -11,10 +11,13 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class EMailAddressModuleImpl extends AbstractModuleImpl { public class EMailAddressModuleImpl extends AbstractModuleImpl {
private static final int EMAIL_PER_MULTI_OPTION = 250;
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
@ -51,6 +54,19 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) { if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) {
throw new AuthorisationException(loginUser, "add", adr); throw new AuthorisationException(loginUser, "add", adr);
} }
//TODO: Needs better implementation
String pacType = dom.getUser().getPac().getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qEmailAliases = em.createQuery("SELECT obj FROM EmailAliases obj WHERE obj.packet_id = :pacId");
qEmailAliases.setParameter("pacId", dom.getUser().getPac().getId());
Query qEmailAddresses = em.createQuery("SELECT obj FROM EmailAdresses obj WHERE obj.domain.user.pac.packet_id = :pacId");
qEmailAddresses.setParameter("pacId", dom.getUser().getPac().getId());
if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= EMAIL_PER_MULTI_OPTION * dom.getUser().getPac().getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included email addresses/aliases exceeded");
}
return super.add(newEntity); return super.add(newEntity);
} }

View File

@ -15,6 +15,8 @@ import de.hsadmin.mods.user.UnixUser;
public class EMailAliasModuleImpl extends AbstractModuleImpl { public class EMailAliasModuleImpl extends AbstractModuleImpl {
private static final int UNIXUSERS_PER_MULTI_OPTION = 250;
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
@ -44,6 +46,19 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl {
if (!name.startsWith(pac.getName())) { if (!name.startsWith(pac.getName())) {
throw new AuthorisationException(loginUser, "add", newEntity); throw new AuthorisationException(loginUser, "add", newEntity);
} }
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qEmailAliases = em.createQuery("SELECT obj FROM EmailAliases obj WHERE obj.packet_id = :pacId");
qEmailAliases.setParameter("pacId", pac.getId());
Query qEmailAddresses = em.createQuery("SELECT obj FROM EmailAdresses obj WHERE obj.domain.user.pac.packet_id = :pacId");
qEmailAddresses.setParameter("pacId", pac.getId());
if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= UNIXUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included email addresses/aliases exceeded");
}
alias.setPac(pac); alias.setPac(pac);
return super.add(newEntity); return super.add(newEntity);
} }

View File

@ -37,10 +37,10 @@ import de.hsadmin.mods.user.UnixUser;
@AnnModuleImpl(de.hsadmin.mods.pac.PacModuleImpl.class) @AnnModuleImpl(de.hsadmin.mods.pac.PacModuleImpl.class)
public class Pac extends AbstractEntity implements Serializable { public class Pac extends AbstractEntity implements Serializable {
public static final String PAC_WEB_BASE = "WEB"; public static final String PAC_DW = "PAC/DW";
public static final String PAC_HIVE = "HIVE"; public static final String PAC_SW = "PAC/SW";
public static final String PAC_DW_BASE = "DW/B"; public static final String PAC_WEB = "PAC/WEB";
public static final String PAC_SW_BASE = "SW/B"; public static final String PAC_SRV = "SRV/MGD";
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -293,4 +293,13 @@ public class Pac extends AbstractEntity implements Serializable {
public void setFree(boolean free) { public void setFree(boolean free) {
this.free = free; this.free = free;
} }
public int getQuantityByComponentName(String componentName) {
PacComponent multi = getPacComponent(componentName);
if (multi == null) {
return 0;
} else {
return multi.getQuantity();
}
}
} }

View File

@ -25,7 +25,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
EntityManager em, T entity) throws ProcessorException { EntityManager em, T entity) throws ProcessorException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB_BASE) || basepacName.equals(Pac.PAC_DW_BASE) || basepacName.equals(Pac.PAC_SW_BASE)) { if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
String pacName = pac.getName(); String pacName = pac.getName();
Hive hive = pac.getHive(); Hive hive = pac.getHive();
UnixUser unixUser = getPacAdminUser(pac); UnixUser unixUser = getPacAdminUser(pac);
@ -79,7 +79,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
throws ProcessorException { throws ProcessorException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB_BASE) || basepacName.equals(Pac.PAC_DW_BASE) || basepacName.equals(Pac.PAC_SW_BASE)) { if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
return createSetQuotaProc(pac); return createSetQuotaProc(pac);
} else { } else {
return new NullProcessor(); return new NullProcessor();
@ -90,7 +90,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException { public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB_BASE) || basepacName.equals(Pac.PAC_DW_BASE) || basepacName.equals(Pac.PAC_SW_BASE)) { if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
Hive hive = pac.getHive(); Hive hive = pac.getHive();
WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName())); WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor( waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(

View File

@ -15,6 +15,8 @@ import de.hsadmin.mods.pac.Pac;
public class UnixUserModuleImpl extends AbstractModuleImpl { public class UnixUserModuleImpl extends AbstractModuleImpl {
private static final int UNIXUSERS_PER_MULTI_OPTION = 50;
public UnixUserModuleImpl() { public UnixUserModuleImpl() {
} }
@ -125,7 +127,17 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
throw new AuthorisationException(loginUser, "add", newUnixUser, "userId"); throw new AuthorisationException(loginUser, "add", newUnixUser, "userId");
} }
} }
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation
Query qUnixUsers = em.createQuery("SELECT obj FROM UnixUsers obj WHERE obj.id = :pacId");
qUnixUsers.setParameter("pacId", pac.getId());
if (qUnixUsers.getResultList().size() >= UNIXUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included unix users exceeded");
}
// don't move this up, it will update the new entity still with wrong // don't move this up, it will update the new entity still with wrong
// userid! // userid!
newUnixUser.setPac(pac); newUnixUser.setPac(pac);

View File

@ -79,7 +79,7 @@ public class InitDataTest {
setParams.put("name", "aaa00"); setParams.put("name", "aaa00");
setParams.put("hive", "h99"); setParams.put("hive", "h99");
setParams.put("customer", "hsh00-aaa"); setParams.put("customer", "hsh00-aaa");
setParams.put("basepac", Pac.PAC_WEB_BASE); setParams.put("basepac", Pac.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.74"); setParams.put("curinetaddr", "176.9.242.74");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),

View File

@ -93,7 +93,7 @@ public class PacTest {
setParams.put("name", "aaa01"); setParams.put("name", "aaa01");
setParams.put("hive", "h99"); setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa"); setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_WEB_BASE); setParams.put("basepac", Pac.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.76"); setParams.put("curinetaddr", "176.9.242.76");
HashMap<String, String> components = new HashMap<String, String>(); HashMap<String, String> components = new HashMap<String, String>();
components.put("QUOTA", "512"); components.put("QUOTA", "512");

View File

@ -47,7 +47,7 @@ public class SSLCertDomainTest {
setParams.put("name", "aaa02"); setParams.put("name", "aaa02");
setParams.put("hive", "h99"); setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa"); setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_WEB_BASE); setParams.put("basepac", Pac.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.77"); setParams.put("curinetaddr", "176.9.242.77");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
@ -78,7 +78,7 @@ public class SSLCertDomainTest {
setParams.put("name", "aaa03"); setParams.put("name", "aaa03");
setParams.put("hive", "h99"); setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa"); setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_DW_BASE); setParams.put("basepac", Pac.PAC_DW);
setParams.put("curinetaddr", "176.9.242.78"); setParams.put("curinetaddr", "176.9.242.78");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),