diff --git a/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java b/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java
index d308272d3..3c7099f45 100644
--- a/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java
+++ b/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java
@@ -43,14 +43,13 @@ public class TimeRestrictionParser {
*
* - 1:0700-1700 - Monday from 07:00 to 17:00
*
- 7:0000-2359 - Sunday, all day (00:00 to 23:59)
- *
- wd:0900-1700 - Monday through Friday, 09:00 to 17:00
- *
- we:0900-1700 - Saturday and Sunday, 09:00 to 17:00
+ *
- *:0900-1700 - Every day, 09:00 to 17:00
*
- 6:0900-1600;7:1200-1300 - Saturday, 09:00 to 16:00, and Sunday,
* 12:00 - 13:00
*
*/
private static final Pattern RESTRICTION_REGEX =
- Pattern.compile("(?:^|;)+([1-7*]|(?:[w][ed]))(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\\-((?:[01][0-9]|2[0-3])[0-5][0-9]))+");
+ Pattern.compile("(?:^|;)+([1-7*])(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\\-((?:[01][0-9]|2[0-3])[0-5][0-9]))+");
/**
* The RegEx group that contains the start day-of-week of the restriction.
@@ -67,25 +66,6 @@ public class TimeRestrictionParser {
*/
private static final int RESTRICTION_TIME_END_GROUP = 3;
- /**
- * A list of DayOfWeek items that make up weekdays.
- */
- private static final List RESTRICTION_WEEKDAYS = Arrays.asList(
- DayOfWeek.MONDAY,
- DayOfWeek.TUESDAY,
- DayOfWeek.WEDNESDAY,
- DayOfWeek.THURSDAY,
- DayOfWeek.FRIDAY
- );
-
- /**
- * A list of DayOfWeek items that make up weekends.
- */
- private static final List RESTRICTION_WEEKEND = Arrays.asList(
- DayOfWeek.SATURDAY,
- DayOfWeek.SUNDAY
- );
-
/**
* A list of DayOfWeek items that make up all days of the week.
*/
@@ -154,16 +134,6 @@ public class TimeRestrictionParser {
restrictions.add(new DailyRestriction(RESTRICTION_ALL_DAYS, startTime, endTime));
break;
- // Weekdays only.
- case "wd":
- restrictions.add(new DailyRestriction(RESTRICTION_WEEKDAYS, startTime, endTime));
- break;
-
- // Weekend days only.
- case "we":
- restrictions.add(new DailyRestriction(RESTRICTION_WEEKEND, startTime, endTime));
- break;
-
// A specific day of the week.
default:
restrictions.add(new DailyRestriction(DayOfWeek.of(Integer.parseInt(dayString)), startTime, endTime));
diff --git a/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js b/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js
index a238e61e9..d65ed8df2 100644
--- a/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js
+++ b/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js
@@ -28,6 +28,9 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s
// Required types
const TimeRestrictionEntry = $injector.get('TimeRestrictionEntry');
+ // Required services
+ const $log = $injector.get('$log');
+
/**
* Options which dictate the behavior of the input field model, as defined
* by https://docs.angularjs.org/api/ng/directive/ngModelOptions
@@ -64,9 +67,7 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s
{ id : '5', day : 'Friday' },
{ id : '6', day : 'Saturday' },
{ id : '7', day : 'Sunday' },
- { id : '*', day : 'All days' },
- { id : 'wd', day: 'Week days' },
- { id : 'we', day: 'Week end' }
+ { id : '*', day : 'All days' }
];
/**
@@ -111,14 +112,18 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s
*/
const parseRestrictions = function parseRestrictions(restrString) {
+ // Array to store the restrictions
var restrictions = [];
+ // Grab the current date so that we can accurately parse DST later
+ var templateDate = new Date();
+
// If the string is null or empty, just return an empty array
if (restrString === null || restrString === "")
return restrictions;
// Set up the RegEx and split the string using the separator.
- const restrictionRegex = new RegExp('^([1-7*]|(?:[w][ed]))(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\-((?:[01][0-9]|2[0-3])[0-5][0-9]))$');
+ const restrictionRegex = new RegExp('^([1-7*])(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\-((?:[01][0-9]|2[0-3])[0-5][0-9]))$');
var restrArray = restrString.split(";");
// Loop through split string and process each item
@@ -129,8 +134,8 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s
var currArray = restrArray[i].match(restrictionRegex);
var entry = new TimeRestrictionEntry();
entry.weekDay = '' + currArray[1];
- entry.startTime = new Date(Date.UTC(1970, 1, 1, parseInt(currArray[2].slice(0,2)), parseInt(currArray[2].slice(2)), 0, 0));
- entry.endTime = new Date(Date.UTC(1970, 1, 1, parseInt(currArray[3].slice(0,2)), parseInt(currArray[3].slice(2)), 0, 0));
+ entry.startTime = new Date(Date.UTC(templateDate.getFullYear(), templateDate.getMonth(), templateDate.getDate(), parseInt(currArray[2].slice(0,2)), parseInt(currArray[2].slice(2))));
+ entry.endTime = new Date(Date.UTC(templateDate.getFullYear(), templateDate.getMonth(), templateDate.getDate(), parseInt(currArray[3].slice(0,2)), parseInt(currArray[3].slice(2))))
restrictions.push(entry);
}
}