Java security system property

Java security system property

This class centralizes all security properties and common security methods. One of its primary uses is to manage providers. The default values of security properties are read from an implementation-specific location, which is typically the properties file lib/security/java.security in the Java installation directory.

Method Summary

This method used to return the value of a proprietary property in the master file of the «SUN» Cryptographic Service Provider in order to determine how to parse algorithm-specific parameters. Use the new provider-based and algorithm-independent AlgorithmParameters and KeyFactory engine classes (introduced in the J2SE version 1.2 platform) instead.

Returns a Set of Strings containing the names of all available algorithms or types for the specified Java cryptographic service (e.g., Signature, MessageDigest, Cipher, Mac, KeyStore).

Returns an array containing all installed providers that satisfy the specified* selection criteria, or null if no such providers have been installed.

Returns an array containing all installed providers that satisfy the specified selection criterion, or null if no such providers have been installed.

Methods inherited from class java.lang.Object

Method Detail

getAlgorithmProperty

@Deprecated public static String getAlgorithmProperty(String algName, String propName)

Deprecated. This method used to return the value of a proprietary property in the master file of the «SUN» Cryptographic Service Provider in order to determine how to parse algorithm-specific parameters. Use the new provider-based and algorithm-independent AlgorithmParameters and KeyFactory engine classes (introduced in the J2SE version 1.2 platform) instead.

Gets a specified property for an algorithm. The algorithm name should be a standard name. See the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names. One possible use is by specialized algorithm parsers, which may map classes to algorithms which they understand (much like Key parsers do).

insertProviderAt

Adds a new provider, at a specified position. The position is the preference order in which providers are searched for requested algorithms. The position is 1-based, that is, 1 is most preferred, followed by 2, and so on. If the given provider is installed at the requested position, the provider that used to be at that position, and all providers with a position greater than position , are shifted up one position (towards the end of the list of installed providers). A provider cannot be added if it is already installed. If there is a security manager, the SecurityManager.checkSecurityAccess(java.lang.String) method is called with the «insertProvider» permission target name to see if it’s ok to add a new provider. If this permission check is denied, checkSecurityAccess is called again with the «insertProvider.»+provider.getName() permission target name. If both checks are denied, a SecurityException is thrown.

Читайте также:  Svg css style class

addProvider

Adds a provider to the next position available. If there is a security manager, the SecurityManager.checkSecurityAccess(java.lang.String) method is called with the «insertProvider» permission target name to see if it’s ok to add a new provider. If this permission check is denied, checkSecurityAccess is called again with the «insertProvider.»+provider.getName() permission target name. If both checks are denied, a SecurityException is thrown.

removeProvider

Removes the provider with the specified name. When the specified provider is removed, all providers located at a position greater than where the specified provider was are shifted down one position (towards the head of the list of installed providers). This method returns silently if the provider is not installed or if name is null. First, if there is a security manager, its checkSecurityAccess method is called with the string «removeProvider.»+name to see if it’s ok to remove the provider. If the default implementation of checkSecurityAccess is used (i.e., that method is not overriden), then this will result in a call to the security manager’s checkPermission method with a SecurityPermission(«removeProvider.»+name) permission.

getProviders

Returns an array containing all the installed providers. The order of the providers in the array is their preference order.

getProvider

Returns the provider installed with the specified name, if any. Returns null if no provider with the specified name is installed or if name is null.

getProviders

public static Provider[] getProviders(String filter)
  • . The cryptographic service name must not contain any dots. A provider satisfies the specified selection criterion iff the provider implements the specified algorithm or type for the specified cryptographic service. For example, «CertificateFactory.X.509» would be satisfied by any provider that supplied a CertificateFactory implementation for X.509 certificates.
  • . : The cryptographic service name must not contain any dots. There must be one or more space characters between the and the . A provider satisfies this selection criterion iff the provider implements the specified algorithm or type for the specified cryptographic service and its implementation meets the constraint expressed by the specified attribute name/value pair. For example, «Signature.SHA1withDSA KeySize:1024» would be satisfied by any provider that implemented the SHA1withDSA signature algorithm with a keysize of 1024 (or larger).
Читайте также:  Текст

getProviders

public static Provider[] getProviders(MapString,String> filter)
  • . The cryptographic service name must not contain any dots. The value associated with the key must be an empty string. A provider satisfies this selection criterion iff the provider implements the specified algorithm or type for the specified cryptographic service.
  • . The cryptographic service name must not contain any dots. There must be one or more space characters between the and the . The value associated with the key must be a non-empty string. A provider satisfies this selection criterion iff the provider implements the specified algorithm or type for the specified cryptographic service and its implementation meets the constraint expressed by the specified attribute name/value pair.

getProperty

Gets a security property value. First, if there is a security manager, its checkPermission method is called with a java.security.SecurityPermission(«getProperty.»+key) permission to see if it’s ok to retrieve the specified security property value..

setProperty

Sets a security property value. First, if there is a security manager, its checkPermission method is called with a java.security.SecurityPermission(«setProperty.»+key) permission to see if it’s ok to set the specified security property value.

getAlgorithms

public static SetString> getAlgorithms(String serviceName)

Returns a Set of Strings containing the names of all available algorithms or types for the specified Java cryptographic service (e.g., Signature, MessageDigest, Cipher, Mac, KeyStore). Returns an empty Set if there is no provider that supports the specified service or if serviceName is null. For a complete list of Java cryptographic services, please see the Java Cryptography Architecture API Specification & Reference. Note: the returned set is immutable.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Источник

System Properties

This topic lists system properties that can be accessed by rich Internet applications (RIAs) that are restricted to the security sandbox and are launched with or without the Java Network Launch Protocol (JNLP). Some system properties cannot be accessed by sandbox RIAs.

Secure System Properties Accessible by All RIAs

All RIAs can retrieve the following secure system properties:

  • java.class.version
  • java.vendor
  • java.vendor.url
  • java.version
  • os.name
  • os.arch
  • os.version
  • file.separator
  • path.separator
  • line.separator

Secure System Properties Accessible by RIAs Launched by Using JNLP

RIAs launched by using JNLP can set and retrieve the following secure properties:

  • awt.useSystemAAFontSettings
  • http.agent
  • http.keepAlive
  • java.awt.syncLWRequests
  • java.awt.Window.locationByPlatform
  • javaws.cfg.jauthenticator
  • javax.swing.defaultlf
  • sun.awt.noerasebackground
  • sun.awt.erasebackgroundonresize
  • sun.java2d.d3d
  • sun.java2d.dpiaware
  • sun.java2d.noddraw
  • sun.java2d.opengl
  • swing.boldMetal
  • swing.metalTheme
  • swing.noxp
  • swing.useSystemFontSettings
Читайте также:  Java enum for name

Forbidden System Properties

Sandbox RIAs cannot access the following system properties:

Источник

Eyal Lupu Software Blog

Lately I encountered a configuration tweak I was not aware of, the problem: I had a single Java installation on a Linux machine from which I had to start two JVM instances — each using a different set of JCE providers. A reminder: the JVM loads its security configuration, including the JCE providers list, from a master security properties file within the JRE folder (JRE_HOME/lib/security/java.security), the location of that file is fixed in the JVM and cannot be modified. Going over the documentation (not too much helpful, I must admit) and the code (more helpful, look for Security.java, for example here) reveled the secret.

security.overridePropertiesFile

It all starts within the default java.security file provided with the JVM, looking at it we will find the following (somewhere around the middle of the file)

# # Determines whether this properties file can be appended to # or overridden on the command line via -Djava.security.properties # security.overridePropertiesFile=true

If the overridePropertiesFile doesn’t equal to true we can stop here — the rest of this article is irrelevant (unless we have the option to change it – but I didn’t have that). Lucky to me by default it does equal to true.

java.security.properties

  1. Overriding the entire file provided by the JVM — if the first character in the java.security.properties’ value is the equals sign the default configuration file will be entirely ignored, only the values in the file we are pointing to will be affective
  2. Appending and overriding values of the default file — any other first character in the property’s value (that is the first character in the alternate configuration file path) means that the alternate file will be loaded and appended to the default one. If the alternate file contains properties which are already in the default configuration file the alternate file will override those properties.
# # Completely override the default java.security file content # (notice the *two* equal signs) # java -Djava.security.properties==/etc/sysconfig/jvm1.java.security # # Append or override parts of the default java.security file # (notice the *single* equal sign) # java -Djava.security.properties=/etc/sysconfig/jvm.java.security

Be Carefull

As an important configuration option as it is we must not forget its security implications. We should always make sure that no one can tamper the value of the property and that no one can tamper the alternate file content if he shouldn’t be allowed to.

Источник

Оцените статью