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; import de.hsadmin.mods.pac.Pac; public class RoleRemote implements IRemote { @Override public List> search(String runAsUser, String ticket, Map whereParams) throws HSAdminException { String user = runAsUser; Transaction transaction = new Transaction(user); if (transaction.login(user, ticket)) { String role = "USER"; String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer"); String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster"); Pac pac = transaction.getLoginUser().getPac(); String pacName = pac.getName(); if (accoutPrefixCustomer.equals(pacName)) { role = "CUSTOMER"; } if (accoutPrefixHostmaster.equals(pacName)) { role = "HOSTMASTER"; } if (user.equals(pacName)) { role = "PAC_ADMIN_DW"; } if (role.equals("USER")) { GenericModuleImpl module = new GenericModuleImpl(transaction); List list = module.search(Domain.class, "obj.user.name = '" + user + "'", null); if (list != null && list.size() > 0) { role = "DOM_ADMIN"; } } List> result = new ArrayList>(); Map record = new HashMap(); record.put("role", role); result.add(record); transaction.close(); return result; } else { transaction.close(); throw new AuthenticationException("authentication failed"); } } @Override public Map add(String runAsUser, String ticket, Map setParams) throws HSAdminException { throw new HSAdminException("not implemented"); } @Override public List> update(String runAsUser, String ticket, Map setParams, Map whereParams) throws HSAdminException { throw new HSAdminException("not implemented"); } @Override public void delete(String runAsUser, String ticket, Map whereParams) throws HSAdminException { throw new HSAdminException("not implemented"); } }