本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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.");
}
示例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.");
}
}
示例13: regist
import java.security.Security; //导入方法依赖的package包/类
public void regist() {
if (Security.getProperty(XiProvider.PROVIDER_NAME) == null) {
Security.addProvider(new XiProvider());
}
}
示例14: getkeyManagerAlgorithm
import java.security.Security; //导入方法依赖的package包/类
private String getkeyManagerAlgorithm() {
String algorithm = Security.getProperty(
"ssl.KeyManagerFactory.algorithm");
return (algorithm != null) ?
algorithm : KeyManagerFactory.getDefaultAlgorithm();
}
示例15: run
import java.security.Security; //导入方法依赖的package包/类
public String run() {
return Security.getProperty(X509_PROVIDER);
}