All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.validator.messageinterpolation.ExpressionLanguageFeatureLevel Maven / Gradle / Ivy

Go to download

JPMS Module-Info's for a few of the Jakarta Libraries. These will be removed as time goes by

There is a newer version: 62
Show newest version
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */
package org.hibernate.validator.messageinterpolation;

import org.hibernate.validator.Incubating;
import org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorContext;

/**
 * Indicates the level of features enabled for the Expression Language engine.
 *
 * @since 6.2
 */
@Incubating
public enum ExpressionLanguageFeatureLevel {

	/**
	 * The default Expression Language feature level.
	 * 

* Depends on the context. *

* For standard constraint messages, it is {@link ExpressionLanguageFeatureLevel#BEAN_PROPERTIES}. *

* For custom violations, the default is {@link ExpressionLanguageFeatureLevel#NONE} and, if Expression Language is * enabled for a given custom violation via the API, the default becomes * {@link ExpressionLanguageFeatureLevel#VARIABLES} in the context of this given custom violation. */ DEFAULT("default"), /** * Expression Language expressions are not interpolated. */ NONE("none"), /** * Only allows access to the variables injected via * {@link HibernateConstraintValidatorContext#addExpressionVariable(String, Object)}, the Jakarta Bean * Validation-defined {@code formatter} and the {@code ResourceBundle}s. */ VARIABLES("variables"), /** * Only allows to what is allowed with the {@code variables} level plus access to bean properties. *

* This is the minimal level to have a specification-compliant implementation. */ BEAN_PROPERTIES("bean-properties"), /** * This level allows what is allowed with the {@code bean-properties} level plus bean methods execution and can lead * to serious security issues, including arbitrary code execution, if not very carefully handled. *

* If using this level, you need to be sure you are not injecting user input in an expression without properly * escaping it using {@link HibernateConstraintValidatorContext#addExpressionVariable(String, Object)}. */ BEAN_METHODS("bean-methods"); private final String externalRepresentation; ExpressionLanguageFeatureLevel(String externalRepresentation) { this.externalRepresentation = externalRepresentation; } public static ExpressionLanguageFeatureLevel of(String value) { for ( ExpressionLanguageFeatureLevel level : values() ) { if ( level.externalRepresentation.equals( value ) ) { return level; } } return ExpressionLanguageFeatureLevel.valueOf( value ); } public static ExpressionLanguageFeatureLevel interpretDefaultForConstraints(ExpressionLanguageFeatureLevel value) { if ( value == DEFAULT ) { return BEAN_PROPERTIES; } return value; } public static ExpressionLanguageFeatureLevel interpretDefaultForCustomViolations(ExpressionLanguageFeatureLevel value) { if ( value == DEFAULT ) { return VARIABLES; } return value; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy