From 81cb2aa8ae947e854dc03c8d7034fccc3a56eea1 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Fri, 11 Nov 2011 10:56:56 +0100 Subject: [PATCH] [Interface] added a property map to the Certificate which is a copy of the users properties on login. This map can be used to configure the user's session --- .../handler/DefaultPrivilegeHandler.java | 4 +++- .../eitchnet/privilege/model/Certificate.java | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ch/eitchnet/privilege/handler/DefaultPrivilegeHandler.java b/src/ch/eitchnet/privilege/handler/DefaultPrivilegeHandler.java index 55471cb63..28442e470 100644 --- a/src/ch/eitchnet/privilege/handler/DefaultPrivilegeHandler.java +++ b/src/ch/eitchnet/privilege/handler/DefaultPrivilegeHandler.java @@ -564,7 +564,9 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler { // get next session id String sessionId = nextSessionId(); - certificate = new Certificate(sessionId, username, authToken, authPassword, user.getLocale()); + // create a new certificate, with details of the user + certificate = new Certificate(sessionId, username, authToken, authPassword, user.getLocale(), + new HashMap(user.getProperties())); // create and save a new session Session session = new Session(sessionId, username, authToken, authPassword, System.currentTimeMillis()); diff --git a/src/ch/eitchnet/privilege/model/Certificate.java b/src/ch/eitchnet/privilege/model/Certificate.java index 7ae4f5f56..762ff0606 100644 --- a/src/ch/eitchnet/privilege/model/Certificate.java +++ b/src/ch/eitchnet/privilege/model/Certificate.java @@ -27,6 +27,7 @@ package ch.eitchnet.privilege.model; import java.io.Serializable; import java.util.Locale; +import java.util.Map; import ch.eitchnet.privilege.handler.PrivilegeHandler; import ch.eitchnet.privilege.i18n.PrivilegeException; @@ -50,6 +51,8 @@ public final class Certificate implements Serializable { private Locale locale; + private Map propertyMap; + /** * Default constructor initializing with all information needed for this certificate * @@ -71,8 +74,12 @@ public final class Certificate implements Serializable { * {@link Session} * @param locale * the users {@link Locale} + * @param propertyMap + * a {@link Map} containing string value pairs of properties for the logged in user. These properties can + * be edited and can be used for the user to change settings of this session */ - public Certificate(String sessionId, String username, String authToken, String authPassword, Locale locale) { + public Certificate(String sessionId, String username, String authToken, String authPassword, Locale locale, + Map propertyMap) { // validate arguments are not null if (sessionId == null || username == null || authToken == null || authPassword == null) { @@ -89,6 +96,15 @@ public final class Certificate implements Serializable { this.locale = Locale.getDefault(); else this.locale = locale; + + this.propertyMap = propertyMap; + } + + /** + * @return the propertyMap + */ + public Map getPropertyMap() { + return this.propertyMap; } /**