org.hyphenType.optionprocessors.lib
Class BooleanValidatorEngine

java.lang.Object
  extended by org.hyphenType.optionprocessors.lib.BooleanValidatorEngine
All Implemented Interfaces:
ArgumentsProcessorEngine<BooleanValidatorEngine.BooleanValidator>

public class BooleanValidatorEngine
extends Object
implements ArgumentsProcessorEngine<BooleanValidatorEngine.BooleanValidator>

Rules must be written in JavaScript and should refer to the names of the option methods. Return types of methods apply. I.e., if the return type is int, variables referring to this method will be considered int, similarly for boolean. One can turn all variables into booleans (converting non zero values to false) by choosing BooleanValidatorEngine.BooleanValidator.allBooleans() to be true.

WARNING! SECURITY RISK. There is a risk of script injection if you allow the annotations to be loaded from properties files. The attacker needs to add a properties file with the same name as the options interface to the classpath. This malicious properties file may override the rules of a BooleanValidatorEngine.BooleanValidator annotation. This trick will cause this engine to execute the malicious scripts. Although this risk may look scary at first, the sort of access the attacker would need to add a file to the classpath is equivalent to the sort of access the attacker would need to have to replace files in another user's space. In other words, the security risk described here is a minor risk compared to the breach one needs in order to exploit the risk itself.

Author:
Aurelio Akira M. Matsui

Nested Class Summary
static interface BooleanValidatorEngine.BooleanValidator
           
static interface BooleanValidatorEngine.Rule
           
 
Constructor Summary
BooleanValidatorEngine()
           
 
Method Summary
<T extends Options<?>>
void
process(Class<T> interfaceClass, T options, BooleanValidatorEngine.BooleanValidator config)
          Must call Options#exit(Enum) or Options#exit(int) if, and only if, the options violate the contract represented by this argument validator engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BooleanValidatorEngine

public BooleanValidatorEngine()
Method Detail

process

public <T extends Options<?>> void process(Class<T> interfaceClass,
                                           T options,
                                           BooleanValidatorEngine.BooleanValidator config)
Description copied from interface: ArgumentsProcessorEngine
Must call Options#exit(Enum) or Options#exit(int) if, and only if, the options violate the contract represented by this argument validator engine.

Specified by:
process in interface ArgumentsProcessorEngine<BooleanValidatorEngine.BooleanValidator>
Parameters:
interfaceClass - The options interface class
options - The options object
config - The configuration annotation


Copyright © 2013. All Rights Reserved.