From 99694b29f82f858f5b6163e6a3d6c11caaeb487e Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 26 Jul 2013 17:07:15 +0200 Subject: Configuration Web-Application --- id/ConfigWebTool/.classpath | 38 ++++ id/ConfigWebTool/pom.xml | 49 +++++ .../moa/id/configuration/Constants.java | 11 + .../id/configuration/auth/AuthenticatedUser.java | 117 ++++++++++ .../config/ConfigurationProvider.java | 80 +++++++ .../moa/id/configuration/data/OAListElement.java | 77 +++++++ .../exception/ConfigurationException.java | 17 ++ .../configuration/filter/AuthenticationFilter.java | 236 +++++++++++++++++++++ .../id/configuration/helper/LanguageHelper.java | 34 +++ .../configuration/struts/action/IndexAction.java | 32 +++ .../configuration/struts/action/ListOAsAction.java | 112 ++++++++++ .../id/configuration/struts/action/MainAction.java | 65 ++++++ .../resources/applicationResources_de.properties | 25 +++ .../src/main/resources/log4j.properties | 20 ++ .../src/main/resources/struts.properties | 16 ++ id/ConfigWebTool/src/main/resources/struts.xml | 37 ++++ .../src/main/webapp/WEB-INF/log4j.properties | 20 ++ id/ConfigWebTool/src/main/webapp/WEB-INF/web.xml | 83 ++++++++ id/ConfigWebTool/src/main/webapp/css/index.css | 68 ++++++ id/ConfigWebTool/src/main/webapp/error.jsp | 22 ++ id/ConfigWebTool/src/main/webapp/index.action | 0 id/ConfigWebTool/src/main/webapp/index.jsp | 24 +++ id/ConfigWebTool/src/main/webapp/jsp/listOAs.jsp | 42 ++++ id/ConfigWebTool/src/main/webapp/jsp/mainpage.jsp | 27 +++ .../src/main/webapp/jsp/snippets/footer.jsp | 9 + .../main/webapp/jsp/snippets/header_userinfos.jsp | 12 ++ .../src/main/webapp/jsp/snippets/main_menu.jsp | 35 +++ 27 files changed, 1308 insertions(+) create mode 100644 id/ConfigWebTool/.classpath create mode 100644 id/ConfigWebTool/pom.xml create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/AuthenticatedUser.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/IndexAction.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ListOAsAction.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/MainAction.java create mode 100644 id/ConfigWebTool/src/main/resources/applicationResources_de.properties create mode 100644 id/ConfigWebTool/src/main/resources/log4j.properties create mode 100644 id/ConfigWebTool/src/main/resources/struts.properties create mode 100644 id/ConfigWebTool/src/main/resources/struts.xml create mode 100644 id/ConfigWebTool/src/main/webapp/WEB-INF/log4j.properties create mode 100644 id/ConfigWebTool/src/main/webapp/WEB-INF/web.xml create mode 100644 id/ConfigWebTool/src/main/webapp/css/index.css create mode 100644 id/ConfigWebTool/src/main/webapp/error.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/index.action create mode 100644 id/ConfigWebTool/src/main/webapp/index.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/jsp/listOAs.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/jsp/mainpage.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/jsp/snippets/header_userinfos.jsp create mode 100644 id/ConfigWebTool/src/main/webapp/jsp/snippets/main_menu.jsp diff --git a/id/ConfigWebTool/.classpath b/id/ConfigWebTool/.classpath new file mode 100644 index 000000000..28bcc0ce1 --- /dev/null +++ b/id/ConfigWebTool/.classpath @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/id/ConfigWebTool/pom.xml b/id/ConfigWebTool/pom.xml new file mode 100644 index 000000000..36eb9ddad --- /dev/null +++ b/id/ConfigWebTool/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + MOA.id + ConfigurationInterface + 0.9 + war + MOA-ID 2.0 Configuration Tool + Web based Configuration Tool for MOA-ID 2.x + + + + MOA.id.server + moa-id-commons + 1.5.2 + + + + at.gv.util + egovutils + 1.0.2 + + + + org.apache.struts + struts2-core + 2.3.14.3 + + + org.apache.struts + struts2-json-plugin + 2.3.14.3 + + + + log4j + log4j + 1.2.14 + + + commons-lang + commons-lang + 2.6 + jar + compile + + + + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java new file mode 100644 index 000000000..a5a5de33c --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java @@ -0,0 +1,11 @@ +package at.gv.egovernment.moa.id.configuration; + +public class Constants { + public static final String STRUTS_SUCCESS = "success"; + public static final String STRUTS_ERROR = "error"; + + + public static final String SESSION_AUTH = "authsession"; + public static final String SESSION_AUTH_ERROR = "authsessionerror"; + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/AuthenticatedUser.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/AuthenticatedUser.java new file mode 100644 index 000000000..3ff48e92b --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/AuthenticatedUser.java @@ -0,0 +1,117 @@ +package at.gv.egovernment.moa.id.configuration.auth; + +import java.util.Date; + +public class AuthenticatedUser { + + private boolean isAuthenticated = false; + private boolean isAdmin = false; + + private long userID; + private String givenName; + private String familyName; + private Date lastLogin; + + public AuthenticatedUser() { + + } + + public AuthenticatedUser(long userID, String givenName, String familyName, + boolean isAuthenticated, boolean isAdmin) { + + this.familyName = familyName; + this.givenName = givenName; + this.userID = userID; + this.isAdmin = isAdmin; + this.isAuthenticated = isAuthenticated; + this.lastLogin = new Date(); + } + + /** + * @return the isAuthenticated + */ + public boolean isAuthenticated() { + return isAuthenticated; + } + + /** + * @param isAuthenticated the isAuthenticated to set + */ + public void setAuthenticated(boolean isAuthenticated) { + this.isAuthenticated = isAuthenticated; + } + + /** + * @return the isAdmin + */ + public boolean isAdmin() { + return isAdmin; + } + + /** + * @param isAdmin the isAdmin to set + */ + public void setAdmin(boolean isAdmin) { + this.isAdmin = isAdmin; + } + + /** + * @return the userID + */ + public long getUserID() { + return userID; + } + + /** + * @param userID the userID to set + */ + public void setUserID(long userID) { + this.userID = userID; + } + + /** + * @return the givenName + */ + public String getGivenName() { + return givenName; + } + + /** + * @param givenName the givenName to set + */ + public void setGivenName(String givenName) { + this.givenName = givenName; + } + + /** + * @return the familyName + */ + public String getFamilyName() { + return familyName; + } + + /** + * @param familyName the familyName to set + */ + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + /** + * @return the lastLogin + */ + public Date getLastLogin() { + return lastLogin; + } + + /** + * @param lastLogin the lastLogin to set + */ + public void setLastLogin(Date lastLogin) { + this.lastLogin = lastLogin; + } + + + + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java new file mode 100644 index 000000000..07f599284 --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java @@ -0,0 +1,80 @@ +package at.gv.egovernment.moa.id.configuration.config; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; +import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; +import at.gv.egovernment.moa.logging.Logger; + + +public class ConfigurationProvider { + + private static final String SYSTEM_PROP_CONFIG = "moa.id.webconfig"; + + private static ConfigurationProvider instance; + private Properties props; + + public static ConfigurationProvider getInstance() throws ConfigurationException { + if (instance == null) { + instance = new ConfigurationProvider(); + } + + return instance; + } + + private ConfigurationProvider() throws ConfigurationException { + inizialize(); + } + + private void inizialize() throws ConfigurationException { + + String configFileName = System.getProperty(SYSTEM_PROP_CONFIG); + + if (configFileName == null) { + throw new ConfigurationException("config.01"); + } + Logger.info("Loading MOA-ID-AUTH configuration " + configFileName); + + //Initial Hibernate Framework + Logger.trace("Initializing Hibernate framework."); + + //Load MOAID-2.0 properties file + File propertiesFile = new File(configFileName); + FileInputStream fis; + props = new Properties(); + + + try { + fis = new FileInputStream(propertiesFile); + props.load(fis); + + // initialize hibernate + synchronized (ConfigurationProvider.class) { + + //Initial config Database + ConfigurationDBUtils.initHibernate(props); + } + Logger.trace("Hibernate initialization finished."); + + + + } catch (FileNotFoundException e) { + throw new ConfigurationException("config.01", e); + } catch (IOException e) { + throw new ConfigurationException("config.02", e); + } catch (MOADatabaseException e) { + throw new ConfigurationException("config.03", e); + } + + } + + public boolean isLoginDeaktivated() { + String result = props.getProperty("general.login.deaktivate", "false"); + return Boolean.parseBoolean(result); + } +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java new file mode 100644 index 000000000..0ea21617e --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java @@ -0,0 +1,77 @@ +package at.gv.egovernment.moa.id.configuration.data; + +public class OAListElement { + + private long dataBaseID; + private String oaIdentifier; + private String oaFriendlyName; + private String oaType; + private boolean isActive; + + + /** + * @return the dataBaseID + */ + public long getDataBaseID() { + return dataBaseID; + } + /** + * @param dataBaseID the dataBaseID to set + */ + public void setDataBaseID(long dataBaseID) { + this.dataBaseID = dataBaseID; + } + /** + * @return the oaIdentifier + */ + public String getOaIdentifier() { + return oaIdentifier; + } + /** + * @param oaIdentifier the oaIdentifier to set + */ + public void setOaIdentifier(String oaIdentifier) { + this.oaIdentifier = oaIdentifier; + } + /** + * @return the oaFriendlyName + */ + public String getOaFriendlyName() { + return oaFriendlyName; + } + /** + * @param oaFriendlyName the oaFriendlyName to set + */ + public void setOaFriendlyName(String oaFriendlyName) { + this.oaFriendlyName = oaFriendlyName; + } + /** + * @return the oaType + */ + public String getOaType() { + return oaType; + } + /** + * @param oaType the oaType to set + */ + public void setOaType(String oaType) { + this.oaType = oaType; + } + /** + * @return the isActive + */ + public boolean isActive() { + return isActive; + } + /** + * @param isActive the isActive to set + */ + public void setActive(boolean isActive) { + this.isActive = isActive; + } + + public String getIsActive(){ + return String.valueOf(isActive); + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java new file mode 100644 index 000000000..39a18309a --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java @@ -0,0 +1,17 @@ +package at.gv.egovernment.moa.id.configuration.exception; + +import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; + +public class ConfigurationException extends Exception { + + private static final long serialVersionUID = 1L; + + public ConfigurationException(String errorname) { + super(LanguageHelper.getErrorString(errorname, null)); + } + + public ConfigurationException(String errorname, Throwable e) { + super(LanguageHelper.getErrorString(errorname, null), e); + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java new file mode 100644 index 000000000..517786d11 --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java @@ -0,0 +1,236 @@ +package at.gv.egovernment.moa.id.configuration.filter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.StringTokenizer; +import java.util.regex.Pattern; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import at.gv.egovernment.moa.id.configuration.Constants; +import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; +import at.gv.egovernment.moa.util.MiscUtil; +import at.gv.util.ToStringUtil; +import at.gv.util.WebAppUtil; + +public class AuthenticationFilter implements Filter{ + + private final Logger log = Logger.getLogger(AuthenticationFilter.class); + + private static ConfigurationProvider config; + + public static final String STORED_REQUEST_URL_ID = String.class.getName() + ":" + "storedRequestURL"; + public static final String WEB_XML_INIT_PARAM_LOGIN_PAGE = "loginPage"; + public static final String WEB_XML_INIT_PARAM_ERROR_PAGE = "errorPage"; + public static final String WEB_XML_INIT_PARAM_AUTHENTICATED_PAGE = "authenticatedPage"; // optional + public static final String WEB_XML_INIT_PARAM_SESSION_LOST_PAGE = "sessionLostPage"; // optional + public static final String WEB_XML_INIT_PARAM_ALLOWED_LIST = "allowedList"; + public static final String WEB_XML_INIT_PARAM_ALLOWED_REGEX = "allowed"; + + private static final String WEB_XML_INIT_PARAM_EXCLUDED_PAGES_DELIMITER = ","; + + private static String loginPage = null; + private boolean loginPageForward = true; + private static String errorPage = null; + private static String authenticatedPage = null; + private static String sessionLostPage = null; + + private static String[] excludedPages = null; + private static Pattern excludedRegEx = null; + + + + public AuthenticationFilter() throws ServletException { + try { + config = ConfigurationProvider.getInstance(); + + } catch (ConfigurationException e) { + throw new ServletException(AuthenticationFilter.class + ": Configuration can not be loaded!", e); + } + } + + public static String getErrorPage() { + return errorPage; + } + + public static String getAuthenticatedPage() { + return authenticatedPage; + } + + public static String getLoginPage() { + return loginPage; + } + + public static String getSessionLostPage() { + return sessionLostPage; + } + + private boolean isExcluded(String url) { + boolean excluded = false; + if (MiscUtil.isNotEmpty(excludedPages)) { + for (String candidate : excludedPages) { + if (StringUtils.upperCase(url).endsWith(StringUtils.upperCase(candidate))) { + excluded = true; + break; + } + } + } + if (excludedRegEx != null && !excluded) { + // log.debug("Trying to match regex \"{}\" with \"{}\".", + // excludedRegEx.toString(), url); + if (excludedRegEx.matcher(url).matches()) { + excluded = true; + } + } + log.debug("URL \"" + url + "\" is " + (excluded ? "" : "NOT ") + "excluded from filter."); + return excluded; + } + + + public void destroy() { + log.trace("Shutting down" + this.getClass().getName() + "..."); + + } + + public void doFilter(ServletRequest req, ServletResponse resp, + FilterChain filterchain) throws IOException, ServletException { + + HttpServletRequest httpServletRequest = (HttpServletRequest) req; + HttpServletResponse httpServletResponse = (HttpServletResponse) resp; + + HttpSession session = httpServletRequest.getSession(); + + Object authuser = session.getAttribute(Constants.SESSION_AUTH); + + String requestURL = WebAppUtil.getRequestURLWithParameters(httpServletRequest, true); + + log.trace("Request URL: " + requestURL); + + if (authuser == null && !this.isExcluded(requestURL)) { + + if (config.isLoginDeaktivated()) { + //add dummy Daten + log.warn("Authentication is deaktivated. Dummy authentication-information are used!"); + + if (authuser == null) { + + authuser = new AuthenticatedUser(0000000, "Max", "TestUser", true, true); + httpServletRequest.getSession().setAttribute(Constants.SESSION_AUTH, authuser); + } + + if (MiscUtil.isNotEmpty(getAuthenticatedPage())) { + if (loginPageForward) { + log.debug("Authenticated page is set. Forwarding to \"" + getAuthenticatedPage() + "\"."); + RequestDispatcher dispatcher = req.getRequestDispatcher(getAuthenticatedPage()); + dispatcher.forward(httpServletRequest, httpServletResponse); + } else { + log.debug("Authenticated page is set. Redirecting to \"" + getAuthenticatedPage() + "\"."); + httpServletResponse.sendRedirect(httpServletResponse.encodeRedirectURL(getAuthenticatedPage())); + } + return; + } + + } else { + //check login Daten + if (MiscUtil.isNotEmpty(getAuthenticatedPage())) { + log.debug("Unable to find authentication data. Authenticated page is given so there is no need to save original request url. " + (loginPageForward ? "Forwarding" : "Redirecting") + " to login page \"" + loginPage + "\"."); + + } + else { + log.debug("Unable to find authentication data. Storing request url and " + (loginPageForward ? "forwarding" : "redirecting") + " to login page \"" + loginPage + "\"."); + // TODO: save HttpServletRequest + // log.debug("new CustomHttpServletRequest(request).toString() = + // {}", new + // CustomHttpServletRequest(httpServletRequest).toString()); + session.setAttribute(STORED_REQUEST_URL_ID, requestURL); + } + + if (loginPageForward) { + RequestDispatcher dispatcher = req.getRequestDispatcher(loginPage); + dispatcher.forward(httpServletRequest, httpServletResponse); + + } else { + httpServletResponse.sendRedirect(httpServletResponse.encodeRedirectURL(loginPage)); + + } + + } + } + + filterchain.doFilter(req, resp); + + } + + public void init(FilterConfig filterConfig) throws ServletException { + log.debug("Starting init of " + this.getClass().getName() + "."); + + // login page + loginPage = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_LOGIN_PAGE)); + if (MiscUtil.isEmpty(loginPage)) { + throw new ServletException("ServletInitParameter \"" + WEB_XML_INIT_PARAM_LOGIN_PAGE + "\" must not be empty."); + } + loginPageForward = false; //!WebAppUtil.isFullQualifiedURL(loginPage); + + // error page + errorPage = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_ERROR_PAGE)); + if (MiscUtil.isEmpty(errorPage)) { + throw new ServletException("ServletInitParameter \"" + WEB_XML_INIT_PARAM_ERROR_PAGE + "\" must not be empty."); + } + + // session lost page + sessionLostPage = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_SESSION_LOST_PAGE)); + if (MiscUtil.isEmpty(sessionLostPage)) { + log.warn("ServletInitParameter \"" + WEB_XML_INIT_PARAM_SESSION_LOST_PAGE + + "\" is empty. This parameter defines a failsafe url the browser is redirected to if the original url has been lost due to session timeout."); + } + + // authenticated page + authenticatedPage = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_AUTHENTICATED_PAGE)); + if (MiscUtil.isEmpty(authenticatedPage)) { + log.debug("ServletInitParameter \"" + WEB_XML_INIT_PARAM_AUTHENTICATED_PAGE + + "\" is empty. This parameter defines the url the user is redirected to (instead of the original url) on successful authentication."); + } + String excluded = filterConfig.getInitParameter(WEB_XML_INIT_PARAM_ALLOWED_LIST); + ArrayList excludedList = new ArrayList(); + if (MiscUtil.isNotEmpty(excluded)) { + StringTokenizer tokenizer = new StringTokenizer(excluded, WEB_XML_INIT_PARAM_EXCLUDED_PAGES_DELIMITER); + while (tokenizer.hasMoreTokens()) { + String ex = StringUtils.trim(tokenizer.nextToken()); + if (MiscUtil.isNotEmpty(ex)) { + excludedList.add(ex); + } + } + } + excludedList.add(loginPage); + excludedList.add(errorPage); + excludedPages = new String[excludedList.size()]; + excludedPages = excludedList.toArray(excludedPages); + + String excludedRegExString = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_ALLOWED_REGEX)); + if (MiscUtil.isNotEmpty(excludedRegExString)) { + excludedRegEx = Pattern.compile(excludedRegExString); + } + + log.debug(WEB_XML_INIT_PARAM_LOGIN_PAGE + " [" + (loginPageForward ? "forward" : "redirect") + "] = \"" + loginPage + "\""); + log.debug(WEB_XML_INIT_PARAM_AUTHENTICATED_PAGE + " = \"" + (MiscUtil.isNotEmpty(authenticatedPage) ? authenticatedPage : "") + "\""); + log.debug(WEB_XML_INIT_PARAM_ERROR_PAGE + " = \"" + errorPage + "\""); + log.debug(WEB_XML_INIT_PARAM_SESSION_LOST_PAGE + " = \"" + (MiscUtil.isNotEmpty(sessionLostPage) ? sessionLostPage : "") + "\""); + log.debug(WEB_XML_INIT_PARAM_ALLOWED_LIST + " = " + ToStringUtil.toString(excludedPages, ", ", "\"")); + log.debug(WEB_XML_INIT_PARAM_ALLOWED_REGEX + " = \"" + (excludedRegEx != null ? excludedRegEx.pattern() : "") + "\""); + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java new file mode 100644 index 000000000..80db5877c --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java @@ -0,0 +1,34 @@ +package at.gv.egovernment.moa.id.configuration.helper; + + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.servlet.http.HttpServletRequest; + + +public class LanguageHelper { + + private static ResourceBundle errorRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); + private static ResourceBundle guiRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); + + public static String getGUIString(String code, HttpServletRequest request) { + return guiRes_DE.getString(code); + } + + public static String getErrorString(String code, HttpServletRequest request) { + return errorRes_DE.getString(code); + } + + public static String getGUIString(String code, String parameter, HttpServletRequest request) { + + return MessageFormat.format(getGUIString(code, request), parameter); + } + + public static String getErrorString(String code, Object[] parameter, HttpServletRequest request) { + + return MessageFormat.format(getGUIString(code, request), parameter); + } +} + diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/IndexAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/IndexAction.java new file mode 100644 index 000000000..4e8e44007 --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/IndexAction.java @@ -0,0 +1,32 @@ +package at.gv.egovernment.moa.id.configuration.struts.action; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.apache.struts2.interceptor.ServletResponseAware; + +import at.gv.egovernment.moa.id.configuration.Constants; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; + +public class IndexAction implements ServletRequestAware, + ServletResponseAware { + + private HttpServletRequest request; + private HttpServletResponse response; + + public String start() { + + return Constants.STRUTS_SUCCESS; + } + + + public void setServletResponse(HttpServletResponse arg0) { + this.response = arg0; + } + public void setServletRequest(HttpServletRequest arg0) { + this.request = arg0; + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ListOAsAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ListOAsAction.java new file mode 100644 index 000000000..cc613ef7b --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ListOAsAction.java @@ -0,0 +1,112 @@ +package at.gv.egovernment.moa.id.configuration.struts.action; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.apache.struts2.interceptor.ServletResponseAware; + +import com.opensymphony.xwork2.ActionSupport; + +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; +import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +import at.gv.egovernment.moa.id.configuration.Constants; +import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.data.OAListElement; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; +import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; + +public class ListOAsAction extends ActionSupport implements ServletRequestAware, + ServletResponseAware { + + private static final long serialVersionUID = 1L; + + private HttpServletRequest request; + private HttpServletResponse response; + + private ConfigurationProvider configuration; + + private List formOAs; + + + private AuthenticatedUser authUser; + + + public ListOAsAction() throws ConfigurationException { + configuration = ConfigurationProvider.getInstance(); + } + + + public String listAllOnlineAppliactions() { + + Object authUserObj = request.getSession().getAttribute(Constants.SESSION_AUTH); + + if (authUserObj != null && authUserObj instanceof AuthenticatedUser) { + authUser = (AuthenticatedUser) authUserObj; + + List dbOAs = null; + + if (authUser.isAdmin()) { + dbOAs = ConfigurationDBRead.getAllOnlineApplications(); + + } else { + UserDatabase authUserDB = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + dbOAs = authUserDB.getRegistratedOAs(); + } + + + formOAs = new ArrayList(); + if (dbOAs == null) { + addActionError(LanguageHelper.getErrorString("errors.listOAs.noOA", request)); + return Constants.STRUTS_SUCCESS; + + } else { + for (OnlineApplication dboa : dbOAs) { + OAListElement listoa = new OAListElement(); + listoa.setActive(dboa.isIsActive()); + listoa.setDataBaseID(dboa.getHjid()); + listoa.setOaFriendlyName(dboa.getFriendlyName()); + listoa.setOaIdentifier(dboa.getPublicURLPrefix()); + listoa.setOaType(dboa.getType()); + formOAs.add(listoa); + } + } + + return Constants.STRUTS_SUCCESS; + + } + + return Constants.STRUTS_ERROR; + } + + + public void setServletResponse(HttpServletResponse arg0) { + this.response = arg0; + } + public void setServletRequest(HttpServletRequest arg0) { + this.request = arg0; + } + + + /** + * @return the authUser + */ + public AuthenticatedUser getAuthUser() { + return authUser; + } + + + /** + * @return the formOAs + */ + public List getFormOAs() { + return formOAs; + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/MainAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/MainAction.java new file mode 100644 index 000000000..ba9b0cc3f --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/MainAction.java @@ -0,0 +1,65 @@ +package at.gv.egovernment.moa.id.configuration.struts.action; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.apache.struts2.interceptor.ServletResponseAware; + +import at.gv.egovernment.moa.id.configuration.Constants; +import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; + +public class MainAction implements ServletRequestAware, + ServletResponseAware { + + private HttpServletRequest request; + private HttpServletResponse response; + + private ConfigurationProvider configuration; + + + private AuthenticatedUser authUser; + + + public MainAction() throws ConfigurationException { + configuration = ConfigurationProvider.getInstance(); + } + + + public String generateMainFrame() { + + Object authUserObj = request.getSession().getAttribute(Constants.SESSION_AUTH); + + if (authUserObj != null && authUserObj instanceof AuthenticatedUser) { + authUser = (AuthenticatedUser) authUserObj; + + + + + return Constants.STRUTS_SUCCESS; + } + return Constants.STRUTS_ERROR; + + } + + + public void setServletResponse(HttpServletResponse arg0) { + this.response = arg0; + } + public void setServletRequest(HttpServletRequest arg0) { + this.request = arg0; + } + + + /** + * @return the authUser + */ + public AuthenticatedUser getAuthUser() { + return authUser; + } + + + +} diff --git a/id/ConfigWebTool/src/main/resources/applicationResources_de.properties b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties new file mode 100644 index 000000000..14e6ba5be --- /dev/null +++ b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties @@ -0,0 +1,25 @@ +title=MOA-ID 2.x Configuration Tool + + +config.01=Configfile is not found. +config.02=Configfile is not readable. +config.03=Hibernate Database connector can not be initialized + +error.title=Fehler: +errors.listOAs.noOA=Es wurden keine Online-Applikationen in der Datenbank gefunden + + +webpages.error.header=Es ist ein Fehler aufgetreten +webpages.index.header=Willkommen beim MOA-ID 2.x Configuration Tool +webpages.index.desciption.head=Um dieses Service nutzen zu können müssen sie sich einloggen. + +webpages.mainpage.menu.oa.insert=Neue Applikation anlegen +webpages.mainpage.menu.oa.display=Meine Applikationen +webpages.mainpage.menu.oa.search=Applikation suchen +webpages.mainpage.menu.general.user=Meine Daten +webpages.mainpage.menu.general.importexport=Importieren/Exportieren +webpages.mainpage.menu.general.config.moaid=Allgemeine Konfiguration +webpages.mainpage.menu.general.usermanagement=Benutzerverwaltung + +webpages.header.info=Sie sind angemeldet als: +webpages.header.lastlogin=Letzte Anmeldung am: diff --git a/id/ConfigWebTool/src/main/resources/log4j.properties b/id/ConfigWebTool/src/main/resources/log4j.properties new file mode 100644 index 000000000..a264eaa85 --- /dev/null +++ b/id/ConfigWebTool/src/main/resources/log4j.properties @@ -0,0 +1,20 @@ +# Set root category priority to INFO and its only appender to CONSOLE. +log4j.rootCategory=INFO, CONSOLE +#log4j.rootCategory=INFO, CONSOLE, LOGFILE + +# Set the enterprise logger category to FATAL and its only appender to CONSOLE. +log4j.logger.at.gv.egovernment.moa.id.configuration=DEBUG, CONSOLE + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=INFO +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n + +# LOGFILE is set to be a File appender using a PatternLayout. +log4j.appender.LOGFILE=org.apache.log4j.FileAppender +log4j.appender.LOGFILE.File=axis.log +log4j.appender.LOGFILE.Append=true +log4j.appender.LOGFILE.Threshold=INFO +log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/id/ConfigWebTool/src/main/resources/struts.properties b/id/ConfigWebTool/src/main/resources/struts.properties new file mode 100644 index 000000000..2ef882658 --- /dev/null +++ b/id/ConfigWebTool/src/main/resources/struts.properties @@ -0,0 +1,16 @@ + + +# struts.configuration=org.apache.struts2.config.DefaultConfiguration + +# struts.multipart.parser=cos +# struts.multipart.parser=pell +struts.multipart.parser=jakarta +# uses javax.servlet.context.tempdir by default +struts.multipart.saveDir= +struts.multipart.maxSize=-1 + +struts.ui.theme=css_xhtml + +struts.devMode=false +struts.action.extension=action,, + diff --git a/id/ConfigWebTool/src/main/resources/struts.xml b/id/ConfigWebTool/src/main/resources/struts.xml new file mode 100644 index 000000000..9faaaeceb --- /dev/null +++ b/id/ConfigWebTool/src/main/resources/struts.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + /index.jsp + + + + + /error.jsp + + + + + /jsp/mainpage.jsp + /error.jsp + + + + + /jsp/listOAs.jsp + /error.jsp + + + + + + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/WEB-INF/log4j.properties b/id/ConfigWebTool/src/main/webapp/WEB-INF/log4j.properties new file mode 100644 index 000000000..3ca86f404 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/WEB-INF/log4j.properties @@ -0,0 +1,20 @@ +# Set root category priority to INFO and its only appender to CONSOLE. +log4j.rootCategory=INFO, CONSOLE +#log4j.rootCategory=INFO, CONSOLE, LOGFILE + +# Set the enterprise logger category to FATAL and its only appender to CONSOLE. +log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=INFO +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n + +# LOGFILE is set to be a File appender using a PatternLayout. +log4j.appender.LOGFILE=org.apache.log4j.FileAppender +log4j.appender.LOGFILE.File=axis.log +log4j.appender.LOGFILE.Append=true +log4j.appender.LOGFILE.Threshold=INFO +log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/id/ConfigWebTool/src/main/webapp/WEB-INF/web.xml b/id/ConfigWebTool/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..c680c875e --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,83 @@ + + + DemoAppMandates + + + + AuthenicationFiler + at.gv.egovernment.moa.id.configuration.filter.AuthenticationFilter + + loginPage + index.action + + + errorPage + error.action + + + sessionLostPage + / + + + authenticatedPage + main.action + + + allowed + ^.*((/index.action)|(/error.action)|(/jsp/.*)|(/css/.*)|(/images/.*)|(/js/.*))$ + + + + AuthenicationFiler + /* + + + + + + + struts2 + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + + + + + struts2 + *.action + + + + + + + /index.action + + diff --git a/id/ConfigWebTool/src/main/webapp/css/index.css b/id/ConfigWebTool/src/main/webapp/css/index.css new file mode 100644 index 000000000..838080186 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/css/index.css @@ -0,0 +1,68 @@ +@CHARSET "UTF-8"; + +#header_area { + height: 40px; + background-color: green; + display: block; +} + +#header_area>p { + font-size: 20px; + margin-left: 25px; + padding-top: 8px; +} + +#menu_area { + margin-top: 25px; + border-color: black; + border-style: solid; + border-width: 2px; + width: 250px; + margin-left: 15px; + position: relative; + padding-left: 15px; + float: left; + background-color: gray; + +} + +.menu_element { + margin-top: 15px; + margin-bottom: 15px; + font-size: 20px; + display: block; + background-color: red; + margin-right: 18px; + margin-top: 5px; + height: 30px; + border-radius: 10px; + padding-top: 5px; +} + +.menu_element>a { + padding: 5px; + margin-left: 5px; +} + +#information_area { + float: left; + padding-left: 25px; +} + + +#footer_area { + background-color: green; + clear: both; + display: block; + height: 40px; + margin-top: 15px; + padding-left: 30px; + position: relative; + top: 15px; +} + +#footer_area>p { + font-size: 20px; + text-align: center; + padding-top: 8px; +} diff --git a/id/ConfigWebTool/src/main/webapp/error.jsp b/id/ConfigWebTool/src/main/webapp/error.jsp new file mode 100644 index 000000000..79e701c76 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/error.jsp @@ -0,0 +1,22 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + + + + <%=LanguageHelper.getGUIString("title", request) %> + + + +

<%=LanguageHelper.getGUIString("webpages.error.header", request) %>

+ +
+ +
+ + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/index.action b/id/ConfigWebTool/src/main/webapp/index.action new file mode 100644 index 000000000..e69de29bb diff --git a/id/ConfigWebTool/src/main/webapp/index.jsp b/id/ConfigWebTool/src/main/webapp/index.jsp new file mode 100644 index 000000000..45587a9a8 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/index.jsp @@ -0,0 +1,24 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + + + + <%=LanguageHelper.getGUIString("title", request) %> + + + +

<%=LanguageHelper.getGUIString("webpages.index.header", request) %>

+ +
+

<%=LanguageHelper.getGUIString("webpages.index.desciption.head", request) %>

+
+ Login +
+ + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/jsp/listOAs.jsp b/id/ConfigWebTool/src/main/webapp/jsp/listOAs.jsp new file mode 100644 index 000000000..8e7b531c1 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/jsp/listOAs.jsp @@ -0,0 +1,42 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + + + + <%=LanguageHelper.getGUIString("title", request) %> + + + + + + + + +
+ +
+ + +
+
+ +
+ +
+      +
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/jsp/mainpage.jsp b/id/ConfigWebTool/src/main/webapp/jsp/mainpage.jsp new file mode 100644 index 000000000..798fdb742 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/jsp/mainpage.jsp @@ -0,0 +1,27 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + + + + <%=LanguageHelper.getGUIString("title", request) %> + + + + + + + + +
+

das ist ein Test Text

+
+ + + + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp b/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp new file mode 100644 index 000000000..a0f12eed4 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp @@ -0,0 +1,9 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/jsp/snippets/header_userinfos.jsp b/id/ConfigWebTool/src/main/webapp/jsp/snippets/header_userinfos.jsp new file mode 100644 index 000000000..a10b6e202 --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/jsp/snippets/header_userinfos.jsp @@ -0,0 +1,12 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + +
+

<%=LanguageHelper.getGUIString("webpages.header.info", request) %> + ,    + <%=LanguageHelper.getGUIString("webpages.header.lastlogin", request) %> +

+
+ \ No newline at end of file diff --git a/id/ConfigWebTool/src/main/webapp/jsp/snippets/main_menu.jsp b/id/ConfigWebTool/src/main/webapp/jsp/snippets/main_menu.jsp new file mode 100644 index 000000000..99447f4ca --- /dev/null +++ b/id/ConfigWebTool/src/main/webapp/jsp/snippets/main_menu.jsp @@ -0,0 +1,35 @@ +<%@page import="at.gv.egovernment.moa.id.configuration.helper.LanguageHelper"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + + \ No newline at end of file -- cgit v1.2.3