當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。