本文整理汇总了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();
}
示例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
);
}
示例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");
}
示例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);
}
示例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
);
}
示例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();
}
示例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();
}
示例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();
}
示例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"));
}
示例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");
}
示例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);
}
}
}
示例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);
}
示例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();
}
示例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();
}
示例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.
}
}