runAs Feature
This commit is contained in:
parent
c6bbeed75a
commit
05b105028c
@ -57,6 +57,7 @@
|
|||||||
</init-param>
|
</init-param>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
|
|
||||||
<filter-mapping>
|
<filter-mapping>
|
||||||
<filter-name>CAS Validation Filter</filter-name>
|
<filter-name>CAS Validation Filter</filter-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
@ -66,7 +67,7 @@
|
|||||||
<filter-name>CAS Authentication Filter</filter-name>
|
<filter-name>CAS Authentication Filter</filter-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>Logout Servlet</servlet-name>
|
<servlet-name>Logout Servlet</servlet-name>
|
||||||
<servlet-class>de.hsadmin.logout.LogoutServlet</servlet-class>
|
<servlet-class>de.hsadmin.logout.LogoutServlet</servlet-class>
|
||||||
@ -93,11 +94,15 @@
|
|||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>HSAdmin Web</servlet-name>
|
<servlet-name>HSAdmin Web</servlet-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/MainApplication/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>HSAdmin Web</servlet-name>
|
||||||
|
<url-pattern>/VAADIN/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>index.html</welcome-file>
|
|
||||||
<welcome-file>index.jsp</welcome-file>
|
<welcome-file>index.jsp</welcome-file>
|
||||||
</welcome-file-list>
|
</welcome-file-list>
|
||||||
</web-app>
|
</web-app>
|
@ -4,12 +4,15 @@ import java.io.Serializable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.vaadin.data.Property;
|
||||||
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
import com.vaadin.terminal.Sizeable;
|
import com.vaadin.terminal.Sizeable;
|
||||||
import com.vaadin.terminal.ThemeResource;
|
import com.vaadin.terminal.ThemeResource;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.Form;
|
import com.vaadin.ui.Form;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.Select;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
@ -28,23 +31,73 @@ public abstract class AbstractModule implements Module, Serializable {
|
|||||||
private VerticalLayout layout;
|
private VerticalLayout layout;
|
||||||
private Component component;
|
private Component component;
|
||||||
private ComponentFactory componentFactory;
|
private ComponentFactory componentFactory;
|
||||||
|
private Select selRunAs;
|
||||||
|
|
||||||
public Component getComponent() {
|
public Component getComponent() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() throws HsarwebException {
|
public void reload() throws HsarwebException {
|
||||||
|
if (selRunAs != null) {
|
||||||
|
selRunAs.select(application.getRunAs());
|
||||||
|
selRunAs.setScrollToSelectedItem(true);
|
||||||
|
}
|
||||||
componentFactory.loadData();
|
componentFactory.loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLayout() {
|
private void initLayout() throws HsarwebException {
|
||||||
layout = new VerticalLayout();
|
layout = new VerticalLayout();
|
||||||
layout.setSizeFull();
|
layout.setSizeFull();
|
||||||
final Module thisModule = this;
|
final Module thisModule = this;
|
||||||
final ModuleConfig moduleConfig = getModuleConfig();
|
final ModuleConfig moduleConfig = getModuleConfig();
|
||||||
final LocaleConfig localeConfig = application.getLocaleConfig();
|
final LocaleConfig localeConfig = application.getLocaleConfig();
|
||||||
if (this instanceof SearchAble || this instanceof InsertAble) {
|
if (this instanceof SearchAble || this instanceof InsertAble ||
|
||||||
|
!("USER".equals(application.getLoginUserRole()) || "NONE".equals(application.getLoginUserRole()))) {
|
||||||
HorizontalLayout toolbar = new HorizontalLayout();
|
HorizontalLayout toolbar = new HorizontalLayout();
|
||||||
|
if (!("USER".equals(application.getLoginUserRole()) || "NONE".equals(application.getLoginUserRole()))) {
|
||||||
|
selRunAs = new Select();
|
||||||
|
selRunAs.setWidth(100.0f, Sizeable.UNITS_PIXELS);
|
||||||
|
selRunAs.setImmediate(true);
|
||||||
|
selRunAs.setNewItemsAllowed(false);
|
||||||
|
selRunAs.setNullSelectionAllowed(false);
|
||||||
|
if (!application.getLoginUserRole().startsWith("PAC")) {
|
||||||
|
// if (application.getLoginUserRole().startsWith("PAC")) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
selRunAs.addItem(application.getLogin());
|
||||||
|
Object custListObj = application.getRemote().callSearch("member", new HashMap<String, String>());
|
||||||
|
if (custListObj instanceof Object[]) {
|
||||||
|
Object[] custList = (Object[]) custListObj;
|
||||||
|
for (Object custObj : custList) {
|
||||||
|
if (custObj instanceof Map<?, ?>) {
|
||||||
|
Map<?, ?> custHash = (Map<?, ?>)custObj;
|
||||||
|
selRunAs.addItem(custHash.get("membercode"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object pacListObj = application.getRemote().callSearch("pac", new HashMap<String, String>());
|
||||||
|
if (pacListObj instanceof Object[]) {
|
||||||
|
Object[] pacList = (Object[]) pacListObj;
|
||||||
|
for (Object pacObj : pacList) {
|
||||||
|
if (pacObj instanceof Map<?, ?>) {
|
||||||
|
Map<?, ?> pacHash = (Map<?, ?>)pacObj;
|
||||||
|
selRunAs.addItem(pacHash.get("name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selRunAs.select(application.getRunAs());
|
||||||
|
selRunAs.setScrollToSelectedItem(true);
|
||||||
|
selRunAs.addListener(new Property.ValueChangeListener() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Override
|
||||||
|
public void valueChange(ValueChangeEvent event) {
|
||||||
|
Property property = event.getProperty();
|
||||||
|
application.setRunAs(property.getValue().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolbar.addComponent(selRunAs);
|
||||||
|
}
|
||||||
if (this instanceof InsertAble) {
|
if (this instanceof InsertAble) {
|
||||||
Button btNew = new Button(moduleConfig.getLabel("new"));
|
Button btNew = new Button(moduleConfig.getLabel("new"));
|
||||||
ThemeResource icon = new ThemeResource("../runo/icons/16/document-add.png");
|
ThemeResource icon = new ThemeResource("../runo/icons/16/document-add.png");
|
||||||
|
@ -29,7 +29,7 @@ public abstract class DatabaseModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
|
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
||||||
idProp.setReadOnly(true);
|
idProp.setReadOnly(true);
|
||||||
|
@ -24,7 +24,7 @@ public abstract class DatabaseUserModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
|
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
||||||
idProp.setReadOnly(true);
|
idProp.setReadOnly(true);
|
||||||
|
@ -23,7 +23,7 @@ public class DomainModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig("domain", application.getLocale());
|
moduleConfig = new ModuleConfig("domain", application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
||||||
idProp.setReadOnly(true);
|
idProp.setReadOnly(true);
|
||||||
|
@ -22,7 +22,7 @@ public class EMailAddressModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig("emailaddress", application.getLocale());
|
moduleConfig = new ModuleConfig("emailaddress", application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
||||||
idProp.setReadOnly(true);
|
idProp.setReadOnly(true);
|
||||||
|
@ -22,7 +22,7 @@ public class EMailAliasModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig("emailalias", application.getLocale());
|
moduleConfig = new ModuleConfig("emailalias", application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
|
||||||
idProp.setReadOnly(true);
|
idProp.setReadOnly(true);
|
||||||
|
@ -95,7 +95,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
|
|||||||
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
|
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
|
||||||
button.setIcon(icon);
|
button.setIcon(icon);
|
||||||
Map<String, String> whereHash = new HashMap<String, String>();
|
Map<String, String> whereHash = new HashMap<String, String>();
|
||||||
whereHash.put("name", application.getLogin());
|
whereHash.put("name", application.getRunAs());
|
||||||
Long key = -1L;
|
Long key = -1L;
|
||||||
try {
|
try {
|
||||||
Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash);
|
Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash);
|
||||||
|
@ -46,6 +46,9 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
private Remote remote;
|
private Remote remote;
|
||||||
private Map<String, Module> modules;
|
private Map<String, Module> modules;
|
||||||
private Locale requestLocale;
|
private Locale requestLocale;
|
||||||
|
private String role = "NONE";
|
||||||
|
private String runAs = null;
|
||||||
|
private TabSheet tabSheet;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,7 +59,6 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
}
|
}
|
||||||
localeConfig = new LocaleConfig(locale, "main");
|
localeConfig = new LocaleConfig(locale, "main");
|
||||||
remote = new Remote(this);
|
remote = new Remote(this);
|
||||||
String role = "NONE";
|
|
||||||
try {
|
try {
|
||||||
Object rolesArrayObj = remote.callSearch("role", null);
|
Object rolesArrayObj = remote.callSearch("role", null);
|
||||||
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
|
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
|
||||||
@ -69,8 +71,8 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
showSystemException(e);
|
showSystemException(e);
|
||||||
}
|
}
|
||||||
Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
|
Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
|
||||||
TabSheet tabs = new TabSheet();
|
tabSheet = new TabSheet();
|
||||||
tabs.setSizeFull();
|
tabSheet.setSizeFull();
|
||||||
String modulesParamString = localeConfig.getText("modules." + role);
|
String modulesParamString = localeConfig.getText("modules." + role);
|
||||||
modules = new HashMap<String, Module>();
|
modules = new HashMap<String, Module>();
|
||||||
Module firstModule = null;
|
Module firstModule = null;
|
||||||
@ -84,13 +86,13 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
ModuleConfig moduleConfig = module.getModuleConfig();
|
ModuleConfig moduleConfig = module.getModuleConfig();
|
||||||
String label = moduleConfig.getLabel("moduletitle");
|
String label = moduleConfig.getLabel("moduletitle");
|
||||||
modules.put(label, module);
|
modules.put(label, module);
|
||||||
tabs.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon")));
|
tabSheet.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
showSystemException(e);
|
showSystemException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tabs.addListener(this);
|
tabSheet.addListener(this);
|
||||||
mainWindow.setContent(tabs);
|
mainWindow.setContent(tabSheet);
|
||||||
setMainWindow(mainWindow);
|
setMainWindow(mainWindow);
|
||||||
setErrorHandler(new Terminal.ErrorListener() {
|
setErrorHandler(new Terminal.ErrorListener() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -105,6 +107,10 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
showSystemException(e);
|
showSystemException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginUserRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
public String getProxyTicket() {
|
public String getProxyTicket() {
|
||||||
return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL"));
|
return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL"));
|
||||||
@ -186,4 +192,24 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
|||||||
getMainWindow().showNotification("System-Fehler", "<br />Bitte informieren Sie den Support<br/ >" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
|
getMainWindow().showNotification("System-Fehler", "<br />Bitte informieren Sie den Support<br/ >" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRunAs() {
|
||||||
|
if (runAs == null) {
|
||||||
|
return getLogin();
|
||||||
|
}
|
||||||
|
return runAs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunAs(String runAs) {
|
||||||
|
this.runAs = runAs;
|
||||||
|
Component selectedTab = tabSheet.getSelectedTab();
|
||||||
|
Tab tab = tabSheet.getTab(selectedTab);
|
||||||
|
Module module = modules.get(tab.getCaption());
|
||||||
|
try {
|
||||||
|
module.reload();
|
||||||
|
} catch (HsarwebException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
showSystemException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class Remote {
|
|||||||
|
|
||||||
private Object xmlrpcCall(String module, String operation, Map<String, String> param1) throws HsarwebException {
|
private Object xmlrpcCall(String module, String operation, Map<String, String> param1) throws HsarwebException {
|
||||||
Object[] params = new Object[3];
|
Object[] params = new Object[3];
|
||||||
params[0] = app.getLogin();
|
params[0] = app.getRunAs();
|
||||||
params[1] = app.getProxyTicket();
|
params[1] = app.getProxyTicket();
|
||||||
params[2] = param1 != null ? param1 : new HashMap<String, String>();
|
params[2] = param1 != null ? param1 : new HashMap<String, String>();
|
||||||
return xmlrpcCall(module + "." + operation, params);
|
return xmlrpcCall(module + "." + operation, params);
|
||||||
@ -44,7 +44,7 @@ public class Remote {
|
|||||||
|
|
||||||
private Object xmlrpcCall(String module, String operation, Map<String, String> param1, Map<String, String> param2) throws HsarwebException {
|
private Object xmlrpcCall(String module, String operation, Map<String, String> param1, Map<String, String> param2) throws HsarwebException {
|
||||||
Object[] params = new Object[4];
|
Object[] params = new Object[4];
|
||||||
params[0] = app.getLogin();
|
params[0] = app.getRunAs();
|
||||||
params[1] = app.getProxyTicket();
|
params[1] = app.getProxyTicket();
|
||||||
params[2] = param1 != null ? param1 : new HashMap<String, String>();
|
params[2] = param1 != null ? param1 : new HashMap<String, String>();
|
||||||
params[3] = param2 != null ? param2 : new HashMap<String, String>();
|
params[3] = param2 != null ? param2 : new HashMap<String, String>();
|
||||||
|
@ -22,7 +22,7 @@ public class UnixUserModule extends GenericModule {
|
|||||||
protected void initModule() {
|
protected void initModule() {
|
||||||
MainApplication application = getApplication();
|
MainApplication application = getApplication();
|
||||||
moduleConfig = new ModuleConfig("user", application.getLocale());
|
moduleConfig = new ModuleConfig("user", application.getLocale());
|
||||||
String login = application.getLogin();
|
String login = application.getRunAs();
|
||||||
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
|
||||||
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
|
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
|
||||||
pacProp.setSelectValues(new PropertySelectValues() {
|
pacProp.setSelectValues(new PropertySelectValues() {
|
||||||
|
Loading…
Reference in New Issue
Block a user