當前位置: 首頁>>代碼示例>>Java>>正文


Java Security.getProperty方法代碼示例

本文整理匯總了Java中java.security.Security.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Security.getProperty方法的具體用法?Java Security.getProperty怎麽用?Java Security.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.Security的用法示例。


在下文中一共展示了Security.getProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.security.Security; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:DefaultSSLServSocketFac.java

示例2: initRegistryFilter

import java.security.Security; //導入方法依賴的package包/類
/**
 * Initialize the registryFilter from the security properties or system property; if any
 * @return an ObjectInputFilter, or null
 */
private static ObjectInputFilter initRegistryFilter() {
    ObjectInputFilter filter = null;
    String props = System.getProperty(REGISTRY_FILTER_PROPNAME);
    if (props == null) {
        props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
    }
    if (props != null) {
        filter = ObjectInputFilter.Config.createFilter(props);
        Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
        if (regLog.isLoggable(Log.BRIEF)) {
            regLog.log(Log.BRIEF, "registryFilter = " + filter);
        }
    }
    return filter;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:RegistryImpl.java

示例3: setSecurityProperty

import java.security.Security; //導入方法依賴的package包/類
/**
 * Set the proper security property
 * @param properties the package.* property.
 */
private final void setSecurityProperty(String properties, String packageList){
    if (System.getSecurityManager() != null){
        String definition = Security.getProperty(properties);
        if( definition != null && definition.length() > 0 ){
            if (packageList.length() > 0) {
                definition = definition + ',' + packageList;
            }
        } else {
            definition = packageList;
        }

        Security.setProperty(properties, definition);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:19,代碼來源:SecurityConfig.java

示例4: initRegistryFilter

import java.security.Security; //導入方法依賴的package包/類
/**
 * Initialize the registryFilter from the security properties or system property; if any
 * @return an ObjectInputFilter, or null
 */
@SuppressWarnings("deprecation")
private static ObjectInputFilter initRegistryFilter() {
    ObjectInputFilter filter = null;
    String props = System.getProperty(REGISTRY_FILTER_PROPNAME);
    if (props == null) {
        props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
    }
    if (props != null) {
        filter = SharedSecrets.getJavaObjectInputFilterAccess().createFilter2(props);
        Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
        if (regLog.isLoggable(Log.BRIEF)) {
            regLog.log(Log.BRIEF, "registryFilter = " + filter);
        }
    }
    return filter;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:RegistryImpl.java

示例5: setSecurityProperty

import java.security.Security; //導入方法依賴的package包/類
/**
 * Set the proper security property
 * 
 * @param properties
 *            the package.* property.
 */
private final void setSecurityProperty(String properties, String packageList) {
	if (System.getSecurityManager() != null) {
		String definition = Security.getProperty(properties);
		if (definition != null && definition.length() > 0) {
			if (packageList.length() > 0) {
				definition = definition + ',' + packageList;
			}
		} else {
			definition = packageList;
		}

		Security.setProperty(properties, definition);
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:21,代碼來源:SecurityConfig.java

示例6: setSecurityProperty

import java.security.Security; //導入方法依賴的package包/類
/**
 * Set the proper security property
 * @param properties the package.* property.
 */
private final void setSecurityProperty(String properties, String packageList){
    if (System.getSecurityManager() != null){
        String definition = Security.getProperty(properties);
        if( definition != null && definition.length() > 0 ){
            definition += ",";
        }

        Security.setProperty(properties,
            // FIX ME package "javax." was removed to prevent HotSpot
            // fatal internal errors
            definition + packageList);      
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:SecurityConfig.java

示例7: run

import java.security.Security; //導入方法依賴的package包/類
/**
 * Determines the boolean value of the security property whose name was
 * specified in the constructor.
 *
 * @return the <code>Boolean</code> value of the security property.
 */
public Boolean run() {
    boolean b = false;
    try {
        String value = Security.getProperty(theProp);
        b = (value != null) && value.equalsIgnoreCase("true");
    } catch (NullPointerException e) {}
    return b;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:GetBooleanSecurityPropertyAction.java

示例8: 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);

    // Activate OCSP
    Security.setProperty("ocsp.enable", "true");
    System.setProperty("com.sun.security.enableCRLDP", "true");

    // Ensure that the ocsp.responderURL property is not set.
    if (Security.getProperty("ocsp.responderURL") != null) {
        throw new
            Exception("The ocsp.responderURL property must not be set");
    }

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

    try {
        validator.validate(path, params);
    } catch (CertPathValidatorException cpve) {
        if (cpve.getReason() != BasicReason.REVOKED) {
            throw new Exception(
                "unexpected exception, should be a REVOKED CPVE", cpve);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:FailoverToCRL.java

示例9: initDgcFilter

import java.security.Security; //導入方法依賴的package包/類
/**
 * Initialize the dgcFilter from the security properties or system property; if any
 * @return an ObjectInputFilter, or null
 */
private static ObjectInputFilter initDgcFilter() {
    ObjectInputFilter filter = null;
    String props = System.getProperty(DGC_FILTER_PROPNAME);
    if (props == null) {
        props = Security.getProperty(DGC_FILTER_PROPNAME);
    }
    if (props != null) {
        filter = ObjectInputFilter.Config.createFilter(props);
        if (dgcLog.isLoggable(Log.BRIEF)) {
            dgcLog.log(Log.BRIEF, "dgcFilter = " + filter);
        }
    }
    return filter;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:DGCImpl.java

示例10: actual

import java.security.Security; //導入方法依賴的package包/類
/**
 * Returns the list of restricted packages in the package.access property.
 */
private static List<String> actual() {
    String prop = Security.getProperty("package.access");
    List<String> packages = new ArrayList<>();
    if (prop != null && !prop.equals("")) {
        StringTokenizer tok = new StringTokenizer(prop, ",");
        while (tok.hasMoreElements()) {
            String s = tok.nextToken().trim();
            packages.add(s);
        }
    }
    return packages;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:CheckPackageMatching.java

示例11: verifyPreferredProviderProperty

import java.security.Security; //導入方法依賴的package包/類
private static void verifyPreferredProviderProperty(String os, String arch,
        String preferred) {
    String preferredProvider
            = Security.getProperty("jdk.security.provider.preferred");
    if (!preferredProvider.equals(preferred)) {
        System.out.println("Expected: " + preferred + "\nResult: " +
                preferredProvider);
        throw new RuntimeException(String.format(
                "Test Failed: wrong jdk.security.provider.preferred value "
                + "on %s-%s", os, arch));
    }
    System.out.println(
            "Preferred provider security property verification complete.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:PreferredProviderTest.java

示例12: init

import java.security.Security; //導入方法依賴的package包/類
public void init(Properties properties)
        throws GeneralSecurityException, IOException {
    // required, could use default keyStore, but it is better practice to explicitly specify
    final String keyStoreFilename = properties.getProperty("javax.net.ssl.keyStore");
    // required
    final String keyStorePassword = properties.getProperty("javax.net.ssl.keyStorePassword");
    // optional, uses default if not specified 
    String keyStoreType = properties.getProperty("javax.net.ssl.keyStoreType");
    if (keyStoreType == null) {
        keyStoreType = KeyStore.getDefaultType();
        logger.logWarning("Using default keystore type " + keyStoreType);
    }
    if (keyStoreFilename == null || keyStorePassword == null) {
        logger.logWarning("TLS server settings will be inactive - TLS key store will use JVM defaults"
                + " keyStoreType=" +  keyStoreType
                + " javax.net.ssl.keyStore=" + keyStoreFilename
                + " javax.net.ssl.keyStorePassword=" + (keyStorePassword == null? null: "***"));
    }

    // required, could use default trustStore, but it is better practice to explicitly specify
    final String trustStoreFilename = properties.getProperty("javax.net.ssl.trustStore");
    // optional, if not specified using keyStorePassword
    String trustStorePassword = properties.getProperty("javax.net.ssl.trustStorePassword");
    if(trustStorePassword == null) {
    	logger.logInfo("javax.net.ssl.trustStorePassword is null, using the password passed through javax.net.ssl.keyStorePassword");
    	trustStorePassword = keyStorePassword;
    }
    // optional, uses default if not specified 
    String trustStoreType = properties.getProperty("javax.net.ssl.trustStoreType");
    if (trustStoreType == null) {
        trustStoreType = KeyStore.getDefaultType();
        logger.logWarning("Using default truststore type " + trustStoreType);
    }
    if (trustStoreFilename == null || trustStorePassword == null) {
        logger.logWarning("TLS trust settings will be inactive - TLS trust store will use JVM defaults."
                + " trustStoreType=" +  trustStoreType
                + " javax.net.ssl.trustStore=" +  trustStoreFilename
                + " javax.net.ssl.trustStorePassword=" + (trustStorePassword == null? null: "***"));
    }

    String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
    if (algorithm == null) {
        algorithm = "SunX509";
    }
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
        logger.logDebug("SecurityManagerProvider " + this.getClass().getCanonicalName() + " will use algorithm " + algorithm);
    }
    
    keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
    if(keyStoreFilename != null) {
    	final KeyStore ks = KeyStore.getInstance(keyStoreType);
    	ks.load(new FileInputStream(new File(keyStoreFilename)), keyStorePassword.toCharArray());
    	
    	keyManagerFactory.init(ks, keyStorePassword.toCharArray());
    } else {
    	keyManagerFactory.init(null, null);
    }

    trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
    if(trustStoreFilename != null) {
    	final KeyStore ts = KeyStore.getInstance(trustStoreType);
    	ts.load(new FileInputStream(new File(trustStoreFilename)), trustStorePassword.toCharArray());
    	
    	trustManagerFactory.init((KeyStore) ts);
    } else {
    	trustManagerFactory.init((KeyStore)null);
    }
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
    	logger.logDebug("TLS settings OK. SecurityManagerProvider " + this.getClass().getCanonicalName() + " initialized.");
    }
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:72,代碼來源:DefaultSecurityManagerProvider.java

示例13: regist

import java.security.Security; //導入方法依賴的package包/類
public void regist() {
    if (Security.getProperty(XiProvider.PROVIDER_NAME) == null) {
        Security.addProvider(new XiProvider());
    }
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:6,代碼來源:XiProviderRegister.java

示例14: getkeyManagerAlgorithm

import java.security.Security; //導入方法依賴的package包/類
private String getkeyManagerAlgorithm() {
  String algorithm = Security.getProperty(
          "ssl.KeyManagerFactory.algorithm");
  return (algorithm != null) ?
          algorithm : KeyManagerFactory.getDefaultAlgorithm();
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:7,代碼來源:ThriftSource.java

示例15: run

import java.security.Security; //導入方法依賴的package包/類
public String run() {
    return Security.getProperty(X509_PROVIDER);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:X509Certificate.java


注:本文中的java.security.Security.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。