亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

簡單的 ESAPI 目錄路徑驗證示例不起作用

簡單的 ESAPI 目錄路徑驗證示例不起作用

慕絲7291255 2023-04-13 15:20:01
我已經構建了一個 ESAPITestValidator 類,如下所示:public class ESAPITestValidator {Validator instance = ESAPI.validator();ValidationErrorList errors = new ValidationErrorList();File parent = null;String path = new String("");boolean status = false;public boolean testGetValidDirectoryPath(String inputPath,String context)   {     try     {        parent = new File(inputPath).getParentFile().getCanonicalFile();        //String parent = ESAPI.securityConfiguration().getResourceFile("ESAPI.properties").getParentFile().getCanonicalPath();        path = instance.getValidDirectoryPath(context, inputPath, parent, true, errors);        status = true;        return status;     }catch(Exception exception)     {         exception.printStackTrace();         status= false;       }     return status; }}現在我正嘗試從主類調用 testGetValidDirectoryPath() ,如下所示:public class HelloWorld {public static void main(String[] args) {    ESAPITestValidator obj =  new ESAPITestValidator();    if ( obj.testGetValidDirectoryPath("C:\\Users\\1730176\\Downloads","C:\\Users") )      System.out.println("Success");    else      System.out.println("Failure");         }}
查看完整描述

1 回答

?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

JVM 正在尋找javax/servlet/http/HttpServletRequest類,而您還沒有將它加載到類路徑中。請記住,ESAPI 是一個基于 Web 的庫,如果您克隆實際的 esapi-java-legacy 項目并在那里進行單元測試,您可能會更輕松地進行測試。



查看完整回答
反對 回復 2023-04-13
  • 1 回答
  • 0 關注
  • 984 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號