From 80ea041e0240eb3d9291eb0d699bb09c90aaa2a9 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 23 Feb 2018 13:35:12 +0100 Subject: first untested unfactoring for Postgresql suppport The scheme of configuration DB changed, therefore this version is incompatible to 3.3.2 configuration --- .../egovernment/moa/id/config/ConfigurationProviderImpl.java | 5 +++++ .../moa/id/storage/DBAuthenticationSessionStoreage.java | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java index 2b5459208..151eda89f 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java @@ -269,11 +269,16 @@ public abstract class ConfigurationProviderImpl implements ConfigurationProvider }else{ activeProfiles.add("advancedLogOff"); } + if (Boolean.valueOf(props.getProperty("redis.active", "false"))) { activeProfiles.add(SpringProfileConstants.REDIS_BACKEND); }else{ activeProfiles.add(SpringProfileConstants.DB_BACKEND); } + + if (Boolean.valueOf(props.getProperty("configuration.database.byteBasedValues", "false"))) + activeProfiles.add(SpringProfileConstants.BYTEBASEDCONFIG); + } public String[] getActiveProfiles(){ diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBAuthenticationSessionStoreage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBAuthenticationSessionStoreage.java index ad200e400..0df6379b0 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBAuthenticationSessionStoreage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBAuthenticationSessionStoreage.java @@ -22,6 +22,7 @@ *******************************************************************************/ package at.gv.egovernment.moa.id.storage; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -105,7 +106,7 @@ public class DBAuthenticationSessionStoreage implements IAuthenticationSessionSt //set additional session informations AuthenticationSessionExtensions sessionExt = new AuthenticationSessionExtensions(); sessionExt.setUniqueSessionId(target.getUniqueSessionIdentifier()); - dbsession.setAdditionalInformation(mapper.serialize(sessionExt)); + dbsession.setAdditionalInformation(mapper.serialize(sessionExt).getBytes("UTF-8")); AuthenticationSession session = new AuthenticationSession(id, now, target.getMOASession()); encryptSession(session, dbsession); @@ -120,7 +121,7 @@ public class DBAuthenticationSessionStoreage implements IAuthenticationSessionSt // Logger.warn("MOASession could not be created."); // throw new MOADatabaseException(e); - } catch (JsonProcessingException e) { + } catch (JsonProcessingException | UnsupportedEncodingException e) { Logger.warn("Extended session information can not be stored.", e); throw new MOADatabaseException(e); @@ -154,7 +155,7 @@ public class DBAuthenticationSessionStoreage implements IAuthenticationSessionSt if (MiscUtil.isNotEmpty(dbsession.getAdditionalInformation())) { try { - return (AuthenticationSessionExtensions)mapper.deserialize(dbsession.getAdditionalInformation(), + return (AuthenticationSessionExtensions)mapper.deserialize(new String(dbsession.getAdditionalInformation(), "UTF-8"), AuthenticationSessionExtensions.class); } catch (Exception e) { @@ -171,7 +172,7 @@ public class DBAuthenticationSessionStoreage implements IAuthenticationSessionSt AuthenticatedSessionStore dbsession = searchInDatabase(sessionID); dbsession.setAdditionalInformation( - mapper.serialize(sessionExtensions)); + mapper.serialize(sessionExtensions).getBytes("UTF-8")); entityManager.merge(dbsession); Logger.debug("MOASession with sessionID=" + sessionID + " is stored in Database"); @@ -181,7 +182,7 @@ public class DBAuthenticationSessionStoreage implements IAuthenticationSessionSt Logger.warn("MOASession could not be stored."); throw new MOADatabaseException(e); - } catch (JsonProcessingException e) { + } catch (JsonProcessingException | UnsupportedEncodingException e) { Logger.warn("Extended session information can not be stored.", e); throw new MOADatabaseException("Extended session information can not be stored.", e); -- cgit v1.2.3