From b60b48e19be2ad306dc9dc6c7b814cf459939393 Mon Sep 17 00:00:00 2001 From: rwm Date: Tue, 3 May 2016 16:57:41 +0200 Subject: [PATCH] Authenticator and timestamps for query request --- README.md | 1 + .../java/org/aktin/dwh/Authenticator.java | 28 ++++++++----------- .../java/org/aktin/exchange/QueryRequest.java | 9 ++++++ src/main/java/org/aktin/prefs/Preference.java | 20 ++++++++++++- src/test/resources/request.xml | 3 +- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 81e2497..e2c5264 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Query exchange + La la la XXXtimestamp diff --git a/src/main/java/org/aktin/dwh/Authenticator.java b/src/main/java/org/aktin/dwh/Authenticator.java index 30f5290..84821a0 100644 --- a/src/main/java/org/aktin/dwh/Authenticator.java +++ b/src/main/java/org/aktin/dwh/Authenticator.java @@ -1,23 +1,19 @@ package org.aktin.dwh; +import java.security.Principal; + public interface Authenticator { - /** - * Determine whether the given user and password combination is granted - * the given role. - * @param user user name - * @param password password - * @param role role - * @return true if all criteria are matched, false otherwise - */ - boolean verifyUserRole(String user, char[] password, String role); - /** - * Determine whether a given user and password combination - * has admin privileges. + Principal authenticate(String user, char[] password); + boolean isUserInRole(Principal user, String role); + /** Determine whether a given user has admin privileges. * - * @param user user name - * @param password password - * @return true if the user is admin and the password is correct + * @param user user + * @return true if the user has administrative rights */ - boolean verifyAdmin(String user, char[] password); + boolean isUserAdmin(Principal user); + + + + } diff --git a/src/main/java/org/aktin/exchange/QueryRequest.java b/src/main/java/org/aktin/exchange/QueryRequest.java index 934b52c..ea446cc 100644 --- a/src/main/java/org/aktin/exchange/QueryRequest.java +++ b/src/main/java/org/aktin/exchange/QueryRequest.java @@ -34,10 +34,19 @@ public class QueryRequest { /** * Time stamp when the request was published at the query broker. */ + @XmlElement(required=true) Instant published; + /** + * Time stamp for the earliest execution / when the request is open. + * If unspecified, the query can be executed at any time (usually + * before the deadline) + */ + @XmlElement(required=false) + Instant scheduled; /** * Due date until which the query results have to be submitted. */ + @XmlElement(required=true) Instant deadline; /** * Date when the request was closed by the query broker. While diff --git a/src/main/java/org/aktin/prefs/Preference.java b/src/main/java/org/aktin/prefs/Preference.java index aa08838..7bd7c23 100644 --- a/src/main/java/org/aktin/prefs/Preference.java +++ b/src/main/java/org/aktin/prefs/Preference.java @@ -35,11 +35,29 @@ public interface Preference { * @param user user name * @param value value */ - public void setValue(String user, T value); + public void setValue(T value, String user); /** * Set the value by the system user * @param value value */ public void setValue(T value); + + /** + * Set the value to the given string representation. The value + * is changed by the system user. + * @param value string representing the value + * @throws IllegalArgumentException if the string conversion fails + */ + public void setValueString(String value) throws IllegalArgumentException; + + /** + * Set the value to the given string representation. The specified + * user name is used to perform the change. + * + * @param value string value + * @param user user name + * @throws IllegalArgumentException if string conversion fails + */ + public void setValueString(String value, String user) throws IllegalArgumentException; } diff --git a/src/test/resources/request.xml b/src/test/resources/request.xml index 90f1334..d459d14 100644 --- a/src/test/resources/request.xml +++ b/src/test/resources/request.xml @@ -3,7 +3,8 @@ xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xml="http://www.w3.org/XML/1998/namespace"> 123 - 2016-04-28T00:00:00Z + 2016-04-28T00:00:00Z + 2016-04-28T00:00:00Z 2016-04-30T00:00:00Z -- GitLab