1 package org.jahia.security.license; 2 3 import org.jahia.bin.JahiaInterface; 4 import org.jahia.resourcebundle.ResourceMessage; 5 6 14 15 public class BuildNumberValidator extends AbstractValidator { 16 public BuildNumberValidator (String name, String value, License license) { 17 super(name, value, license); 18 } 19 20 public boolean assertEquals (String value) { 21 int licenseBuildNumber = Integer.parseInt(value); 22 if (licenseBuildNumber == JahiaInterface.BUILD_NUMBER) { 23 return true; 24 } else { 25 errorMessage = new ResourceMessage("org.jahia.security.license.BuildNumberValidator.invalidBuildNumber.label", new Integer (JahiaInterface.BUILD_NUMBER), new Integer (licenseBuildNumber)); 26 return false; 27 } 28 } 29 30 public boolean assertInRange (String fromValue, String toValue) { 31 int minBuildNumber = Integer.parseInt(fromValue); 32 int maxBuildNumber = Integer.parseInt(toValue); 33 if ( (JahiaInterface.BUILD_NUMBER >= minBuildNumber) && 34 (JahiaInterface.BUILD_NUMBER < maxBuildNumber) ) { 35 return true; 36 } else { 37 errorMessage = new ResourceMessage("org.jahia.security.license.BuildNumberValidator.buildNumberNotInRange.label", new Integer (JahiaInterface.BUILD_NUMBER), new Integer (minBuildNumber), new Integer (maxBuildNumber)); 38 return false; 39 } 40 } 41 42 } | Popular Tags |