From 456513332389b2dbb7a6d1461f77dda9b7393050 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 14 Aug 2015 13:53:00 +0200 Subject: use old ConfigTool --- .../id/configuration/auth/AuthenticatedUser.java | 2 +- .../auth/pvp2/MetaDataVerificationFilter.java | 1 - .../config/ConfigurationProvider.java | 130 ++++++-- .../usermanagement/FileBasedUserConfiguration.java | 370 +++++++++++++++++++++ .../config/usermanagement/UserConfiguration.java | 6 + .../configuration/data/FormularCustomization.java | 21 +- .../id/configuration/data/GeneralMOAIDConfig.java | 54 ++- .../id/configuration/data/GeneralStorkConfig.java | 42 +-- .../id/configuration/data/oa/AttributeHelper.java | 4 +- .../data/oa/IOnlineApplicationData.java | 2 +- .../data/oa/OAAuthenticationData.java | 72 ++-- .../id/configuration/data/oa/OABPKEncryption.java | 8 +- .../id/configuration/data/oa/OAGeneralConfig.java | 4 +- .../data/oa/OAMOAIDPInterfederationConfig.java | 4 +- .../id/configuration/data/oa/OAOAuth20Config.java | 6 +- .../moa/id/configuration/data/oa/OAPVP2Config.java | 43 ++- .../configuration/data/oa/OARevisionsLogData.java | 153 +++++++++ .../id/configuration/data/oa/OASAML1Config.java | 6 +- .../moa/id/configuration/data/oa/OASSOConfig.java | 6 +- .../id/configuration/data/oa/OASTORKConfig.java | 40 ++- .../data/oa/OATargetConfiguration.java | 6 +- .../data/oa/PVPGatewayInterfederationConfig.java | 6 +- .../id/configuration/data/pvp2/ContactForm.java | 2 +- .../id/configuration/helper/FormDataHelper.java | 2 +- .../configuration/struts/action/BasicOAAction.java | 180 +++++++--- .../struts/action/EditGeneralConfigAction.java | 99 +++--- .../configuration/struts/action/EditOAAction.java | 84 ++--- .../struts/action/ImportExportAction.java | 263 +++++++++------ .../configuration/struts/action/IndexAction.java | 29 +- .../struts/action/InterfederationIDPAction.java | 49 ++- .../configuration/struts/action/ListOAsAction.java | 32 +- .../struts/action/OpenAdminRequestsAction.java | 7 +- .../struts/action/UserManagementAction.java | 38 +-- .../interceptor/HibernateSessionInterceptor.java | 116 ++++--- .../id/configuration/utils/UserRequestCleaner.java | 12 +- .../validation/UserDatabaseFormValidator.java | 23 +- .../validation/moaconfig/MOAConfigValidator.java | 22 +- .../validation/moaconfig/StorkConfigValidator.java | 10 +- .../validation/oa/OAPVP2ConfigValidation.java | 18 +- .../validation/oa/OASTORKConfigValidation.java | 2 +- 40 files changed, 1372 insertions(+), 602 deletions(-) create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/FileBasedUserConfiguration.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/UserConfiguration.java create mode 100644 id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java (limited to 'id/ConfigWebTool/src/main/java/at/gv') 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 index 3bfe409c0..bc964af4c 100644 --- 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 @@ -101,7 +101,7 @@ public class AuthenticatedUser { this.familyName = userdb.getFamilyname(); this.givenName = userdb.getGivenname(); this.userName = userdb.getUsername(); - this.userID = userdb.getHjid(); + this.userID = Long.valueOf(userdb.getHjid()); this.institute = userdb.getInstitut(); this.isAdmin = userdb.isIsAdmin(); this.isAuthenticated = isAuthenticated; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/pvp2/MetaDataVerificationFilter.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/pvp2/MetaDataVerificationFilter.java index 104ea51f5..12016a2bf 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/pvp2/MetaDataVerificationFilter.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/auth/pvp2/MetaDataVerificationFilter.java @@ -26,7 +26,6 @@ import java.util.Iterator; import org.opensaml.saml2.metadata.EntitiesDescriptor; import org.opensaml.saml2.metadata.EntityDescriptor; -import org.opensaml.saml2.metadata.provider.FilterException; import org.opensaml.saml2.metadata.provider.MetadataFilter; import org.opensaml.xml.XMLObject; import org.opensaml.xml.security.x509.BasicX509Credential; 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 index 0036645cf..849e81967 100644 --- 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 @@ -29,6 +29,8 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.security.KeyStore; import java.security.KeyStoreException; @@ -47,19 +49,24 @@ import org.opensaml.DefaultBootstrap; import org.opensaml.saml2.metadata.provider.HTTPMetadataProvider; import org.opensaml.xml.parse.BasicParserPool; import org.opensaml.xml.security.x509.BasicX509Credential; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; -import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; -import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException; import at.gv.egovernment.moa.id.commons.utils.MOAHttpProtocolSocketFactory; +import at.gv.egovernment.moa.id.config.webgui.MOAIDConfigurationModul; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.pvp2.MetaDataVerificationFilter; +import at.gv.egovernment.moa.id.configuration.config.usermanagement.FileBasedUserConfiguration; import at.gv.egovernment.moa.id.configuration.utils.UserRequestCleaner; import at.gv.egovernment.moa.util.FileUtils; import at.gv.egovernment.moa.util.MiscUtil; +import at.gv.egovernment.moa.id.commons.db.NewConfigurationDBRead; + public class ConfigurationProvider { @@ -82,6 +89,11 @@ public class ConfigurationProvider { private boolean pvp2logininitialzied = false; + private ApplicationContext context = null; + private MOAIDConfigurationModul configModule = null; + private NewConfigurationDBRead deprecatedDBRead = null; + private FileBasedUserConfiguration userManagement = null; + public static ConfigurationProvider getInstance() throws ConfigurationException { if (instance == null) { @@ -100,34 +112,40 @@ public class ConfigurationProvider { if (configFileName == null) { throw new ConfigurationException("config.05"); } + try { + URI fileURI = new URI(configFileName); + File propertiesFile = new File(fileURI); + + // determine the directory of the root config file + String rootConfigFileDir = propertiesFile.getParent(); + configRootDir = new File(rootConfigFileDir).toURI().toURL().toString();; - // determine the directory of the root config file - configRootDir = new File(configFileName).getParent(); - - log.info("Loading MOA-ID-AUTH configuration " + configFileName); + log.info("Loading MOA-ID-AUTH configuration " + configFileName); - //Initial Hibernate Framework - log.trace("Initializing Hibernate framework."); + //Initial Hibernate Framework + log.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); + //Load MOAID-2.0 properties file + + FileInputStream fis; + props = new Properties(); + + fis = new FileInputStream(propertiesFile); + props.load(fis); fis.close(); - // initialize hibernate - synchronized (ConfigurationProvider.class) { - - //Initial config Database - ConfigurationDBUtils.initHibernate(props); - } - log.trace("Hibernate initialization finished."); + context = new ClassPathXmlApplicationContext( + new String[] { "configuration.beans.xml", + "moaid.webgui.beans.xml", + "moaid.migration.beans.xml", + "moaid.configurationtool.beans.xml" + }); + AutowireCapableBeanFactory acbFactory = context.getAutowireCapableBeanFactory(); + acbFactory.autowireBean(this); + + + log.info("Hibernate initialization finished."); DefaultBootstrap.bootstrap(); log.info("OPENSAML initialized"); @@ -143,15 +161,48 @@ public class ConfigurationProvider { } catch (IOException e) { throw new ConfigurationException("config.02", new Object[]{configFileName}, e); - } catch (MOADatabaseException e) { - throw new ConfigurationException("config.03", e); - } catch (org.opensaml.xml.ConfigurationException e) { throw new ConfigurationException("config.04", e); + + } catch (URISyntaxException e) { + throw new ConfigurationException("config.01", new Object[]{configFileName}, e); } } + @Autowired(required = true) + public void setMOAIDConfigurationModul(MOAIDConfigurationModul module) { + this.configModule = module; + } + + + + /** + * @param dbRead the dbRead to set + */ + @Autowired(required = true) + public void setDbRead(NewConfigurationDBRead dbRead) { + this.deprecatedDBRead = dbRead; + } + + + + /** + * @return the deprecatedDBWrite + */ + public FileBasedUserConfiguration getUserManagement() { + return userManagement; + } + + /** + * @param deprecatedDBWrite the deprecatedDBWrite to set + */ + @Autowired(required = true) + public void setUserManagement(FileBasedUserConfiguration userManagement) { + this.userManagement = userManagement; + } + + public String getPublicUrlPreFix(HttpServletRequest request) { publicURLPreFix = props.getProperty("general.publicURLContext"); @@ -467,6 +518,29 @@ public class ConfigurationProvider { } + /** + * @return the context + */ + public ApplicationContext getContext() { + return context; + } + + /** + * @return the configModule + */ + public MOAIDConfigurationModul getConfigModule() { + return configModule; + } + + + + /** + * @return the dbRead + */ + public NewConfigurationDBRead getDbRead() { + return deprecatedDBRead; + } + private void initalPVP2Login() throws ConfigurationException { try { diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/FileBasedUserConfiguration.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/FileBasedUserConfiguration.java new file mode 100644 index 000000000..b1bba7289 --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/FileBasedUserConfiguration.java @@ -0,0 +1,370 @@ +package at.gv.egovernment.moa.id.configuration.config.usermanagement; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.commons.collections4.map.HashedMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.components.configuration.api.Configuration; +import at.gv.egiz.components.configuration.api.ConfigurationException; +import at.gv.egiz.components.configuration.file.PropertiesBasedConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; +import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils; +import at.gv.egovernment.moa.util.MiscUtil; + + +public class FileBasedUserConfiguration + implements UserConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(FileBasedUserConfiguration.class); + public static final String CONFIG_FILE_PROPERTY = "user.properties"; + + private Configuration userconfig; + + public FileBasedUserConfiguration() { + String cfgFile = System.getProperty(CONFIG_FILE_PROPERTY); + if(cfgFile == null) { + throw new RuntimeException("Please configure " + CONFIG_FILE_PROPERTY + " to provide user database"); + } + + try { + userconfig = new PropertiesBasedConfiguration(new File(cfgFile)); + + } catch (IOException | ConfigurationException e) { + logger.error("Failed to build configuration in user modul!"); + throw new RuntimeException(e); + + } + } + + /** + * + * @return + */ + public List getAllUsers() { + logger.trace("Get All Users from database."); + + // select userdatabase from UserDatabase userdatabase + List result = new ArrayList(); + try { + String[] userIDs = userconfig.getConfigurationIdNextLevel(UserDatabase.PREFIX); + for (String userID : userIDs) { + String[] userKeys = userconfig.findConfigurationId(UserDatabase.PREFIX + "." + userID + ".*"); + Map keyValue = new HashMap(); + if (userKeys.length > 0) { + for (String key : userKeys) { + keyValue.put( + KeyValueUtils.removePrefixFromKey( + key, UserDatabase.PREFIX + "." + userID + "."), + userconfig.getStringValue(key)); + } + UserDatabase userDAO = new UserDatabase(keyValue); + userDAO.setHjid(userID); + result.add(userDAO); + } + } + + if (result.size() == 0) { + logger.trace("No entries found."); + return null; + } + + return result; + + } catch (ConfigurationException e) { + logger.error("Access UserDatabase FAILED", e); + return null; + + } + } + + /** + * + * @return + */ + public List getAllOpenUsersRequests() { + logger.trace("Get all new Users from Database"); + + // select userdatabase from UserDatabase userdatabase + // where userdatabase.userRequestTokken is not null + // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0' + List result = new ArrayList(); + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?) + if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL")) + && (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) { + result.add(user); + } + } + + if (result.size() == 0) { + logger.trace("No entries found."); + return null; + } + + return result; + } + + /** + * + * @param tokken + * @return + */ + public UserDatabase getNewUserWithTokken(String tokken) { + logger.trace("Getting Userinformation with Tokken " + tokken + " from database."); + + // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken + UserDatabase result = null; + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + if (user.getUserRequestTokken() != null && + user.getUserRequestTokken().equals(tokken)) { + result = user; + break; + } + } + + return result; + } + + /** + * + * @param id + * @return + */ + public UserDatabase getUsersWithOADBID(long id) { + logger.trace("Getting Userinformation with OADBID " + id + " from database."); + + // select userdatabase from UserDatabase userdatabase + // inner join userdatabase.onlineApplication oa where oa.hjid = :id + UserDatabase result = null; + List allUsers = getAllUsers(); + + boolean quit = false; + for (UserDatabase user : nullGuard(allUsers)) { + + for (String oa : user.getOnlineApplication()) { + + if (oa.equals(String.valueOf(id))) { + result = user; + quit = true; + break; + } + } + + if (quit) { + break; + } + } + + return result; + } + + /** + * + * @param id + * @return + */ + public UserDatabase getUserWithID(long id) { + logger.trace("Getting Userinformation with ID " + id + " from database."); + + // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id + UserDatabase result = null; + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + if (user.getHjid().equals(String.valueOf(id))) { + result = user; + break; + } + } + + return result; + } + + /** + * + * @param username + * @return + */ + public UserDatabase getUserWithUserName(String username) { + logger.trace("Getting Userinformation with ID " + username + " from database."); + + // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username + UserDatabase result = null; + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + if (user.getUsername().equals(username)) { + result = user; + break; + } + } + + return result; + } + + /** + * + * @param bpkwbpk + * @return + */ + public UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { + logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); + + // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk + UserDatabase result = null; + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + if (user.getBpk() != null && + user.getBpk().equals(bpkwbpk)) { + result = user; + break; + } + } + + return result; + } + + /** + * @return + */ + public List getAllNewUsers() { + List result = new ArrayList(); + List allUsers = getAllUsers(); + + for (UserDatabase user : nullGuard(allUsers)) { + // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?) + if (((user.getUserRequestTokken() == null || user.getUserRequestTokken().isEmpty() || user.getUserRequestTokken().equals("NULL"))) + && (user.isIsAdminRequest()) && (user.isIsMailAddressVerified())) { + result.add(user); + } + } + + if (result.size() == 0) { + logger.trace("No entries found."); + return null; + } + + return result; + } + + + /** + * @param user + */ + public void saveOrUpdate(UserDatabase user) throws MOADatabaseException{ + List allUsers = getAllUsers(); + + if (allUsers == null) { + Set> keySet = user.getKeyValuePairs().entrySet(); + for (Entry el : keySet) { + try { + if (MiscUtil.isNotEmpty(el.getValue())) { + userconfig.setStringValue(UserDatabase.PREFIX + ".0." + el.getKey(), + el.getValue()); + } + + } catch (ConfigurationException e) { + logger.error("Can not store Userentry with key: " + UserDatabase.PREFIX + ".0." + el.getKey(), e); + } + + } + + + } else { + boolean isUpdated = false; + for (UserDatabase dbUser : allUsers) { + if (dbUser.getHjid().equals(user.getHjid())) { + logger.debug("User is already stored -> start update process ..."); + Set> keySet = user.getKeyValuePairs().entrySet(); + for (Entry el : keySet) { + try { + if (MiscUtil.isNotEmpty(el.getValue())) + userconfig.setStringValue(UserDatabase.PREFIX + "." + user.getHjid() + "." + el.getKey(), + el.getValue()); + + } catch (ConfigurationException e) { + logger.error("Can not store Userentry with key: " + UserDatabase.PREFIX + "." + user.getHjid() + "." + el.getKey(), e); + } + + } + isUpdated = true; + break; + } + } + if (!isUpdated) { + try { + String[] temp = userconfig.findConfigurationId(UserDatabase.PREFIX + ".*." + UserDatabase.ISACTIVE); + int newID = KeyValueUtils.findNextFreeListCounter(temp, UserDatabase.PREFIX); + + logger.debug("Add new User with ID:" + String.valueOf(newID)); + Set> keySet = user.getKeyValuePairs().entrySet(); + for (Entry el : keySet) { + try { + if (MiscUtil.isNotEmpty(el.getValue())) + userconfig.setStringValue(UserDatabase.PREFIX + "." + String.valueOf(newID) + "." + el.getKey(), + el.getValue()); + + } catch (ConfigurationException e) { + logger.error("Can not store Userentry with key: " + UserDatabase.PREFIX + "." + String.valueOf(newID) + "." + el.getKey(), e); + } + + } + } catch (ConfigurationException e) { + logger.error("Access UserDatabase FAILED", e); + + } + } + } + + try { + userconfig.synchronize(); + + } catch (ConfigurationException e) { + logger.error("Access UserDatabase FAILED", e); + } + + } + + /** + * @param dbuser + */ + public void delete(UserDatabase dbuser) { + try { + logger.debug("Delete User with ID: " + dbuser.getHjid()); + userconfig.deleteIds(UserDatabase.PREFIX + "." + dbuser.getHjid() + "*"); + userconfig.synchronize(); + + } catch (ConfigurationException e) { + logger.error("Access UserManagement Database FAILED!", e); + + } + + } + + @SuppressWarnings("unchecked") + public static > T nullGuard(T item) { + if (item == null) { + return (T) Collections.emptyList(); + } else { + return item; + } + + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/UserConfiguration.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/UserConfiguration.java new file mode 100644 index 000000000..f894b510b --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/usermanagement/UserConfiguration.java @@ -0,0 +1,6 @@ +package at.gv.egovernment.moa.id.configuration.config.usermanagement; + + +public interface UserConfiguration { + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java index 504a38800..e2d473f8a 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java @@ -36,11 +36,12 @@ import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.BKUSelectionCustomizationType; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BKUSelectionCustomizationType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TemplatesType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; @@ -137,12 +138,18 @@ public class FormularCustomization implements IOnlineApplicationData { aditionalAuthBlockText = templates.getAditionalAuthBlockText(); TransformsInfoType bkuSelectTemplate = templates.getBKUSelectionTemplate(); - if (bkuSelectTemplate != null && MiscUtil.isNotEmpty(bkuSelectTemplate.getFilename())) { + if (bkuSelectTemplate != null + && MiscUtil.isNotEmpty(bkuSelectTemplate.getFilename()) + && !bkuSelectTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) + && !bkuSelectTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { bkuSelectionFileUploadFileName.add(bkuSelectTemplate.getFilename()); } TransformsInfoType sendAssertionTemplate = templates.getSendAssertionTemplate(); - if (sendAssertionTemplate != null && MiscUtil.isNotEmpty(sendAssertionTemplate.getFilename())) { + if (sendAssertionTemplate != null + && MiscUtil.isNotEmpty(sendAssertionTemplate.getFilename()) + && !sendAssertionTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) + && !sendAssertionTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { sendAssertionFileUploadFileName.add(sendAssertionTemplate.getFilename()); } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java index def880da8..bcf99d246 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java @@ -28,34 +28,32 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; -import at.gv.egovernment.moa.id.commons.db.dao.config.ConnectionParameterClientAuthType; -import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; -import at.gv.egovernment.moa.id.commons.db.dao.config.GeneralConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; -import at.gv.egovernment.moa.id.commons.db.dao.config.LegacyAllowed; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOASP; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAuth; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineMandates; -import at.gv.egovernment.moa.id.commons.db.dao.config.Organization; -import at.gv.egovernment.moa.id.commons.db.dao.config.PVP2; -import at.gv.egovernment.moa.id.commons.db.dao.config.Protocols; -import at.gv.egovernment.moa.id.commons.db.dao.config.SAML1; -import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; -import at.gv.egovernment.moa.id.commons.db.dao.config.SSO; -import at.gv.egovernment.moa.id.commons.db.dao.config.STORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.SecurityLayer; -import at.gv.egovernment.moa.id.commons.db.dao.config.TimeOuts; -import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TrustAnchor; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyAuthBlock; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyIdentityLink; -import at.gv.egovernment.moa.id.config.legacy.ConfigurationBuilder; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModeType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModes; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ConnectionParameterClientAuthType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Contact; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.DefaultBKUs; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.GeneralConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.LegacyAllowed; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOASP; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAuth; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineMandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Organization; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.PVP2; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Protocols; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SAML1; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SLRequestTemplates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SSO; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SecurityLayer; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TimeOuts; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TrustAnchor; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyAuthBlock; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyIdentityLink; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.data.pvp2.ContactForm; import at.gv.egovernment.moa.util.MiscUtil; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java index c830e682d..d8bb0179c 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java @@ -25,15 +25,14 @@ package at.gv.egovernment.moa.id.configuration.data; import java.util.ArrayList; import java.util.List; -import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfigurationImpl; -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.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; -import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.STORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; +import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import org.apache.log4j.Logger; @@ -49,18 +48,17 @@ public class GeneralStorkConfig { /** * */ - public GeneralStorkConfig() { - - dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); - + public GeneralStorkConfig() { + try { + dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); + + } catch (ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + + } + } - - @Override - protected void finalize() throws Throwable { - ConfigurationDBUtils.closeSession(); - super.finalize(); - } - + public void parse(MOAIDConfiguration config) { log.info("Initializing general Stork config"); @@ -108,6 +106,10 @@ public class GeneralStorkConfig { } } + public List getRawCPEPSList() { + return cpepslist; + } + public List getCpepslist() { if (null == cpepslist) return null; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java index 012e8121f..63c82037f 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java @@ -1,7 +1,7 @@ package at.gv.egovernment.moa.id.configuration.data.oa; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAStorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; public class AttributeHelper { private boolean isUsed = false; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java index 37f8fbc07..8195c993d 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java @@ -26,7 +26,7 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; /** diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java index a9c914f74..0c633f312 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java @@ -29,20 +29,18 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; -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.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.BKUURLS; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAKeyBoxSelector; -import at.gv.egovernment.moa.id.commons.db.dao.config.Mandates; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.TemplateType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TestCredentials; -import at.gv.egovernment.moa.id.commons.db.dao.config.TestCredentialsCredentialOIDItem; -import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BKUURLS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.DefaultBKUs; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAKeyBoxSelector; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Mandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TemplateType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TemplatesType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TestCredentials; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TestCredentialsCredentialOIDItem; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OAAuthenticationDataValidation; @@ -86,18 +84,18 @@ public class OAAuthenticationData implements IOnlineApplicationData { keyBoxIdentifier = MOAKeyBoxSelector.SECURE_SIGNATURE_KEYPAIR.value(); - bkuLocalURL = Constants.DEFAULT_LOCALBKU_URL; - bkuHandyURL = Constants.DEFAULT_HANDYBKU_URL; - - MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); - if (moaidconfig != null) { - DefaultBKUs defaultbkus = moaidconfig.getDefaultBKUs(); - if (defaultbkus != null) { - setBkuHandyURL(defaultbkus.getHandyBKU()); - setBkuLocalURL(defaultbkus.getLocalBKU()); - setBkuOnlineURL(defaultbkus.getOnlineBKU()); - } - } +// bkuLocalURL = Constants.DEFAULT_LOCALBKU_URL; +// bkuHandyURL = Constants.DEFAULT_HANDYBKU_URL; +// +// MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); +// if (moaidconfig != null) { +// DefaultBKUs defaultbkus = moaidconfig.getDefaultBKUs(); +// if (defaultbkus != null) { +// setBkuHandyURL(defaultbkus.getHandyBKU()); +// setBkuLocalURL(defaultbkus.getLocalBKU()); +// setBkuOnlineURL(defaultbkus.getOnlineBKU()); +// } +// } } /* (non-Javadoc) @@ -123,15 +121,15 @@ public class OAAuthenticationData implements IOnlineApplicationData { String defaultlocal = ""; String defaultonline = ""; - MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); - if (dbconfig != null) { - DefaultBKUs defaultbkus = dbconfig.getDefaultBKUs(); - if (defaultbkus != null) { - defaulthandy = defaultbkus.getHandyBKU(); - defaultlocal = defaultbkus.getLocalBKU(); - defaultonline = defaultbkus.getOnlineBKU(); - } - } +// MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); +// if (dbconfig != null) { +// DefaultBKUs defaultbkus = dbconfig.getDefaultBKUs(); +// if (defaultbkus != null) { +// defaulthandy = defaultbkus.getHandyBKU(); +// defaultlocal = defaultbkus.getLocalBKU(); +// defaultonline = defaultbkus.getOnlineBKU(); +// } +// } if (bkuurls != null) { @@ -318,8 +316,8 @@ public class OAAuthenticationData implements IOnlineApplicationData { if (enableTestCredentials) { TestCredentials testing = authoa.getTestCredentials(); - if (testing != null) - ConfigurationDBUtils.delete(testing); +// if (testing != null) +// ConfigurationDBUtils.delete(testing); testing = new TestCredentials(); authoa.setTestCredentials(testing); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java index 6782987e5..58b0b9d17 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java @@ -36,10 +36,10 @@ import org.apache.commons.lang.SerializationUtils; import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.auth.exception.BuildException; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.BPKDecryption; -import at.gv.egovernment.moa.id.commons.db.dao.config.EncBPKInformation; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BPKDecryption; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.EncBPKInformation; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.config.auth.data.BPKDecryptionParameters; import at.gv.egovernment.moa.id.configuration.Constants; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java index 05e163c23..22a978014 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java @@ -29,8 +29,8 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java index 2f9df18aa..a4d71f0ed 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java @@ -29,8 +29,8 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.InterfederationIDPType; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java index b95090a55..ce50c847a 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java @@ -32,9 +32,9 @@ import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAOAUTH20; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAOAUTH20; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java index bcac63a5f..07c9f5eda 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java @@ -35,12 +35,14 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; import iaik.x509.X509Certificate; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAPVP2; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAPVP2; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.validation.oa.OAPVP2ConfigValidation; +import at.gv.egovernment.moa.util.Base64Utils; import at.gv.egovernment.moa.util.MiscUtil; public class OAPVP2Config implements IOnlineApplicationData{ @@ -133,16 +135,33 @@ public class OAPVP2Config implements IOnlineApplicationData{ if (pvp2 != null) { metaDataURL = pvp2.getMetadataURL(); - try { - byte[] cert = pvp2.getCertificate(); - - if (MiscUtil.isNotEmpty(cert)) { - X509Certificate x509 = new X509Certificate(cert); - certificateDN = x509.getSubjectDN().getName(); + if (pvp2.getCertificate() != null && + !(new String(pvp2.getCertificate())).equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT)) { + try { + //byte[] cert = pvp2.getCertificate(); + byte[] cert = Base64Utils.decode(new String(pvp2.getCertificate()), false); + if (MiscUtil.isNotEmpty(cert)) { + X509Certificate x509 = new X509Certificate(cert); + certificateDN = x509.getSubjectDN().getName(); + } + } catch (CertificateException e) { + try { + byte[] cert = pvp2.getCertificate(); + if (MiscUtil.isNotEmpty(cert)) { + X509Certificate x509 = new X509Certificate(cert); + certificateDN = x509.getSubjectDN().getName(); + } + + } catch (CertificateException e1) { + log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig.getPublicURLPrefix(), e1); + errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); + + } + + } catch (IOException e) { + log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig.getPublicURLPrefix()); + errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); } - } catch (CertificateException e) { - log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig.getPublicURLPrefix()); - errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); } } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java new file mode 100644 index 000000000..441c879be --- /dev/null +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java @@ -0,0 +1,153 @@ +/* + * Copyright 2014 Federal Chancellery Austria + * MOA-ID has been developed in a cooperation between BRZ, the Federal + * Chancellery Austria - ICT staff unit, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ +package at.gv.egovernment.moa.id.configuration.data.oa; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils; +import at.gv.egovernment.moa.id.config.webgui.exception.ValidationObjectIdentifier; +import at.gv.egovernment.moa.id.config.webgui.helper.LanguageHelper; +import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; +import at.gv.egovernment.moa.util.MiscUtil; + +/** + * @author tlenz + * + */ +public class OARevisionsLogData implements IOnlineApplicationData { + + private boolean active = false; + private String eventCodes = null; + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() + */ + @Override + public String getName() { + return "OARevisionsLogging"; + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) + */ + @Override + public List parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + + if (dbOA.getIsRevisionsLogActive() != null) + active = dbOA.getIsRevisionsLogActive(); + + if (MiscUtil.isNotEmpty(dbOA.getEventCodes())) + eventCodes = dbOA.getEventCodes(); + + return null; + + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + dbOA.setIsRevisionsLogActive(active); + + if (MiscUtil.isNotEmpty(eventCodes)) { + dbOA.setEventCodes(KeyValueUtils.normalizeCSVValueString(eventCodes)); + + } + + return null; + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) + */ + @Override + public List validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + List errors = new ArrayList(); + + if (active && MiscUtil.isEmpty(eventCodes)) { + errors.add(LanguageHelper.getErrorString( + "error.oa.reversion.log.enabled")); + + } + + if (MiscUtil.isNotEmpty(eventCodes)) { + String[] codes = eventCodes.split(","); + for (String el: codes) { + try { + Integer.parseInt(el.trim()); + + } catch (NumberFormatException e) { + errors.add(LanguageHelper.getErrorString( + "error.oa.reversion.log.eventcodes")); + break; + + } + + } + + } + + return errors; + } + + /** + * @return the active + */ + public boolean isActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(boolean active) { + this.active = active; + } + + /** + * @return the eventCodes + */ + public String getEventCodes() { + return eventCodes; + } + + /** + * @param eventCodes the eventCodes to set + */ + public void setEventCodes(String eventCodes) { + this.eventCodes = eventCodes; + } + + + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java index 7b5575a90..2922231b3 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java @@ -27,9 +27,9 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASAML1; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASAML1; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OASAML1ConfigValidation; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java index 28144666b..1baefe4b8 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java @@ -26,9 +26,9 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASSO; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASSO; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OASSOConfigValidation; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java index e0a312c09..d26fe8a89 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java @@ -29,17 +29,17 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -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.AttributeProviderPlugin; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASTORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AttributeProviderPlugin; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASTORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAStorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; +import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; 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.validation.oa.OASTORKConfigValidation; import at.gv.egovernment.moa.id.protocols.stork2.AttributeProviderFactory; @@ -66,25 +66,23 @@ public class OASTORKConfig implements IOnlineApplicationData{ public OASTORKConfig() { // fetch available citizen countries citizenCountries = new ArrayList(); + try { + dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); - dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); - try { for(CPEPS current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS()) { citizenCountries.add(current.getCountryCode()); } }catch (NullPointerException e) { + } catch (ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + } } - @Override - protected void finalize() throws Throwable { - ConfigurationDBUtils.closeSession(); - super.finalize(); - } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() @@ -111,7 +109,13 @@ public class OASTORKConfig implements IOnlineApplicationData{ setQaa(config.getQaa()); } catch(NullPointerException e) { // if there is no configuration available for the OA, get the default qaa level - setQaa(dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getQualityAuthenticationAssuranceLevel()); + try { + setQaa(dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getQualityAuthenticationAssuranceLevel()); + + } catch (NullPointerException e1) { + setQaa(4); + + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java index bb7bac4f8..19671e502 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java @@ -27,9 +27,9 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentificationNumber; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.TargetValidator; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java index 23af59d8e..e27c55c90 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java @@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.InterfederationGatewayType; -import at.gv.egovernment.moa.id.commons.db.dao.config.InterfederationIDPType; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationGatewayType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/pvp2/ContactForm.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/pvp2/ContactForm.java index 01615a056..664e94377 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/pvp2/ContactForm.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/pvp2/ContactForm.java @@ -25,7 +25,7 @@ package at.gv.egovernment.moa.id.configuration.data.pvp2; import java.util.ArrayList; import java.util.List; -import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Contact; public class ContactForm { diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/FormDataHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/FormDataHelper.java index e5ee5ac09..b4afcb5f2 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/FormDataHelper.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/FormDataHelper.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.data.OAListElement; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java index 04715027a..45674a283 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/BasicOAAction.java @@ -36,13 +36,18 @@ import java.util.Map; import org.apache.log4j.Logger; +import edu.emory.mathcs.backport.java.util.Arrays; + +import at.gv.egiz.components.configuration.meta.api.ConfigurationStorageException; import at.gv.egovernment.moa.id.auth.builder.LoginFormBuilder; -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.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.config.ConfigurationMigrationUtils; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; +import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.Constants; @@ -100,10 +105,10 @@ public class BasicOAAction extends BasicAction { OnlineApplication onlineapplication = null; if (authUser.isAdmin()) - onlineapplication = ConfigurationDBRead.getOnlineApplication(oaid); + onlineapplication = configuration.getDbRead().getOnlineApplication(oaid); else { - userdb = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + userdb = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (!authUser.isAdmin() && userdb.isIsMailAddressVerified() != null && !userdb.isIsMailAddressVerified()) { log.info("Online-Applikation managemant disabled. Mail address is not verified."); @@ -114,10 +119,10 @@ public class BasicOAAction extends BasicAction { } // TODO: change to direct Database operation - List oas = userdb.getOnlineApplication(); - for (OnlineApplication oa : oas) { - if (oa.getHjid() == oaid) { - onlineapplication = oa; + List oas = userdb.getOnlineApplication(); + for (String oa : oas) { + if (oa.equals(oaid)) { + onlineapplication = configuration.getDbRead().getOnlineApplication(oaid); break; } } @@ -173,7 +178,7 @@ public class BasicOAAction extends BasicAction { UserDatabase userdb = null; if (onlineapplication.getHjid() != null) - userdb = ConfigurationDBRead.getUsersWithOADBID(onlineapplication.getHjid()); + userdb = configuration.getUserManagement().getUsersWithOADBID(onlineapplication.getHjid()); if (userdb != null && !userdb.isIsAdmin()) { try { @@ -197,27 +202,27 @@ public class BasicOAAction extends BasicAction { throw new BasicOAActionException(error, Constants.STRUTS_ERROR_VALIDATION); } - //set metadata reload flag if reload is required - - if (getPvp2OA() != null && getPvp2OA().getMetaDataURL() != null) { - - try { - if (isMetaDataRefreshRequired - || !getPvp2OA().getMetaDataURL().equals(onlineapplication.getAuthComponentOA().getOAPVP2().getMetadataURL()) - || getPvp2OA().getFileUpload() != null - || getPvp2OA().isReLoad()) { - - log.debug("Set PVP2 Metadata refresh flag."); - MOAIDConfiguration moaconfig = ConfigurationDBRead.getMOAIDConfiguration(); - moaconfig.setPvp2RefreshItem(new Date()); - ConfigurationDBUtils.saveOrUpdate(moaconfig); - - } - } catch (Throwable e) { - log.info("Found no MetadataURL in OA-Databaseconfig!", e); - } - - } +// //set metadata reload flag if reload is required +// +// if (getPvp2OA() != null && getPvp2OA().getMetaDataURL() != null) { +// +// try { +// if (isMetaDataRefreshRequired +// || !getPvp2OA().getMetaDataURL().equals(onlineapplication.getAuthComponentOA().getOAPVP2().getMetadataURL()) +// || getPvp2OA().getFileUpload() != null +// || getPvp2OA().isReLoad()) { +// +// log.debug("Set PVP2 Metadata refresh flag."); +// MOAIDConfiguration moaconfig = configuration.getDbRead().getMOAIDConfiguration(); +// moaconfig.setPvp2RefreshItem(new Date()); +// ConfigurationDBUtils.saveOrUpdate(moaconfig); +// +// } +// } catch (Throwable e) { +// log.info("Found no MetadataURL in OA-Databaseconfig!", e); +// } +// +// } return onlineapplication; } @@ -242,7 +247,7 @@ public class BasicOAAction extends BasicAction { } session.setAttribute(Constants.SESSION_FORMID, null); - UserDatabase userdb = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase userdb = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (!authUser.isAdmin() && userdb.isIsMailAddressVerified() != null && !userdb.isIsMailAddressVerified()) { log.info("Online-Applikation managemant disabled. Mail address is not verified."); throw new BasicOAActionException( @@ -292,7 +297,7 @@ public class BasicOAAction extends BasicAction { } else { if (oaid == -1) { - List oaList = ConfigurationDBRead.getAllOnlineApplications(); + List oaList = configuration.getDbRead().getAllOnlineApplications(); if (oaList != null) { for (OnlineApplication el : oaList) { @@ -303,7 +308,7 @@ public class BasicOAAction extends BasicAction { } if (onlineapplication == null) { - onlineapplication = ConfigurationDBRead.getOnlineApplication(oaidentifier); + onlineapplication = configuration.getDbRead().getOnlineApplication(oaidentifier); } setNewOA(true); @@ -316,18 +321,18 @@ public class BasicOAAction extends BasicAction { } } else { - onlineapplication = ConfigurationDBRead.getOnlineApplication(oaid); + onlineapplication = configuration.getDbRead().getOnlineApplication(oaid); if (!oaidentifier.equals(onlineapplication.getPublicURLPrefix())) { OnlineApplication dbOA = null; - List oaList = ConfigurationDBRead.getAllOnlineApplications(); + List oaList = configuration.getDbRead().getAllOnlineApplications(); for (OnlineApplication el : oaList) { if (el.getPublicURLPrefix().startsWith(oaidentifier) ) dbOA = el; } if (dbOA == null) - dbOA = ConfigurationDBRead.getOnlineApplication(oaidentifier); + dbOA = configuration.getDbRead().getOnlineApplication(oaidentifier); if ( (dbOA != null && !dbOA.getHjid().equals(oaid))) { log.info("The OAIdentifier is not unique"); @@ -376,7 +381,7 @@ public class BasicOAAction extends BasicAction { } session.setAttribute(Constants.SESSION_FORMID, null); - UserDatabase userdb = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase userdb = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (!authUser.isAdmin() && userdb.isIsMailAddressVerified() != null && !userdb.isIsMailAddressVerified()) { log.info("Online-Applikation managemant disabled. Mail address is not verified."); throw new BasicOAActionException( @@ -426,23 +431,23 @@ public class BasicOAAction extends BasicAction { try { if (dboa.isIsNew()) { if (!authUser.isAdmin()) { - UserDatabase user = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase user = configuration.getUserManagement().getUserWithID(authUser.getUserID()); - List useroas = user.getOnlineApplication(); - if (useroas == null) useroas = new ArrayList(); + List useroas = user.getOnlineApplication(); + if (useroas == null) useroas = new ArrayList(); - useroas.add(dboa); - ConfigurationDBUtils.saveOrUpdate(user); + useroas.add(String.valueOf(dboa.getHjid())); + configuration.getUserManagement().saveOrUpdate(user); } else { if (persistOA) - ConfigurationDBUtils.save(dboa); + save(dboa); } } else if (persistOA) - ConfigurationDBUtils.saveOrUpdate(dboa); + save(dboa); } catch (MOADatabaseException e) { log.warn("Online-Application can not be stored.", e); @@ -452,6 +457,89 @@ public class BasicOAAction extends BasicAction { return null; } + protected void save(OnlineApplication oa) throws MOADatabaseException { + try { + STORK storkConfig = null; + try { + MOAIDConfiguration moaidConfig = + ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); + + storkConfig = moaidConfig.getAuthComponentGeneral().getForeignIdentities().getSTORK(); + + } catch (Exception e) { + + } + + log.debug("JaxB to Key/Value configuration transformation started ..."); + Map keyValueConfig = + ConfigurationMigrationUtils.convertHyberJaxBOnlineApplicationToKeyValue(oa, storkConfig); + + log.debug("JaxB to Key/Value configuration transformation finished. Start Key/Value storage process ..."); + + String serviceIdentifier = keyValueConfig.get(MOAIDConfigurationConstants.PREFIX_SERVICES); + if (MiscUtil.isEmpty(serviceIdentifier)) { + log.info("Use default ServiceIdentifier."); + serviceIdentifier = MOAIDConfigurationConstants.PREFIX_OA; + } + + if (oa.getHjid() == null) { + log.debug("No hjID -> find new Service ID ..."); + String hjID = configuration.getConfigModule().buildArrayIdentifier( + MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES + "." + serviceIdentifier, 0, keyValueConfig); + log.debug("Find new hjID: " + hjID + " for service: " + oa.getPublicURLPrefix()); + oa.setHjid(Long.valueOf(hjID)); + + } + + Map absolutKeyValue = KeyValueUtils.makeKeysAbsolut( + keyValueConfig, + MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES + "." + serviceIdentifier + "." + String.valueOf(oa.getHjid()), + MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES); + + configuration.getConfigModule().storeChanges(absolutKeyValue, null, null); + + log.info("MOA-ID Service Key/Value configuration successfull stored."); + + + } catch (ConfigurationStorageException | at.gv.egiz.components.configuration.api.ConfigurationException e) { + log.warn("MOAID Configuration can not be stored in Database", e); + throw new MOADatabaseException(e); + + } + + } + + protected boolean delete(OnlineApplication onlineapplication) { + try { + log.debug("JaxB to Key/Value configuration transformation started ..."); + Map keyValueConfig = + ConfigurationMigrationUtils.convertHyberJaxBOnlineApplicationToKeyValue(onlineapplication, null); + + log.debug("JaxB to Key/Value configuration transformation finished. Start Key/Value storage process ..."); + + String serviceIdentifier = keyValueConfig.get(MOAIDConfigurationConstants.PREFIX_SERVICES); + if (MiscUtil.isEmpty(serviceIdentifier)) { + log.info("Use default ServiceIdentifier."); + serviceIdentifier = MOAIDConfigurationConstants.PREFIX_OA; + } + + String deleteServiceKey = + MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES + "." + serviceIdentifier + "." + String.valueOf(onlineapplication.getHjid()) + ".*"; + + configuration.getConfigModule().storeChanges(null, null, Arrays.asList(new String[]{deleteServiceKey})); + + log.info("MOA-ID Service Key/Value configuration successfull stored."); + return true; + + } catch (ConfigurationStorageException e) { + log.warn("MOAID Configuration can not be stored in Database", e); + + } + + return false; + + } + public String bkuFramePreview() { String preview = null; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java index 4236c0d13..13256a6a0 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java @@ -25,49 +25,41 @@ package at.gv.egovernment.moa.id.configuration.struts.action; import java.math.BigInteger; import java.util.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; -import org.apache.struts2.interceptor.ServletRequestAware; -import org.apache.struts2.interceptor.ServletResponseAware; - -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.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; -import at.gv.egovernment.moa.id.commons.db.dao.config.ConnectionParameterClientAuthType; -import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; -import at.gv.egovernment.moa.id.commons.db.dao.config.GeneralConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentityLinkSigners; -import at.gv.egovernment.moa.id.commons.db.dao.config.LegacyAllowed; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOASP; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAuth; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineMandates; -import at.gv.egovernment.moa.id.commons.db.dao.config.Organization; -import at.gv.egovernment.moa.id.commons.db.dao.config.PVP2; -import at.gv.egovernment.moa.id.commons.db.dao.config.Protocols; -import at.gv.egovernment.moa.id.commons.db.dao.config.SAML1; -import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; -import at.gv.egovernment.moa.id.commons.db.dao.config.SSO; -import at.gv.egovernment.moa.id.commons.db.dao.config.STORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.SecurityLayer; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; -import at.gv.egovernment.moa.id.commons.db.dao.config.TimeOuts; -import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TrustAnchor; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyAuthBlock; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyIdentityLink; -import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; + +import at.gv.egiz.components.configuration.meta.api.ConfigurationStorageException; +import at.gv.egovernment.moa.id.commons.config.ConfigurationMigrationUtils; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModeType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModes; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ConnectionParameterClientAuthType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Contact; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.DefaultBKUs; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.GeneralConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentityLinkSigners; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.LegacyAllowed; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOASP; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAuth; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineMandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Organization; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.PVP2; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Protocols; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SAML1; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SLRequestTemplates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SSO; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SecurityLayer; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TimeOuts; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyAuthBlock; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyIdentityLink; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.Constants; -import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.data.GeneralMOAIDConfig; import at.gv.egovernment.moa.id.configuration.data.GeneralStorkConfig; import at.gv.egovernment.moa.id.configuration.exception.BasicActionException; @@ -78,7 +70,6 @@ import at.gv.egovernment.moa.id.configuration.validation.moaconfig.StorkConfigVa import at.gv.egovernment.moa.id.util.Random; import at.gv.egovernment.moa.util.MiscUtil; -import com.opensymphony.xwork2.ActionSupport; public class EditGeneralConfigAction extends BasicAction { @@ -92,7 +83,8 @@ public class EditGeneralConfigAction extends BasicAction { public String loadConfig() { try { - populateBasicInformations(); + populateBasicInformations(); + } catch (BasicActionException e) { return Constants.STRUTS_ERROR; @@ -101,7 +93,8 @@ public class EditGeneralConfigAction extends BasicAction { if (authUser.isAdmin()) { - MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); + + MOAIDConfiguration dbconfig = configuration.getDbRead().getMOAIDConfiguration(); moaconfig = new GeneralMOAIDConfig(); moaconfig.parse(dbconfig); @@ -115,8 +108,6 @@ public class EditGeneralConfigAction extends BasicAction { if (storkconfig == null) { log.error("Stork configuration is null"); } - - ConfigurationDBUtils.closeSession(); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); @@ -210,7 +201,6 @@ public class EditGeneralConfigAction extends BasicAction { public String back() { try { populateBasicInformations(); - ConfigurationDBUtils.closeSession(); } catch (BasicActionException e) { @@ -240,7 +230,7 @@ public class EditGeneralConfigAction extends BasicAction { ex.printStackTrace(); } - MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); + MOAIDConfiguration dbconfig = configuration.getDbRead().getMOAIDConfiguration(); if (dbconfig == null) dbconfig = new MOAIDConfiguration(); @@ -502,7 +492,7 @@ public class EditGeneralConfigAction extends BasicAction { } dbchainingmodes.setSystemDefaultMode( - ChainingModeType.fromValue(moaconfig.getDefaultchainigmode())); + ChainingModeType.fromValue("pkix")); IdentityLinkSigners idlsigners = dbauth.getIdentityLinkSigners(); if (idlsigners == null) { @@ -652,16 +642,23 @@ public class EditGeneralConfigAction extends BasicAction { //save config try { - dbconfig.setTimestampItem(new Date()); + log.debug("JaxB to Key/Value configuration transformation started ..."); + Map keyValueConfig = + ConfigurationMigrationUtils.convertHyberJaxBMOAIDConfigToKeyValue(dbconfig); - ConfigurationDBUtils.save(dbconfig); + log.debug("JaxB to Key/Value configuration transformation finished. Start Key/Value storage process ..."); - } catch (MOADatabaseException e) { + configuration.getConfigModule().storeChanges(keyValueConfig, null, null); + + log.info("General MOA-ID Key/Value configuration successfull stored."); + + + } catch (ConfigurationStorageException e) { log.warn("MOAID Configuration can not be stored in Database", e); return LanguageHelper.getErrorString("error.db.oa.store", request); } finally { - ConfigurationDBUtils.closeSession(); + } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java index 575d93589..1079932b9 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java @@ -22,9 +22,9 @@ *******************************************************************************/ package at.gv.egovernment.moa.id.configuration.struts.action; -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.*; +import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.Constants; @@ -79,6 +79,9 @@ public class EditOAAction extends BasicOAAction { map.putAll(FormBuildUtils.getDefaultMap()); FormularCustomization formOA = new FormularCustomization(map); formList.put(formOA.getName(), formOA); + + OARevisionsLogData revisOA = new OARevisionsLogData(); + formList.put(revisOA.getName(), revisOA); } @@ -123,7 +126,6 @@ public class EditOAAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } } @@ -140,7 +142,7 @@ public class EditOAAction extends BasicOAAction { ArrayList attributes = new ArrayList(); try { - for (StorkAttribute current : ConfigurationDBRead + for (StorkAttribute current : configuration.getDbRead() .getMOAIDConfiguration().getAuthComponentGeneral() .getForeignIdentities().getSTORK().getAttributes()) attributes.add(new AttributeHelper(current)); @@ -152,7 +154,7 @@ public class EditOAAction extends BasicOAAction { getStorkOA().setHelperAttributes(attributes); - UserDatabase userdb = ConfigurationDBRead.getUserWithID(authUser + UserDatabase userdb = configuration.getUserManagement().getUserWithID(authUser .getUserID()); if (!authUser.isAdmin() && userdb.isIsMailAddressVerified() != null @@ -176,7 +178,6 @@ public class EditOAAction extends BasicOAAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } } @@ -240,12 +241,12 @@ public class EditOAAction extends BasicOAAction { int numoas = 0; int numusers = 0; - List openOAs = ConfigurationDBRead + List openOAs = configuration.getDbRead() .getAllNewOnlineApplications(); if (openOAs != null) numoas = openOAs.size(); - List openUsers = ConfigurationDBRead.getAllNewUsers(); + List openUsers = configuration.getUserManagement().getAllNewUsers(); if (openUsers != null) numusers = openUsers.size(); try { @@ -281,7 +282,6 @@ public class EditOAAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } } @@ -312,7 +312,6 @@ public class EditOAAction extends BasicOAAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } } @@ -332,42 +331,43 @@ public class EditOAAction extends BasicOAAction { } oaidentifier = preProcessDeleteOnlineApplication(); - OnlineApplication onlineapplication = ConfigurationDBRead + OnlineApplication onlineapplication = configuration.getDbRead() .getOnlineApplication(oaidentifier); + request.getSession().setAttribute(Constants.SESSION_OAID, null); - try { - if (MiscUtil.isNotEmpty(onlineapplication.getAuthComponentOA() - .getOAPVP2().getMetadataURL())) { - - MOAIDConfiguration moaconfig = ConfigurationDBRead - .getMOAIDConfiguration(); - moaconfig.setPvp2RefreshItem(new Date()); - ConfigurationDBUtils.saveOrUpdate(moaconfig); - - } - } catch (NullPointerException e) { - log.debug("Found no MetadataURL in OA-Databaseconfig"); - - } catch (Throwable e) { - log.info("Set metadata refresh flag FAILED.", e); - } - - if (ConfigurationDBUtils.delete(onlineapplication)) { +// try { +// if (MiscUtil.isNotEmpty(onlineapplication.getAuthComponentOA() +// .getOAPVP2().getMetadataURL())) { +// +// MOAIDConfiguration moaconfig = configuration.getDbRead() +// .getMOAIDConfiguration(); +// moaconfig.setPvp2RefreshItem(new Date()); +// ConfigurationDBUtils.saveOrUpdate(moaconfig); +// +// } +// } catch (NullPointerException e) { +// log.debug("Found no MetadataURL in OA-Databaseconfig"); +// +// } catch (Throwable e) { +// log.info("Set metadata refresh flag FAILED.", e); +// } + + if (onlineapplication != null && delete(onlineapplication)) { if (!authUser.isAdmin()) { - UserDatabase user = ConfigurationDBRead.getUserWithID(authUser + UserDatabase user = configuration.getUserManagement().getUserWithID(authUser .getUserID()); - List useroas = user.getOnlineApplication(); + List useroas = user.getOnlineApplication(); - for (OnlineApplicationType oa : useroas) { - if (oa.getHjid().equals(onlineapplication.getHjid())) { + for (String oa : useroas) { + if (oa.equals(onlineapplication.getHjid())) { useroas.remove(oa); } } try { - ConfigurationDBUtils.saveOrUpdate(user); + configuration.getUserManagement().saveOrUpdate(user); } catch (MOADatabaseException e) { log.warn("User information can not be updated in database", @@ -378,15 +378,12 @@ public class EditOAAction extends BasicOAAction { } } - ConfigurationDBUtils.closeSession(); - addActionMessage(LanguageHelper.getGUIString( "webpages.oaconfig.delete.message", oaidentifier, request)); return Constants.STRUTS_SUCCESS; } else { - ConfigurationDBUtils.closeSession(); addActionError(LanguageHelper.getGUIString( "webpages.oaconfig.delete.error", oaidentifier, request)); return Constants.STRUTS_SUCCESS; @@ -400,7 +397,6 @@ public class EditOAAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } @@ -439,6 +435,16 @@ public class EditOAAction extends BasicOAAction { formList.put(storkOA.getName(), storkOA); } + + public OARevisionsLogData getRevisionsLogOA() { + return (OARevisionsLogData) formList.get(new OARevisionsLogData().getName()); + } + + public void setRevisionsLogOA(OARevisionsLogData storkOA) { + formList.put(storkOA.getName(), storkOA); + } + + /** * @return the nextPage */ diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ImportExportAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ImportExportAction.java index 256f101fe..a2c5da247 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ImportExportAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/ImportExportAction.java @@ -22,40 +22,38 @@ *******************************************************************************/ package at.gv.egovernment.moa.id.configuration.struts.action; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.StringWriter; +import java.util.Arrays; +import java.util.Enumeration; import java.util.List; +import java.util.Properties; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; -import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; -import org.apache.struts2.interceptor.ServletRequestAware; -import org.apache.struts2.interceptor.ServletResponseAware; +import org.springframework.beans.BeansException; -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.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egiz.components.configuration.api.Configuration; +import at.gv.egovernment.moa.id.commons.config.ConfigurationUtil; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; -import at.gv.egovernment.moa.id.config.ConfigurationException; -import at.gv.egovernment.moa.id.config.legacy.BuildFromLegacyConfig; +import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; 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.BasicActionException; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.util.Random; +import at.gv.egovernment.moa.util.MiscUtil; -import com.opensymphony.xwork2.ActionSupport; +import com.fasterxml.jackson.core.JsonProcessingException; public class ImportExportAction extends BasicAction { @@ -92,7 +90,7 @@ public class ImportExportAction extends BasicAction { } } - public String importLegacyConfig() { + public String importLegacyConfig() throws ConfigurationException { try { populateBasicInformations(); @@ -128,67 +126,94 @@ public class ImportExportAction extends BasicAction { return Constants.STRUTS_ERROR_VALIDATION; } - try { - - MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); - - MOAIDConfiguration moaconfig; + Properties result = null; + try { log.warn("WARNING! The legacy import deletes the hole old config"); - String rootConfigFileDir = ConfigurationProvider.getInstance().getConfigRootDir(); - - moaconfig = BuildFromLegacyConfig.build(fileUpload, rootConfigFileDir, moaidconfig); - - } catch (ConfigurationException e) { + InputStream inStream = new FileInputStream(fileUpload); + // get config from xml file + JAXBContext jc = JAXBContext.newInstance("at.gv.egovernment.moa.id.commons.db.dao.config.deprecated"); + Unmarshaller m = jc.createUnmarshaller(); + MOAIDConfiguration config = (MOAIDConfiguration) m.unmarshal(inStream); + + // serialize config to JSON properties + result = ConfigurationUtil.moaIdConfigToJsonProperties(config); + + if (result == null || result.isEmpty()) { + log.info("Legacy configuration has is empty"); + addActionError(LanguageHelper.getErrorString("errors.importexport.legacyimport", new Object[] {"Empty Configuratiobn"}, request)); + + formID = Random.nextRandom(); + session.setAttribute(Constants.SESSION_FORMID, formID); + return Constants.STRUTS_ERROR_VALIDATION; + + } + + } catch (JsonProcessingException | JAXBException | FileNotFoundException e) { log.info("Legacy configuration has an Import Error", e); addActionError(LanguageHelper.getErrorString("errors.importexport.legacyimport", new Object[] {e.getMessage()}, request)); - ConfigurationDBUtils.closeSession(); - + formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_ERROR_VALIDATION; - } catch (at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException e) { - ConfigurationDBUtils.closeSession(); + } + + try { + //check if XML config should be use + log.warn("WARNING! MOA-ID 2.0 is started with XML configuration. This setup overstrike the actual configuration in the Database!"); + + Configuration dbConfiguration = + (Configuration) ConfigurationProvider.getInstance().getContext().getBean("moaidconfig"); + + if (dbConfiguration == null) { + log.warn("Open Database connection FAILED."); + addActionError("Open Database connection FAILED."); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_ERROR_VALIDATION; + } - //check if XML config should be use - log.warn("WARNING! MOA-ID 2.0 is started with XML configuration. This setup overstrike the actual configuration in the Database!"); - - - if (moaidconfig != null) - ConfigurationDBUtils.delete(moaidconfig); + boolean isOverwriteData = true; - List oas = ConfigurationDBRead.getAllOnlineApplications(); - if (oas != null && oas.size() > 0) { - for (OnlineApplication oa : oas) - ConfigurationDBUtils.delete(oa); + List keys = Arrays.asList(dbConfiguration.getConfigurationIds()); + + if (keys == null) { + log.info("Configuration is not readable."); + throw new MOADatabaseException("Configuration is not readable."); } - - - oas = moaconfig.getOnlineApplication(); - for (OnlineApplication oa : oas) - ConfigurationDBUtils.save(oa); - moaconfig.setOnlineApplication(null); - ConfigurationDBUtils.save(moaconfig); - - } catch (MOADatabaseException e) { - log.warn("General MOA-ID config can not be stored in Database"); - addActionError(e.getMessage()); + if (isOverwriteData) { + // remove existing entries + for (String key : keys) { + dbConfiguration.deleteIds(key); + } + } + + Enumeration propertyNames = result.propertyNames(); + + while (propertyNames.hasMoreElements()) { + String key = (String) propertyNames.nextElement(); + String json = result.getProperty(key); + + dbConfiguration.setStringValue(key, json); + } + + } catch (ConfigurationException | MOADatabaseException | at.gv.egiz.components.configuration.api.ConfigurationException e1) { + log.warn("General MOA-ID config can not be stored in Database", e1); + addActionError(e1.getMessage()); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); - return Constants.STRUTS_ERROR_VALIDATION; + return Constants.STRUTS_ERROR_VALIDATION; + } finally { - ConfigurationDBUtils.closeSession(); + } //set new formID @@ -232,45 +257,61 @@ public class ImportExportAction extends BasicAction { if (authUser.isAdmin()) { - log.info("Write MOA-ID 2.x xml config"); - JAXBContext jc; + log.info("Write MOA-ID 3.x config"); try { - jc = JAXBContext.newInstance("at.gv.egovernment.moa.id.commons.db.dao.config"); - - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); -// File test = new File(xmlconfigout); -// m.marshal(moaidconfig, test); - MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); - if (moaidconfig == null) { - log.info("No MOA-ID 2.x configruation available"); - addActionError(LanguageHelper.getErrorString("errors.importexport.export.noconfig", request)); + Configuration dbConfiguration = + (Configuration) ConfigurationProvider.getInstance().getContext().getBean("moaidconfig"); + + if (dbConfiguration == null) { + log.warn("Open Database connection FAILED."); + addActionError("Open Database connection FAILED."); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_ERROR_VALIDATION; + + } + + Properties result = new Properties(); + String[] allConfigIDs = dbConfiguration.getConfigurationIds(); + for (String key : allConfigIDs) { + String value = dbConfiguration.getStringValue(key); + if (MiscUtil.isNotEmpty(value)) { + result.put(key, value); + log.debug("Put key: " + key + " with value: " + value + " to property file."); + + } else + log.info("Leave key: " + key + " Reason: Value is null or empty"); + } - List oaconfigs = ConfigurationDBRead.getAllOnlineApplications(); - moaidconfig.setOnlineApplication(oaconfigs); - StringWriter writer = new StringWriter(); - m.marshal(moaidconfig, writer); - fileInputStream = IOUtils.toInputStream(writer.toString(), "UTF-8"); + if (result.isEmpty()) { + log.info("No MOA-ID 3.x configruation available"); + addActionError(LanguageHelper.getErrorString("errors.importexport.export.noconfig", request)); + + formID = Random.nextRandom(); + session.setAttribute(Constants.SESSION_FORMID, formID); + return Constants.STRUTS_ERROR_VALIDATION; + } - } catch (JAXBException e) { - log.info("MOA-ID 2.x configruation could not be exported into a XML file.", e); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + result.store(output, null); + fileInputStream = new ByteArrayInputStream(output.toByteArray()); + + } catch (IOException | at.gv.egiz.components.configuration.api.ConfigurationException e) { + log.info("MOA-ID 3.x configruation could not be exported into file.", e); addActionError(LanguageHelper.getErrorString("errors.importexport.export", new Object[]{e.getMessage()}, request)); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_ERROR_VALIDATION; - } catch (IOException e) { - log.info("MOA-ID 2.x configruation could not be exported into a XML file.", e); - addActionError(LanguageHelper.getErrorString("errors.importexport.export", - new Object[]{e.getMessage()}, request)); + + } catch (ConfigurationException | BeansException e) { + log.warn("Open Database connection FAILED."); + addActionError("Open Database connection FAILED."); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); @@ -278,7 +319,7 @@ public class ImportExportAction extends BasicAction { } finally { - ConfigurationDBUtils.closeSession(); + } @@ -331,32 +372,54 @@ public class ImportExportAction extends BasicAction { return Constants.STRUTS_ERROR_VALIDATION; } - log.info("Load configuration from MOA-ID 2.x XML configuration"); + log.info("Load configuration from MOA-ID 3.x XML configuration"); try { - JAXBContext jc = JAXBContext.newInstance("at.gv.egovernment.moa.id.commons.db.dao.config"); - Unmarshaller m = jc.createUnmarshaller(); - MOAIDConfiguration moaconfig = (MOAIDConfiguration) m.unmarshal(fileUpload); - - log.warn("WARNING! The XML import deletes the hole old config"); - List oas = ConfigurationDBRead.getAllOnlineApplications(); - if (oas != null && oas.size() > 0) { - for (OnlineApplication oa : oas) - ConfigurationDBUtils.delete(oa); - } - MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); - if (moaidconfig != null) - ConfigurationDBUtils.delete(moaidconfig); + Properties inProperties = new Properties(); + inProperties.load(new FileInputStream(fileUpload)); + + //check if XML config should be use + log.warn("WARNING! MOA-ID 2.0 is started with XML configuration. This setup overstrike the actual configuration in the Database!"); - List importoas = moaconfig.getOnlineApplication(); - for (OnlineApplication importoa : importoas) { - ConfigurationDBUtils.saveOrUpdate(importoa); + Configuration dbConfiguration = + (Configuration) ConfigurationProvider.getInstance().getContext().getBean("moaidconfig"); + + if (dbConfiguration == null) { + log.warn("Open Database connection FAILED."); + addActionError("Open Database connection FAILED."); + + formID = Random.nextRandom(); + session.setAttribute(Constants.SESSION_FORMID, formID); + return Constants.STRUTS_ERROR_VALIDATION; + } - - moaconfig.setOnlineApplication(null); - ConfigurationDBUtils.saveOrUpdate(moaconfig); - + + boolean isOverwriteData = true; + + List keys = Arrays.asList(dbConfiguration.getConfigurationIds()); + + if (keys == null) { + log.info("Configuration is not readable."); + throw new MOADatabaseException("Configuration is not readable."); + } + + if (isOverwriteData) { + // remove existing entries + for (String key : keys) { + dbConfiguration.deleteIds(key); + } + } + + Enumeration propertyNames = inProperties.propertyNames(); + + while (propertyNames.hasMoreElements()) { + String key = (String) propertyNames.nextElement(); + String json = inProperties.getProperty(key); + + dbConfiguration.setStringValue(key, json); + } + } catch (Exception e) { log.warn("MOA-ID XML configuration can not be loaded from File.", e); addActionError(LanguageHelper.getErrorString("errors.importexport.import", @@ -369,7 +432,7 @@ public class ImportExportAction extends BasicAction { } finally { - ConfigurationDBUtils.closeSession(); + } //set new formID 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 index 1ec0f4668..040931b42 100644 --- 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 @@ -77,9 +77,7 @@ import org.opensaml.xml.security.x509.X509Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.impl.ExplicitKeySignatureTrustEngine; -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.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; @@ -187,7 +185,7 @@ public class IndexAction extends BasicAction { } - UserDatabase dbuser = ConfigurationDBRead.getUserWithUserName(username); + UserDatabase dbuser = configuration.getUserManagement().getUserWithUserName(username); if (dbuser == null) { log.warn("Unknown Username"); addActionError(LanguageHelper.getErrorString("webpages.index.login.notallowed", request)); @@ -238,7 +236,7 @@ public class IndexAction extends BasicAction { dbuser.setLastLogin(DateTimeHelper.getDateTime(new Date())); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); } catch (MOADatabaseException e) { log.warn("UserDatabase communicaton error", e); @@ -246,7 +244,6 @@ public class IndexAction extends BasicAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } HttpSession session = generateNewJSession(request); @@ -400,7 +397,7 @@ public class IndexAction extends BasicAction { (sessionTimeOut * Constants.ONE_MINUTE_IN_MILLIS)); //search user - UserDatabase dbuser = ConfigurationDBRead.getUserWithUserBPKWBPK(bpkwbpk); + UserDatabase dbuser = configuration.getUserManagement().getUserWithUserBPKWBPK(bpkwbpk); if (dbuser == null) { log.info("No user found with bpk/wbpk " + bpkwbpk); @@ -456,7 +453,6 @@ public class IndexAction extends BasicAction { session.setAttribute(Constants.SESSION_FORM, user); session.setAttribute(Constants.SESSION_AUTH, authUser); - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_NEWUSER; @@ -516,7 +512,7 @@ public class IndexAction extends BasicAction { dbuser.setLastLogin(DateTimeHelper.getDateTime(new Date())); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); } catch (MOADatabaseException e) { log.warn("UserDatabase communicaton error", e); @@ -524,7 +520,6 @@ public class IndexAction extends BasicAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } HttpSession newsession = generateNewJSession(request); @@ -693,7 +688,7 @@ public class IndexAction extends BasicAction { dbuser.setIsUsernamePasswordAllowed(false); } else - dbuser = ConfigurationDBRead.getUserWithID(userID); + dbuser = configuration.getUserManagement().getUserWithID(userID); dbuser.setMail(user.getMail()); dbuser.setPhone(user.getPhone()); @@ -702,7 +697,7 @@ public class IndexAction extends BasicAction { dbuser.setUserRequestTokken(Random.nextRandom()); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); MailHelper.sendUserMailAddressVerification(dbuser); @@ -719,7 +714,6 @@ public class IndexAction extends BasicAction { finally { session.setAttribute(Constants.SESSION_FORM, null); session.setAttribute(Constants.SESSION_AUTH, null); - ConfigurationDBUtils.closeSession(); } addActionMessage(LanguageHelper.getGUIString("webpages.edituser.changemailaddress.verify", request)); @@ -758,7 +752,7 @@ public class IndexAction extends BasicAction { return Constants.STRUTS_ERROR; } - UserDatabase dbuser = ConfigurationDBRead.getNewUserWithTokken(userrequesttokken); + UserDatabase dbuser = configuration.getUserManagement().getNewUserWithTokken(userrequesttokken); if (dbuser != null) { dbuser.setUserRequestTokken(null); dbuser.setIsMailAddressVerified(true); @@ -767,16 +761,16 @@ public class IndexAction extends BasicAction { dbuser.setIsAdminRequest(false); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); int numoas = 0; int numusers = 0; - List openOAs = ConfigurationDBRead.getAllNewOnlineApplications(); + List openOAs = configuration.getDbRead().getAllNewOnlineApplications(); if (openOAs != null) numoas = openOAs.size(); - List openUsers = ConfigurationDBRead.getAllNewUsers(); + List openUsers = configuration.getUserManagement().getAllNewUsers(); if (openUsers != null) numusers = openUsers.size(); @@ -792,7 +786,6 @@ public class IndexAction extends BasicAction { } finally { - ConfigurationDBUtils.closeSession(); } addActionMessage(LanguageHelper.getGUIString("validation.newuser.mailaddress", request)); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/InterfederationIDPAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/InterfederationIDPAction.java index eead280be..8be24edb4 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/InterfederationIDPAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/InterfederationIDPAction.java @@ -28,12 +28,10 @@ import java.util.List; import org.apache.log4j.Logger; -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.AttributeProviderPlugin; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AttributeProviderPlugin; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentificationNumber; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; @@ -80,7 +78,7 @@ public class InterfederationIDPAction extends BasicOAAction { populateBasicInformations(); if (authUser.isAdmin()) { - List dbOAs = ConfigurationDBRead.getAllOnlineApplications(); + List dbOAs = configuration.getDbRead().getAllOnlineApplications(); if (dbOAs == null || dbOAs.size() == 0) { addActionError(LanguageHelper.getErrorString("errors.listOAs.noOA", request)); @@ -104,7 +102,6 @@ public class InterfederationIDPAction extends BasicOAAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } } @@ -147,7 +144,6 @@ public class InterfederationIDPAction extends BasicOAAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } @@ -204,7 +200,6 @@ public class InterfederationIDPAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } } @@ -281,7 +276,7 @@ public class InterfederationIDPAction extends BasicOAAction { onlineapplication.setTarget("MOA-IDP"); try { - ConfigurationDBUtils.saveOrUpdate(onlineapplication); + save(onlineapplication); } catch (MOADatabaseException e) { log.warn("Online-Application can not be stored.", e); @@ -292,7 +287,6 @@ public class InterfederationIDPAction extends BasicOAAction { //remove session attributes session.setAttribute(Constants.SESSION_OAID, null); - ConfigurationDBUtils.closeSession(); addActionMessage(LanguageHelper.getGUIString("webpages.idp.success", getGeneralOA().getIdentifier(), request)); return Constants.STRUTS_SUCCESS; @@ -306,7 +300,6 @@ public class InterfederationIDPAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } } @@ -323,7 +316,6 @@ public class InterfederationIDPAction extends BasicOAAction { session.setAttribute(Constants.SESSION_OAID, null); addActionMessage(LanguageHelper.getGUIString("webpages.idp.cancle", getGeneralOA().getIdentifier(), request)); - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; @@ -331,7 +323,6 @@ public class InterfederationIDPAction extends BasicOAAction { return Constants.STRUTS_ERROR; } finally { - ConfigurationDBUtils.closeSession(); } } @@ -350,21 +341,21 @@ public class InterfederationIDPAction extends BasicOAAction { oaidentifier = preProcessDeleteOnlineApplication(); session.setAttribute(Constants.SESSION_OAID, null); - OnlineApplication onlineapplication = ConfigurationDBRead.getOnlineApplication(oaidentifier); + OnlineApplication onlineapplication = configuration.getDbRead().getOnlineApplication(oaidentifier); - try { - if (onlineapplication.getAuthComponentOA().getOAPVP2() != null && - MiscUtil.isNotEmpty(onlineapplication.getAuthComponentOA().getOAPVP2().getMetadataURL())) { - MOAIDConfiguration moaconfig = ConfigurationDBRead.getMOAIDConfiguration(); - moaconfig.setPvp2RefreshItem(new Date()); - ConfigurationDBUtils.saveOrUpdate(moaconfig); +// try { +// if (onlineapplication.getAuthComponentOA().getOAPVP2() != null && +// MiscUtil.isNotEmpty(onlineapplication.getAuthComponentOA().getOAPVP2().getMetadataURL())) { +// MOAIDConfiguration moaconfig = configuration.getDbRead().getMOAIDConfiguration(); +// moaconfig.setPvp2RefreshItem(new Date()); +// ConfigurationDBUtils.saveOrUpdate(moaconfig); +// +// } +// } catch (Throwable e) { +// log.info("Found no MetadataURL in OA-Databaseconfig!", e); +// } - } - } catch (Throwable e) { - log.info("Found no MetadataURL in OA-Databaseconfig!", e); - } - - if (ConfigurationDBUtils.delete(onlineapplication)) { + if (delete(onlineapplication)) { addActionMessage(LanguageHelper.getGUIString("webpages.oaconfig.delete.message", oaidentifier, request)); return Constants.STRUTS_SUCCESS; @@ -381,7 +372,6 @@ public class InterfederationIDPAction extends BasicOAAction { return e.getStrutsReturnValue(); } finally { - ConfigurationDBUtils.closeSession(); } @@ -404,7 +394,6 @@ public class InterfederationIDPAction extends BasicOAAction { setNewOA(false); - ConfigurationDBUtils.closeSession(); formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); 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 index 37727c0f0..c6b0965fe 100644 --- 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 @@ -35,9 +35,7 @@ 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.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; @@ -75,13 +73,17 @@ public class ListOAsAction extends BasicAction { List dbOAs = null; if (authUser.isAdmin()) { - dbOAs = ConfigurationDBRead.getAllOnlineApplications(); + dbOAs = configuration.getDbRead().getAllOnlineApplications(); } else { - UserDatabase authUserDB = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase authUserDB = configuration.getUserManagement().getUserWithID(authUser.getUserID()); - if (authUserDB != null) - dbOAs = authUserDB.getOnlineApplication(); + if (authUserDB != null) { + for (String el : authUserDB.getOnlineApplication()) { + dbOAs.add(configuration.getDbRead().getOnlineApplication(Long.valueOf(el))); + + } + } } if (dbOAs == null || dbOAs.size() == 0) { @@ -94,7 +96,6 @@ public class ListOAsAction extends BasicAction { session.setAttribute(Constants.SESSION_RETURNAREA, Constants.STRUTS_RETURNAREA_VALUES.main.name()); - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; } @@ -142,19 +143,21 @@ public class ListOAsAction extends BasicAction { List dbOAs = null; if (authUser.isAdmin()) { - dbOAs = ConfigurationDBRead.searchOnlineApplications(friendlyname); + dbOAs = configuration.getDbRead().searchOnlineApplications(friendlyname); } else { - UserDatabase authUserDB = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase authUserDB = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (authUserDB != null) { - List alldbOAs = authUserDB.getOnlineApplication(); + List alldbOAs = authUserDB.getOnlineApplication(); dbOAs = new ArrayList(); - for (OnlineApplication el : alldbOAs) { - if (el.getPublicURLPrefix() + for (String el : alldbOAs) { + OnlineApplication oa = configuration.getDbRead().getOnlineApplication(Long.valueOf(el)); + + if (oa.getPublicURLPrefix() .toLowerCase().indexOf(friendlyname.toLowerCase()) > -1) - dbOAs.add(el); + dbOAs.add(oa); } } } @@ -168,7 +171,6 @@ public class ListOAsAction extends BasicAction { } - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/OpenAdminRequestsAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/OpenAdminRequestsAction.java index 283b3604a..26d4e13ab 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/OpenAdminRequestsAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/OpenAdminRequestsAction.java @@ -32,8 +32,7 @@ import org.apache.log4j.Logger; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; -import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.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; @@ -65,12 +64,12 @@ public class OpenAdminRequestsAction extends BasicAction { if (authUser.isAdmin()) { - List dbOAs = ConfigurationDBRead.getAllNewOnlineApplications(); + List dbOAs = configuration.getDbRead().getAllNewOnlineApplications(); if (dbOAs != null) { formOAs = FormDataHelper.populateFormWithOAs(dbOAs); } - List dbUsers = ConfigurationDBRead.getAllNewUsers(); + List dbUsers = configuration.getUserManagement().getAllNewUsers(); if (dbUsers != null){ userlist = FormDataHelper.addFormUsers(dbUsers); } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/UserManagementAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/UserManagementAction.java index 3cc3b9969..8be134442 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/UserManagementAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/UserManagementAction.java @@ -34,8 +34,6 @@ import org.apache.log4j.Logger; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; -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.UserDatabase; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; @@ -89,7 +87,7 @@ public class UserManagementAction extends BasicAction { log.info("Show UserList"); - List dbuserlist = ConfigurationDBRead.getAllUsers(); + List dbuserlist = configuration.getUserManagement().getAllUsers(); if (dbuserlist != null) { userlist = FormDataHelper.addFormUsers(dbuserlist); @@ -98,17 +96,15 @@ public class UserManagementAction extends BasicAction { session.setAttribute(Constants.SESSION_RETURNAREA, Constants.STRUTS_RETURNAREA_VALUES.usermanagementInit.name()); - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; } else { log.info("User with ID " + authUser.getUserID() + " is not admin. Show only EditUser Frame"); - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (dbuser == null) { return Constants.STRUTS_REAUTHENTICATE; } user = new UserDatabaseFrom(dbuser); - ConfigurationDBUtils.closeSession(); session.setAttribute(Constants.SESSION_RETURNAREA, Constants.STRUTS_RETURNAREA_VALUES.main.name()); @@ -176,7 +172,7 @@ public class UserManagementAction extends BasicAction { } userid = Long.valueOf(useridobj); - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(userid); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(userid); if (dbuser == null) { log.info("No User with ID " + userid + " in Database");; addActionError(LanguageHelper.getErrorString("errors.edit.user.userid", request)); @@ -185,14 +181,12 @@ public class UserManagementAction extends BasicAction { user = new UserDatabaseFrom(dbuser); newUser = false; - - ConfigurationDBUtils.closeSession(); - + return Constants.STRUTS_SUCCESS; } else { log.info("User with ID " + authUser.getUserID() + " is not admin. Show his own EditUser Frame"); - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(authUser.getUserID()); user = new UserDatabaseFrom(dbuser); return Constants.STRUTS_SUCCESS; } @@ -237,7 +231,7 @@ public class UserManagementAction extends BasicAction { userID = Long.valueOf(useridobj); } - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(userID); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(userID); if( dbuser == null) { dbuser = new UserDatabase(); @@ -340,7 +334,6 @@ public class UserManagementAction extends BasicAction { return Constants.STRUTS_SUCCESS; } - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; } @@ -402,20 +395,19 @@ public class UserManagementAction extends BasicAction { nextPage = Constants.STRUTS_RETURNAREA_VALUES.usermanagementInit.name(); } - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(userID); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(userID); if (dbuser != null) { - dbuser.setOnlineApplication(null); + dbuser.setOaIDs(null); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); - ConfigurationDBUtils.delete(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); + configuration.getUserManagement().delete(dbuser); if (authUser.isAdmin()) { MailHelper.sendUserAccountRevocationMail(dbuser); } - if (dbuser.getHjid() == authUser.getUserID()) { - ConfigurationDBUtils.closeSession(); + if (dbuser.getHjid().equals(String.valueOf(authUser.getUserID()))) { return Constants.STRUTS_REAUTHENTICATE; } @@ -431,11 +423,9 @@ public class UserManagementAction extends BasicAction { } finally { - ConfigurationDBUtils.closeSession(); } } - ConfigurationDBUtils.closeSession(); return Constants.STRUTS_SUCCESS; } @@ -452,14 +442,14 @@ public class UserManagementAction extends BasicAction { String message = LanguageHelper.getErrorString("error.mail.send", request); if (authUser != null) { - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(authUser.getUserID()); + UserDatabase dbuser = configuration.getUserManagement().getUserWithID(authUser.getUserID()); if (dbuser != null) { dbuser.setIsMailAddressVerified(false); dbuser.setUserRequestTokken(Random.nextRandom()); try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); MailHelper.sendUserMailAddressVerification(dbuser); @@ -532,7 +522,7 @@ public class UserManagementAction extends BasicAction { } try { - ConfigurationDBUtils.saveOrUpdate(dbuser); + configuration.getUserManagement().saveOrUpdate(dbuser); } catch (MOADatabaseException e) { log.warn("User information can not be stored in Database.", e); return LanguageHelper.getErrorString("errors.edit.user.save", request); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/interceptor/HibernateSessionInterceptor.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/interceptor/HibernateSessionInterceptor.java index 084d054f7..27f7a4ad0 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/interceptor/HibernateSessionInterceptor.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/interceptor/HibernateSessionInterceptor.java @@ -1,59 +1,57 @@ -/* - * Copyright 2014 Federal Chancellery Austria - * MOA-ID has been developed in a cooperation between BRZ, the Federal - * Chancellery Austria - ICT staff unit, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egovernment.moa.id.configuration.struts.interceptor; - -import org.apache.log4j.Logger; - -import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; - -/** - * @author tlenz - * - */ -public class HibernateSessionInterceptor extends AbstractInterceptor { - - private static final long serialVersionUID = 2457987431702749278L; - private static Logger log = Logger.getLogger(HibernateSessionInterceptor.class); - - /* (non-Javadoc) - * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation) - */ - @Override - public String intercept(ActionInvocation arg0) throws Exception { - log.trace("Hibernate session interceptor starts .... "); - - try { - return arg0.invoke(); - - } finally { - log.debug("Hibernate-Session interceptor close active sessions."); - ConfigurationDBUtils.closeSession(); - - } - - } - -} +///* +// * Copyright 2014 Federal Chancellery Austria +// * MOA-ID has been developed in a cooperation between BRZ, the Federal +// * Chancellery Austria - ICT staff unit, and Graz University of Technology. +// * +// * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by +// * the European Commission - subsequent versions of the EUPL (the "Licence"); +// * You may not use this work except in compliance with the Licence. +// * You may obtain a copy of the Licence at: +// * http://www.osor.eu/eupl/ +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the Licence is distributed on an "AS IS" basis, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the Licence for the specific language governing permissions and +// * limitations under the Licence. +// * +// * This product combines work with different licenses. See the "NOTICE" text +// * file for details on the various modules and licenses. +// * The "NOTICE" text file is part of the distribution. Any derivative works +// * that you distribute must include a readable copy of the "NOTICE" text file. +// */ +//package at.gv.egovernment.moa.id.configuration.struts.interceptor; +// +//import org.apache.log4j.Logger; +// +//import com.opensymphony.xwork2.ActionInvocation; +//import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +// +///** +// * @author tlenz +// * +// */ +//public class HibernateSessionInterceptor extends AbstractInterceptor { +// +// private static final long serialVersionUID = 2457987431702749278L; +// private static Logger log = Logger.getLogger(HibernateSessionInterceptor.class); +// +// /* (non-Javadoc) +// * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation) +// */ +// @Override +// public String intercept(ActionInvocation arg0) throws Exception { +// log.trace("Hibernate session interceptor starts .... "); +// +// try { +// return arg0.invoke(); +// +// } finally { +// log.debug("Hibernate-Session interceptor close active sessions."); +// ConfigurationDBUtils.closeSession(); +// +// } +// +// } +// +//} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/utils/UserRequestCleaner.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/utils/UserRequestCleaner.java index 62e01720d..5f55a61d5 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/utils/UserRequestCleaner.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/utils/UserRequestCleaner.java @@ -28,8 +28,6 @@ import java.util.List; import org.apache.log4j.Logger; -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.UserDatabase; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.auth.AuthenticationManager; @@ -49,7 +47,7 @@ public class UserRequestCleaner implements Runnable { ConfigurationProvider config = ConfigurationProvider.getInstance(); //clean up user request storage - List userrequests = ConfigurationDBRead.getAllOpenUsersRequests(); + List userrequests = config.getUserManagement().getAllOpenUsersRequests(); if (userrequests != null) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR, config.getUserRequestCleanUpDelay()*-1); @@ -60,7 +58,7 @@ public class UserRequestCleaner implements Runnable { if (requestdate != null && requestdate.after(cleanupdate)) { log.info("Remove UserRequest from Database"); - ConfigurationDBUtils.delete(dbuser); + config.getUserManagement().delete(dbuser); } } @@ -68,7 +66,6 @@ public class UserRequestCleaner implements Runnable { //clean up active user storage AuthenticationManager.getInstance().removeAllUsersAfterTimeOut(); - ConfigurationDBUtils.closeSession(); Thread.sleep(SESSION_CLEANUP_INTERVAL * 1000); @@ -77,10 +74,7 @@ public class UserRequestCleaner implements Runnable { } catch (InterruptedException e) { - } finally { - ConfigurationDBUtils.closeSession(); - - } + } } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/UserDatabaseFormValidator.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/UserDatabaseFormValidator.java index 662694ce7..7b49275b3 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/UserDatabaseFormValidator.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/UserDatabaseFormValidator.java @@ -29,9 +29,12 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead; +import at.gv.egovernment.moa.id.commons.db.NewConfigurationDBRead; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; +import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.config.usermanagement.FileBasedUserConfiguration; import at.gv.egovernment.moa.id.configuration.data.UserDatabaseFrom; import at.gv.egovernment.moa.id.configuration.helper.AuthenticationHelper; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; @@ -46,6 +49,16 @@ public class UserDatabaseFormValidator { List errors = new ArrayList(); String check = null; + FileBasedUserConfiguration newConfigRead = null; + try { + newConfigRead = ConfigurationProvider.getInstance().getUserManagement(); + + } catch (ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + errors.add("Internal Server Error"); + return errors; + + } if (!isPVP2Generated) { check = form.getGivenName(); @@ -121,8 +134,8 @@ public class UserDatabaseFormValidator { new Object[] {ValidationHelper.getPotentialCSSCharacter(false)}, request )); } else { - UserDatabase dbuser = ConfigurationDBRead.getUserWithUserName(check); - if (dbuser != null && userID != dbuser.getHjid()) { + UserDatabase dbuser = newConfigRead.getUserWithUserName(check); + if (dbuser != null && !dbuser.getHjid().equals(String.valueOf(userID ))) { log.warn("Username " + check + " exists in UserDatabase"); errors.add(LanguageHelper.getErrorString("validation.edituser.username.duplicate", request)); form.setUsername(""); @@ -133,7 +146,7 @@ public class UserDatabaseFormValidator { log.warn("Username is empty"); errors.add(LanguageHelper.getErrorString("validation.edituser.username.empty", request)); } else { - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(userID); + UserDatabase dbuser = newConfigRead.getUserWithID(userID); if (dbuser == null) { log.warn("Username is empty"); errors.add(LanguageHelper.getErrorString("validation.edituser.username.empty", request)); @@ -150,7 +163,7 @@ public class UserDatabaseFormValidator { log.warn("Password is empty"); errors.add(LanguageHelper.getErrorString("validation.edituser.password.empty", request)); } else { - UserDatabase dbuser = ConfigurationDBRead.getUserWithID(userID); + UserDatabase dbuser = newConfigRead.getUserWithID(userID); if (dbuser == null || MiscUtil.isEmpty(dbuser.getPassword())) { log.warn("Password is empty"); errors.add(LanguageHelper.getErrorString("validation.edituser.password.empty", request)); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/MOAConfigValidator.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/MOAConfigValidator.java index c64ae35d3..73f5e098f 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/MOAConfigValidator.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/MOAConfigValidator.java @@ -136,17 +136,17 @@ public class MOAConfigValidator { } } - check = form.getDefaultchainigmode(); - if (MiscUtil.isEmpty(check)) { - log.info("Empty Defaultchainigmode"); - errors.add(LanguageHelper.getErrorString("validation.general.Defaultchainigmode.empty", request)); - } else { - Map list = form.getChainigmodelist(); - if (!list.containsKey(check)) { - log.info("Not valid Defaultchainigmode " + check); - errors.add(LanguageHelper.getErrorString("validation.general.Defaultchainigmode.valid", request)); - } - } +// check = form.getDefaultchainigmode(); +// if (MiscUtil.isEmpty(check)) { +// log.info("Empty Defaultchainigmode"); +// errors.add(LanguageHelper.getErrorString("validation.general.Defaultchainigmode.empty", request)); +// } else { +// Map list = form.getChainigmodelist(); +// if (!list.containsKey(check)) { +// log.info("Not valid Defaultchainigmode " + check); +// errors.add(LanguageHelper.getErrorString("validation.general.Defaultchainigmode.valid", request)); +// } +// } check = form.getMandateURL(); if (MiscUtil.isNotEmpty(check)) { diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java index f7d61653d..a042a7931 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java @@ -7,8 +7,8 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.data.GeneralStorkConfig; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; @@ -26,8 +26,10 @@ public class StorkConfigValidator { // check peps list - if (form.getCpepslist() != null) { - for(CPEPS current : form.getCpepslist()) { +// if (form.getCpepslist() != null) { +// for(CPEPS current : form.getCpepslist()) { + if (form.getRawCPEPSList() != null) { + for(CPEPS current : form.getRawCPEPSList()) { // if an existing record got deleted if(null == current) continue; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAPVP2ConfigValidation.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAPVP2ConfigValidation.java index 70413dad7..d850decb4 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAPVP2ConfigValidation.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAPVP2ConfigValidation.java @@ -44,7 +44,6 @@ import org.opensaml.xml.parse.BasicParserPool; import org.opensaml.xml.security.x509.BasicX509Credential; import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; -import at.gv.egovernment.moa.id.commons.db.NewConfigurationDBRead; import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException; import at.gv.egovernment.moa.id.commons.utils.MOAHttpProtocolSocketFactory; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; @@ -74,12 +73,19 @@ public class OAPVP2ConfigValidation { byte[] certSerialized = null; if (form.getFileUpload() != null) certSerialized = form.getCertificate(); + else { - Map oa = NewConfigurationDBRead.getOnlineApplicationKeyValueWithId(oaID); - if (oa != null && - MiscUtil.isNotEmpty(oa.get(MOAIDConfigurationConstants.SERVICE_PROTOCOLS_PVP2X_CERTIFICATE))) { - certSerialized = Base64Utils.decode(oa.get(MOAIDConfigurationConstants.SERVICE_PROTOCOLS_PVP2X_CERTIFICATE), false); - } + try { + Map oa = ConfigurationProvider.getInstance().getDbRead().getOnlineApplicationKeyValueWithId(oaID); + if (oa != null && + MiscUtil.isNotEmpty(oa.get(MOAIDConfigurationConstants.SERVICE_PROTOCOLS_PVP2X_CERTIFICATE))) { + certSerialized = Base64Utils.decode(oa.get(MOAIDConfigurationConstants.SERVICE_PROTOCOLS_PVP2X_CERTIFICATE), false); + } + + } catch (ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + + } } String check = form.getMetaDataURL(); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java index 60209542b..5c451c06a 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OASTORKConfigValidation.java @@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AttributeProviderPlugin; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.data.oa.OASTORKConfig; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; -- cgit v1.2.3