首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ESAPI getValidInput方法的使用

ESAPI getValidInput方法的使用
EN

Stack Overflow用户
提问于 2014-03-26 22:26:10
回答 2查看 28.5K关注 0票数 1

我无法使用ESAPI类下存在的of方法

代码语言:javascript
复制
    java.lang.String getValidInput(java.lang.String context,
                                  java.lang.String input,
                                  java.lang.String type,
                                  int maxLength,
                                  boolean allowNull)
                                      throws ValidationException,
                                       IntrusionException

      Parameters:
         type - The regular expression name that maps to the actual regular expression from "ESAPI.properties". 

如何从ESAPI.properties文件中传递参数类型?有没有我可以参考的使用属性文件值的例子?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-27 02:06:32

下面是一个示例调用,我在其中验证"to“地址字段:

代码语言:javascript
复制
validator.getValidInput("toAddress", it.next(), "Email", Email.MAX_ADDRESS_SIZE, true)

ESAPI假设您正在使用IDE或有权访问直接源代码。如果您使用的是Eclipse,只需将鼠标悬停在方法名称上,参数类型就会显示出来。

===UPDATED===

这是直接来自javadoc的rip:

代码语言:javascript
复制
/**
     * Returns canonicalized and validated input as a String. Invalid input will generate a descriptive ValidationException,
     * and input that is clearly an attack will generate a descriptive IntrusionException.
     *
     * @param context
     *      A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.
     * @param input
     *      The actual user input data to validate.
     * @param type
     *      The regular expression name that maps to the actual regular expression from "ESAPI.properties".
     * @param maxLength
     *      The maximum post-canonicalized String length allowed.
     * @param allowNull
     *      If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.
     *
     * @return The canonicalized user input.
     *
     * @throws ValidationException
     * @throws IntrusionException
     */
票数 6
EN

Stack Overflow用户

发布于 2017-02-01 18:02:39

代码语言:javascript
复制
ESAPI.validator().getValidInput("Validationofinput", StringInput, "Onlycharacters",200, true);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22664006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档