Top Description Fields Constructors Methods
org.apache.tomcat.util.digester

public Class ServiceBindingPropertySource

extends Object
implements SecurePropertySource
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource, org.apache.tomcat.util.IntrospectionUtils.PropertySource
Imports
java.io.FilePermission, .IOException, java.nio.file.Files, .Path, .Paths, java.security.Permission, org.apache.tomcat.util.IntrospectionUtils, org.apache.tomcat.util.security.PermissionCheck

A org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource that uses Kubernetes service bindings to resolve expressions.

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 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.

How to configure:
echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource" >> conf/catalina.properties
or add this to CATALINA_OPTS
-Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource

Note

When configured the PropertySource for resolving expressions from system properties is still active.

See Also
Digester, Tomcat Configuration Reference System Properties

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public String
getProperty(String
The key of the requested property
key
,
ClassLoader
The class loader associated with the code that trigger the property lookup
classLoader
)

Implements org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource.getProperty.

Obtain a property value, checking that code associated with the provided class loader has permission to access the property.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SERVICE_BINDING_ROOT_ENV_VARback to summary
private static final String SERVICE_BINDING_ROOT_ENV_VAR

Constructor Detail

ServiceBindingPropertySourceback to summary
public ServiceBindingPropertySource()

Method Detail

getPropertyback to summary
public String getProperty(String key)

Implements org.apache.tomcat.util.IntrospectionUtils.PropertySource.getProperty.

Annotations
@Override
getPropertyback to summary
public String getProperty(String key, ClassLoader classLoader)

Implements org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource.getProperty.

Doc from org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource.getProperty.

Obtain a property value, checking that code associated with the provided class loader has permission to access the property. If the classLoader is null or if classLoader does not implement PermissionCheck then the property value will be looked up without a call to PermissionCheck#check(java.security.Permission)

Parameters
key:String

The key of the requested property

classLoader:ClassLoader

The class loader associated with the code that trigger the property lookup

Returns:String

The property value or null if it could not be found or if PermissionCheck#check(java.security.Permission) fails

Annotations
@Override