- switch (ruleProvider){
- case GUARD_BL_YAML:
- templateFile = new File(classLoader.getResource(XACML_BLGUARD_TEMPLATE).getFile());
- xacmlTemplatePath = templateFile.toPath();
- cons.setActive_time_range(activeTimeRange);
- if(blackList==null || blackList.isEmpty()){
- throw new BuilderException("blackList is required");
- }
- cons.setBlacklist(blackList);
- break;
- default:
- templateFile = new File(classLoader.getResource(XACML_GUARD_TEMPLATE).getFile());
- xacmlTemplatePath = templateFile.toPath();
- Map<String,String> timeWindow = new HashMap<>();
- if(!PolicyUtils.isInteger(yamlParams.get("timeWindow"))){
- throw new BuilderException("time window is not in Integer format.");
- }
- String timeUnits = yamlParams.get("timeUnits");
- if(timeUnits==null || !(timeUnits.equalsIgnoreCase("minute") || timeUnits.equalsIgnoreCase("hour") || timeUnits.equalsIgnoreCase("day")
- || timeUnits.equalsIgnoreCase("week") || timeUnits.equalsIgnoreCase("month")||timeUnits.equalsIgnoreCase("year"))){
- throw new BuilderException("time Units is not in proper format.");
- }
- timeWindow.put("value", yamlParams.get("timeWindow"));
- timeWindow.put("units", yamlParams.get("timeUnits"));
- cons = new Constraint(Integer.parseInt(yamlParams.get("limit")),timeWindow,activeTimeRange);
- break;
+ switch (ruleProvider) {
+ case GUARD_BL_YAML:
+ templateFile = new File(classLoader.getResource(XACML_BLGUARD_TEMPLATE).getFile());
+ xacmlTemplatePath = templateFile.toPath();
+ cons.setActive_time_range(activeTimeRange);
+ if (blackList == null || blackList.isEmpty()) {
+ throw new BuilderException("blackList is required");
+ }
+ cons.setBlacklist(blackList);
+ break;
+ case GUARD_MIN_MAX:
+ templateFile = new File(classLoader.getResource(XACML_GUARD_MIN_MAX_TEMPLATE).getFile());
+ xacmlTemplatePath = templateFile.toPath();
+ cons = new Constraint(Integer.parseInt(yamlParams.get("min")),
+ Integer.parseInt(yamlParams.get("max")), activeTimeRange);
+ break;
+ default:
+ templateFile = new File(classLoader.getResource(XACML_GUARD_TEMPLATE).getFile());
+ xacmlTemplatePath = templateFile.toPath();
+ Map<String, String> timeWindow = new HashMap<>();
+ if (!PolicyUtils.isInteger(yamlParams.get("timeWindow"))) {
+ throw new BuilderException("time window is not in Integer format.");
+ }
+ String timeUnits = yamlParams.get("timeUnits");
+ if (timeUnits == null
+ || !("minute".equalsIgnoreCase(timeUnits) || "hour".equalsIgnoreCase(timeUnits)
+ || "day".equalsIgnoreCase(timeUnits) || "week".equalsIgnoreCase(timeUnits)
+ || "month".equalsIgnoreCase(timeUnits) || "year".equalsIgnoreCase(timeUnits))) {
+ throw new BuilderException("time Units is not in proper format.");
+ }
+ timeWindow.put("value", yamlParams.get("timeWindow"));
+ timeWindow.put("units", yamlParams.get("timeUnits"));
+ cons = new Constraint(Integer.parseInt(yamlParams.get("limit")), timeWindow, activeTimeRange);
+ break;