• 大小: 11MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-07-28
  • 语言: 其他
  • 标签: esapi  

资源简介

ESAPI是一个免费、开源的Web应用程序安全控制组件,可以帮助编程人员开发低风险应用程序。

资源截图

代码片段和文件信息

import java.io.*;
import java.util.*;
import org.owasp.esapi.EncryptedProperties;
import org.owasp.esapi.errors.EncryptionException;
import org.owasp.esapi.reference.crypto.DefaultEncryptedProperties;

// Purpose: Short code snippet to show how to display encrypted property files
//          that were encrypted using ESAPI‘s EncryptedProperties class.
//
// Usage: java -classpath  DisplayEncryptedProperties encryptedPropFileName
//        where  is proper classpath which minimally include esapi.jar & log4j.jar
public class DisplayEncryptedProperties {

    public DisplayEncryptedProperties() {
    }

    public void loadProperties(String encryptedPropertiesFilename
                                  Properties props )
        throws IOException
    {
         EncryptedProperties loader = new DefaultEncryptedProperties();
         loader.load( new FileInputStream(
                                    new File( encryptedPropertiesFilename) ) );

         System.out.println(“\n\nLoaded encrypted properties file...“);

         try {
             props.setProperty( “database.driver“
                                loader.getProperty( “database.driver“ ) );
             props.setProperty( “jdbc.url“
                                loader.getProperty( “jdbc.url“ ) );
             props.setProperty( “jdbc.username“
                                loader.getProperty( “jdbc.username“ ) );
             props.setProperty( “jdbc.password“
                                loader.getProperty( “jdbc.password“ ) );
         } catch( EncryptionException ee ) {
             ee.printStackTrace();
         }
    }

    public void showProperties(Properties props) throws Exception
    {
        System.out.println(““);
        String value = null;
        value = props.getProperty( “database.driver“);
        System.out.println(“database.driver=“ + value);
        value = props.getProperty( “jdbc.url“);
        System.out.println(“jdbc.url=“ + value);
        value = props.getProperty( “jdbc.username“);
        System.out.println(“jdbc.username=“ + value);
        value = props.getProperty( “jdbc.password“);
        System.out.println(“jdbc.password=“ + value);
    }


    public static void main(String[] args) {

        try {
            DisplayEncryptedProperties dep = new DisplayEncryptedProperties();
            Properties props = new Properties();

            String encryptedPropFname = “encrypted.properties“;
            if ( args.length == 1 ) {
                encryptedPropFname = args[0];
            } else {
                System.err.println(“Usage: java -classpath  DisplayEncryptedProperties encryptedPropFileName“);
                System.exit(2);
            }

            dep.loadProperties(encryptedPropFname props);
            dep.showProperties(props);

        } catch(Throwable t) {
            System.err.println(“Caught: “ + t.getClass().getName() +
                               “; exception msg: “ + t);
            t.printStackTr

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-09-07 13:19  esapi-2.1.0-dist\
     目录           0  2015-09-07 13:19  esapi-2.1.0-dist\configuration\
     文件        6718  2013-09-02 13:39  esapi-2.1.0-dist\configuration\log4j.dtd
     文件        1323  2013-09-02 13:39  esapi-2.1.0-dist\configuration\log4j.xml
     目录           0  2015-09-07 13:19  esapi-2.1.0-dist\configuration\properties\
     文件         174  2013-09-02 13:39  esapi-2.1.0-dist\configuration\properties\ESAPI_en_US.properties
     文件         192  2013-09-02 13:39  esapi-2.1.0-dist\configuration\properties\ESAPI_fr_FR.properties
     文件          40  2013-09-02 13:39  esapi-2.1.0-dist\configuration\properties\ESAPI_zhs_CN.properties
     目录           0  2015-09-07 13:19  esapi-2.1.0-dist\documentation\
     文件       22536  2013-09-02 13:39  esapi-2.1.0-dist\documentation\Analysis-of-ESAPI-2.0-KDF.odt
     文件      313772  2013-09-02 13:39  esapi-2.1.0-dist\documentation\Analysis-of-ESAPI-2.0-KDF.pdf
     文件        4578  2013-09-02 13:39  esapi-2.1.0-dist\documentation\cc.JPG
     文件      130846  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-2.0-javadoc-pictures.pptx
     文件        3744  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-2.0-readme.txt
     文件        3372  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-2.0rc6-override-log4jloggingfactory.txt
     文件        8350  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-big-duke.JPG
     文件      136825  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-ciphertext-serialization.pdf
     文件       16384  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-ciphertext-serialization.xls
     文件      119808  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-crypto-design-goals.doc
     文件      278016  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-install-guide.doc
     文件      582255  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-install-guide.pdf
     文件       22120  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-readme-crypto-changes.html
     文件      283648  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-release-notes.doc
     文件      531816  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-release-notes.pdf
     文件       38170  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.0-symmetric-crypto-user-guide.html
     文件        3912  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-core-2.1-release-notes.txt
     文件       47448  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-disa.JPG
     文件      141824  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-google-code.doc
     文件        2004  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-google-code.JPG
     文件      216462  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-waf-2.0-policy-file-spec.docx
     文件      758388  2013-09-02 13:39  esapi-2.1.0-dist\documentation\esapi4java-waf-2.0-policy-file-spec.pdf
............此处省略432个文件信息

评论

共有 条评论

相关资源