当前位置: 首页>>代码示例>>Java>>正文


Java Security.setProperty方法代码示例

本文整理汇总了Java中java.security.Security.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Security.setProperty方法的具体用法?Java Security.setProperty怎么用?Java Security.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.Security的用法示例。


在下文中一共展示了Security.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // reset the security property to make sure that the algorithms
    // and keys used in this test are not disabled.
    Security.setProperty("jdk.tls.disabledAlgorithms", "");

    String keyFilename =
        System.getProperty("test.src", ".") + "/" + pathToStores +
            "/" + keyStoreFile;
    String trustFilename =
        System.getProperty("test.src", ".") + "/" + pathToStores +
            "/" + trustStoreFile;

    System.setProperty("javax.net.ssl.keyStore", keyFilename);
    System.setProperty("javax.net.ssl.keyStorePassword", passwd);
    System.setProperty("javax.net.ssl.trustStore", trustFilename);
    System.setProperty("javax.net.ssl.trustStorePassword", passwd);

    if (debug)
        System.setProperty("javax.net.debug", "all");

    /*
     * Start the tests.
     */
    new GenericStreamCipher();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:GenericStreamCipher.java

示例2: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args)
        throws Exception {

    // 5 sec is default timeout for tryLess
    if (BadKdc.getRatio() > 2.5) {
        Security.setProperty("krb5.kdc.bad.policy",
                "tryLess:1," + BadKdc.toReal(2000));
    } else {
        Security.setProperty("krb5.kdc.bad.policy", "tryLess");
    }

    BadKdc.go(
            "121212222222(32){1,2}1222(32){1,2}", // 1 2
            // The above line means try kdc1 for 2 seconds then kdc1
            // for 2 seconds... finally kdc3 for 2 seconds.
            "1222(32){1,2}1222(32){1,2}",    // 1 2
            // refresh
            "121212222222(32){1,2}1222(32){1,2}",  // 1 2
            // k3 off k2 on
            "(122212(22){1,2}|1222323232-)", // 1
            // k1 on
            "(12(12){1,2}|122232-)"  // empty
    );
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:BadKdc1.java

示例3: OneKDC

import java.security.Security; //导入方法依赖的package包/类
/**
 * Creates the KDC and starts it.
 * @param etype Encryption type, null if not specified
 * @throws java.lang.Exception if there's anything wrong
 */
public OneKDC(String etype) throws Exception {
    super(REALM, KDCHOST, 0, true);
    addPrincipal(USER, PASS);
    addPrincipal(USER2, PASS2);
    addPrincipalRandKey("krbtgt/" + REALM);
    addPrincipalRandKey(SERVER);
    addPrincipalRandKey(BACKEND);

    String extraConfig = "";
    if (etype != null) {
        extraConfig += "default_tkt_enctypes=" + etype
                + "\ndefault_tgs_enctypes=" + etype;
        if (etype.startsWith("des")) {
            extraConfig += "\nallow_weak_crypto = true";
        }
    }
    KDC.saveConfig(KRB5_CONF, this,
            "forwardable = true",
            "default_keytab_name = " + KTAB,
            extraConfig);
    System.setProperty("java.security.krb5.conf", KRB5_CONF);
    // Whatever krb5.conf had been loaded before, we reload ours now.
    Config.refresh();

    writeKtab(KTAB);
    Security.setProperty("auth.login.defaultCallbackHandler",
            "OneKDC$CallbackForClient");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:OneKDC.java

示例4: xRealmAuth

import java.security.Security; //导入方法依赖的package包/类
static void xRealmAuth() throws Exception {
    Security.setProperty("auth.login.defaultCallbackHandler", "CrossRealm");
    System.setProperty("java.security.auth.login.config", "jaas-localkdc.conf");
    System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
    FileOutputStream fos = new FileOutputStream("jaas-localkdc.conf");
    fos.write(("com.sun.security.jgss.krb5.initiate {\n" +
            "    com.sun.security.auth.module.Krb5LoginModule\n" +
            "    required\n" +
            "    principal=dummy\n" +
            "    doNotPrompt=false\n" +
            "    useTicketCache=false\n" +
            "    ;\n" +
            "};").getBytes());
    fos.close();

    GSSManager m = GSSManager.getInstance();
    m.createContext(
            m.createName("[email protected]", GSSName.NT_HOSTBASED_SERVICE),
            GSSUtil.GSS_KRB5_MECH_OID,
            null,
            GSSContext.DEFAULT_LIFETIME).initSecContext(new byte[0], 0, 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:CrossRealm.java

示例5: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args)
        throws Exception {

    // 1 sec is too short.
    BadKdc.setRatio(3.0f);

    Security.setProperty(
            "krb5.kdc.bad.policy", "tryLess:2," + BadKdc.toReal(1000));
    BadKdc.go(
            "121212222222(32){1,2}11112121(32){1,2}", // 1 2
            "11112121(32){1,2}11112121(32){1,2}", // 1 2
            // refresh
            "121212222222(32){1,2}11112121(32){1,2}", // 1 2
            // k3 off k2 on
            "1111(21){1,2}1111(22){1,2}", // 1
            // k1 on
            "(11){1,2}(12){1,2}"  // empty
    );
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:BadKdc2.java

示例6: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty("jdk.certpath.disabledAlgorithms",
            "MD2, RSA keySize < 1024");
    Security.setProperty("jdk.tls.disabledAlgorithms",
            "SSLv3, RC4, DH keySize < 768");

    if (debug)
        System.setProperty("javax.net.debug", "all");

    /*
     * Get the customized arguments.
     */
    parseArguments(args);

    /*
     * Start the tests.
     */
    new MD2InTrustAnchor();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:MD2InTrustAnchor.java

示例7: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty("jdk.certpath.disabledAlgorithms",
            "MD2, RSA keySize < 1024");
    Security.setProperty("jdk.tls.disabledAlgorithms",
            "SSLv3, RC4, DH keySize < 768");

    if (debug)
        System.setProperty("javax.net.debug", "all");

    /*
     * Start the tests.
     */
    new SunX509ExtendedTM();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:SunX509ExtendedTM.java

示例8: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // reset the security property to make sure that the algorithms
    // and keys used in this test are not disabled.
    Security.setProperty("jdk.tls.disabledAlgorithms", "");
    Security.setProperty("jdk.certpath.disabledAlgorithms", "");

    (new AnonCipherWithWantClientAuth()).run();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:AnonCipherWithWantClientAuth.java

示例9: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    for (Provider p : Security.getProviders()) {
        for (Provider.Service s : p.getServices()) {
            if (s.getType().equals("SecureRandom") &&
                    !s.getAlgorithm().contains("Block")) {
                test(SecureRandom.getInstance(s.getAlgorithm(), p));
            }
        }
    }
    Security.setProperty("securerandom.drbg.config", "HMAC_DRBG");
    test(SecureRandom.getInstance("DRBG"));
    Security.setProperty("securerandom.drbg.config", "CTR_DRBG");
    test(SecureRandom.getInstance("DRBG"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:NoSync.java

示例10: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        throw new RuntimeException("No parameters specified");
    }

    System.setProperty("javax.net.ssl.keyStore", keyFilename);
    System.setProperty("javax.net.ssl.keyStorePassword", passwd);
    System.setProperty("javax.net.ssl.trustStore", trustFilename);
    System.setProperty("javax.net.ssl.trustStorePassword", passwd);

    switch (args[0]) {
        case "default":
            // use default jdk.tls.disabledAlgorithms
            System.out.println("jdk.tls.disabledAlgorithms = "
                    + Security.getProperty("jdk.tls.disabledAlgorithms"));

            // check if RC4 cipher suites can't be used by default
            checkFailure(rc4_ciphersuites);
            break;
        case "empty":
            // reset jdk.tls.disabledAlgorithms
            Security.setProperty("jdk.tls.disabledAlgorithms", "");
            System.out.println("jdk.tls.disabledAlgorithms = "
                    + Security.getProperty("jdk.tls.disabledAlgorithms"));

            // check if RC4 cipher suites can be used
            // if jdk.tls.disabledAlgorithms is empty
            checkSuccess(rc4_ciphersuites);
            break;
        default:
            throw new RuntimeException("Wrong parameter: " + args[0]);
    }

    System.out.println("Test passed");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:DisabledAlgorithms.java

示例11: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty(
            "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");

    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();
    CertStore crls = generateCertificateStore();

    PKIXParameters params = new PKIXParameters(anchors);

    // add the CRL store
    params.addCertStore(crls);

    // Activate certificate revocation checking
    params.setRevocationEnabled(true);

    // set the validation time
    params.setDate(new Date(109, 5, 1));   // 2009-05-01

    // disable OCSP checker
    Security.setProperty("ocsp.enable", "false");

    // enable CRL checker
    System.setProperty("com.sun.security.enableCRLDP", "true");

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpect exception, should be a REVOKED CPVE", cpve);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:CircularCRLOneLevel.java

示例12: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // reset security properties to make sure that the algorithms
    // and keys used in this test are not disabled.
    Security.setProperty("jdk.tls.disabledAlgorithms", "");
    Security.setProperty("jdk.certpath.disabledAlgorithms", "");

    cipherSuite = args[0];

    WeakCipherSuite testCase = new WeakCipherSuite();
    testCase.runTest(testCase);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:WeakCipherSuite.java

示例13: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty("jdk.certpath.disabledAlgorithms",
            "MD2, RSA keySize < 1024");
    Security.setProperty("jdk.tls.disabledAlgorithms",
            "SSLv3, RC4, DH keySize < 768");

    if (debug)
        System.setProperty("javax.net.debug", "all");

    /*
     * Start the tests.
     */
    new DNSIdentities();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:DNSIdentities.java

示例14: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    // MD5 is used in this test case, don't disable MD5 algorithm.
    Security.setProperty("jdk.certpath.disabledAlgorithms",
            "MD2, RSA keySize < 1024");
    Security.setProperty("jdk.tls.disabledAlgorithms",
            "SSLv3, RC4, DH keySize < 768");

    if (debug)
        System.setProperty("javax.net.debug", "all");

    /*
     * Start the tests.
     */
    new Identities();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Identities.java

示例15: main

import java.security.Security; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    CertPath path = generateCertificatePath();
    Set<TrustAnchor> anchors = generateTrustAnchors();

    PKIXParameters params = new PKIXParameters(anchors);

    // disable certificate revocation checking
    params.setRevocationEnabled(false);

    // set the validation time
    params.setDate(new Date(109, 5, 8));   // 2009-05-01

    // disable OCSP checker
    Security.setProperty("ocsp.enable", "false");

    // disable CRL checker
    System.setProperty("com.sun.security.enableCRLDP", "false");

    CertPathValidator validator = CertPathValidator.getInstance("PKIX");

    try {
        validator.validate(path, params);
        throw new Exception("Should thrown UnsupportedOperationException");
    } catch (UnsupportedOperationException uoe) {
        // that is the expected exception.
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:NameConstraintsWithUnexpectedRID.java


注:本文中的java.security.Security.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。