2011-03-30 18:26:43 +02:00
|
|
|
package de.hsadmin.remote;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import de.hsadmin.core.model.AbstractEntity;
|
|
|
|
import de.hsadmin.core.model.AuthenticationException;
|
|
|
|
import de.hsadmin.core.model.GenericModuleImpl;
|
|
|
|
import de.hsadmin.core.model.HSAdminException;
|
|
|
|
import de.hsadmin.core.model.Transaction;
|
|
|
|
import de.hsadmin.core.util.Config;
|
|
|
|
import de.hsadmin.mods.dom.Domain;
|
2011-10-28 13:03:27 +02:00
|
|
|
import de.hsadmin.mods.pac.Pac;
|
2011-03-30 18:26:43 +02:00
|
|
|
|
|
|
|
public class RoleRemote implements IRemote {
|
|
|
|
|
|
|
|
@Override
|
2011-10-28 16:08:18 +02:00
|
|
|
public List<Map<String, Object>> search(String runAsUser, String ticket,
|
2011-03-30 18:26:43 +02:00
|
|
|
Map<String, String> whereParams) throws HSAdminException {
|
|
|
|
String user = runAsUser;
|
|
|
|
Transaction transaction = new Transaction(user);
|
2012-06-12 12:56:58 +02:00
|
|
|
if (transaction.login(user, ticket)) {
|
2011-03-30 18:26:43 +02:00
|
|
|
String role = "USER";
|
|
|
|
String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
|
|
|
|
String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
|
2011-10-28 13:03:27 +02:00
|
|
|
Pac pac = transaction.getLoginUser().getPac();
|
|
|
|
String pacName = pac.getName();
|
2011-03-30 18:26:43 +02:00
|
|
|
if (accoutPrefixCustomer.equals(pacName)) {
|
|
|
|
role = "CUSTOMER";
|
|
|
|
}
|
|
|
|
if (accoutPrefixHostmaster.equals(pacName)) {
|
|
|
|
role = "HOSTMASTER";
|
|
|
|
}
|
|
|
|
if (user.equals(pacName)) {
|
2013-05-01 09:54:28 +02:00
|
|
|
if (pac.isDynamic()) {
|
|
|
|
role = "PAC_ADMIN_DW";
|
|
|
|
} else {
|
|
|
|
role = "PAC_ADMIN_SW";
|
|
|
|
}
|
2011-03-30 18:26:43 +02:00
|
|
|
}
|
|
|
|
if (role.equals("USER")) {
|
|
|
|
GenericModuleImpl module = new GenericModuleImpl(transaction);
|
|
|
|
List<AbstractEntity> list = module.search(Domain.class, "obj.user.name = '" + user + "'", null);
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
role = "DOM_ADMIN";
|
|
|
|
}
|
|
|
|
}
|
2011-10-28 16:08:18 +02:00
|
|
|
List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();
|
|
|
|
Map<String, Object> record = new HashMap<String, Object>();
|
2011-03-30 18:26:43 +02:00
|
|
|
record.put("role", role);
|
|
|
|
result.add(record);
|
|
|
|
transaction.close();
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
transaction.close();
|
|
|
|
throw new AuthenticationException("authentication failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-28 16:08:18 +02:00
|
|
|
public Map<String, Object> add(String runAsUser, String ticket,
|
|
|
|
Map<String, Object> setParams) throws HSAdminException {
|
2011-03-30 18:26:43 +02:00
|
|
|
throw new HSAdminException("not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-28 16:08:18 +02:00
|
|
|
public List<Map<String, Object>> update(String runAsUser, String ticket,
|
|
|
|
Map<String, Object> setParams, Map<String, String> whereParams)
|
2011-03-30 18:26:43 +02:00
|
|
|
throws HSAdminException {
|
|
|
|
throw new HSAdminException("not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void delete(String runAsUser, String ticket,
|
|
|
|
Map<String, String> whereParams) throws HSAdminException {
|
|
|
|
throw new HSAdminException("not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|