Database Namen pruefen
This commit is contained in:
parent
32e231850e
commit
2cdb8a77ff
@ -21,6 +21,20 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl {
|
||||
return super.search(entityClass, condition, orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
MySqlDatabase database = (MySqlDatabase) newEntity;
|
||||
String name = database.getName();
|
||||
String pacname = database.getPac().getName();
|
||||
if (!name.startsWith(pacname) || name.length() < 7) {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
if (name.charAt(5) != '_') {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
return super.add(newEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
|
@ -12,7 +12,15 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl {
|
||||
@Override
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
MySqlUser user = (MySqlUser) newEntity;
|
||||
if (user.getName().length() > 16) {
|
||||
String name = user.getName();
|
||||
if (name.length() > 16) {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
String pacname = user.getPac().getName();
|
||||
if (!name.startsWith(pacname) || name.length() < 7) {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
if (name.charAt(5) != '_') {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
return super.add(newEntity);
|
||||
|
@ -20,6 +20,20 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl {
|
||||
return super.search(entityClass, condition, orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
PgSqlDatabase database = (PgSqlDatabase) newEntity;
|
||||
String name = database.getName();
|
||||
String pacname = database.getPac().getName();
|
||||
if (!name.startsWith(pacname) || name.length() < 7) {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
if (name.charAt(5) != '_') {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
return super.add(newEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
|
@ -4,10 +4,25 @@ import java.util.List;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
import de.hsadmin.core.model.AuthorisationException;
|
||||
import de.hsadmin.core.model.HSAdminException;
|
||||
|
||||
public class PgSqlUserModuleImpl extends AbstractModuleImpl {
|
||||
|
||||
@Override
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
PgSqlUser user = (PgSqlUser) newEntity;
|
||||
String name = user.getName();
|
||||
String pacname = user.getPac().getName();
|
||||
if (!name.startsWith(pacname) || name.length() < 7) {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
if (name.charAt(5) != '_') {
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
return super.add(newEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
|
||||
String condition, String orderBy) throws HSAdminException {
|
||||
|
@ -2,9 +2,9 @@ package de.hsadmin.mods.email;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.AuthenticationException;
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
import de.hsadmin.core.model.AuthorisationException;
|
||||
import de.hsadmin.core.model.HSAdminException;
|
||||
|
||||
public class EMailAliasModuleImpl extends AbstractModuleImpl {
|
||||
@ -24,10 +24,10 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl {
|
||||
String name = alias.getName();
|
||||
String pacname = alias.getPac().getName();
|
||||
if (!name.startsWith(pacname)) {
|
||||
throw new AuthenticationException("alias not allowed");
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
if (name.length() > 5 && (name.charAt(5) != '-') || name.length() == 6) {
|
||||
throw new AuthenticationException("alias not allowed");
|
||||
throw new AuthorisationException(getLoginUser(), "add", newEntity);
|
||||
}
|
||||
return super.add(newEntity);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user