Package org.apache.tomcat.util.digester
Class ServiceBindingPropertySource
- java.lang.Object
-
- org.apache.tomcat.util.digester.ServiceBindingPropertySource
-
- All Implemented Interfaces:
IntrospectionUtils.PropertySource,IntrospectionUtils.SecurePropertySource
public class ServiceBindingPropertySource extends java.lang.Object implements IntrospectionUtils.SecurePropertySource
AIntrospectionUtils.SecurePropertySourcethat uses Kubernetes service bindings to resolve expressions.The Kubernetes service binding specification can be found at https://servicebinding.io/.
Usage example:
Configure the certificate with a service binding.When the service binding is constructed as follows:
$SERVICE_BINDING_ROOT/ /custom-certificate/ /keyFile /file /chainFile /keyPassword<SSLHostConfig> <Certificate certificateKeyFile="${custom-certificate.keyFile}" certificateFile="${custom-certificate.file}" certificateChainFile="${custom-certificate.chainFile}" certificateKeyPassword="${chomp:custom-certificate.keyPassword}" type="RSA" /> </SSLHostConfig>The optional
How to configure:chomp:prefix will cause the ServiceBindingPropertySource to trim a single newline (\r\n,\r, or\n) from the end of the file, if it exists. This is a convenience for hand-edited files/values where removing a trailing newline is difficult, and trailing whitespace changes the meaning of the value.
or add this toecho "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource" >> conf/catalina.propertiesCATALINA_OPTS
NOTE: When configured the PropertySource for resolving expressions from system properties is still active.-Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource
-
-
Constructor Summary
Constructors Constructor Description ServiceBindingPropertySource()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetProperty(java.lang.String key)Resolves a property key using Kubernetes service bindings.java.lang.StringgetProperty(java.lang.String key, java.lang.ClassLoader classLoader)Obtain a property value, checking that code associated with the provided class loader has permission to access the property.
-
-
-
Method Detail
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Resolves a property key using Kubernetes service bindings.Keys are expected in the format
<binding-name>.<key>, which maps to$SERVICE_BINDING_ROOT/<binding-name>/<key>. The optionalchomp:prefix trims a trailing newline from the file content.- Specified by:
getPropertyin interfaceIntrospectionUtils.PropertySource- Parameters:
key- the property key to resolve- Returns:
- the resolved property value, or
nullif not found
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.ClassLoader classLoader)Description copied from interface:IntrospectionUtils.SecurePropertySourceObtain a property value, checking that code associated with the provided class loader has permission to access the property. If theclassLoaderisnullor ifclassLoaderdoes not implementPermissionCheckthen the property value will be looked up without a call toPermissionCheck.check(java.security.Permission)- Specified by:
getPropertyin interfaceIntrospectionUtils.SecurePropertySource- Parameters:
key- The key of the requested propertyclassLoader- The class loader associated with the code that trigger the property lookup- Returns:
- The property value or
nullif it could not be found or ifPermissionCheck.check(java.security.Permission)fails
-
-