Package org.kiwiproject.config
Class SecureEndpointsConfiguration
- java.lang.Object
-
- org.kiwiproject.config.SSLContextConfiguration
-
- org.kiwiproject.config.SecureEndpointsConfiguration
-
- All Implemented Interfaces:
KeyAndTrustStoreConfigProvider,TrustStoreConfigProvider
public class SecureEndpointsConfiguration extends SSLContextConfiguration
Configuration for secure REST endpoints, including the configuration from anSSLContextConfigurationas well as adding a collection ofEndpointConfigurationinstances. Supports programmatic creation using a builder. Also supports construction from external configuration, e.g. from a YAML configuration file, using the no-args constructor and setter methods.As this is a configuration class that supports population from external configuration, it is mutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSecureEndpointsConfiguration.BuilderBuilder class forSecureEndpointsConfiguration.
-
Constructor Summary
Constructors Constructor Description SecureEndpointsConfiguration()Create instance with empty collection of endpoints.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallEndpointsSecure()Returns true if all of the endpoints in this configuration are secure.booleananyEndpointSecure()Returns true if any of the endpoints in this configuration is secure.static SecureEndpointsConfiguration.Builderbuilder()Return a new builder instance.EndpointConfigurationgetEndpointByPathEnding(String pathEnding)Finds theEndpointConfigurationwith a path ending with the givenpathEnding, throwing an exception if not found.Optional<EndpointConfiguration>getEndpointByPathEndingOrEmpty(String pathEnding)Finds theEndpointConfigurationwith a path ending with the givenpathEnding, returning an empty Optional if not found.EndpointConfigurationgetEndpointByTag(String tag)Finds theEndpointConfigurationwith the given tag, throwing an exception if not found.Optional<EndpointConfiguration>getEndpointByTagOrEmpty(String tag)Finds theEndpointConfigurationwith the given tag, returning an empty Optional if not found.booleanisSecure()Returns true if any of the endpoints in this configuration is secure.-
Methods inherited from class org.kiwiproject.config.SSLContextConfiguration
getTrustStoreType, toSimpleSSLContextFactory, toSSLContext, toTlsContextConfiguration, toTlsContextConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.kiwiproject.security.KeyAndTrustStoreConfigProvider
getKeyStorePassword, getKeyStorePath, getKeyStoreType
-
Methods inherited from interface org.kiwiproject.security.TrustStoreConfigProvider
getProtocol, getTrustStorePassword, getTrustStorePath, isVerifyHostname, toSslSocketFactory
-
-
-
-
Method Detail
-
builder
public static SecureEndpointsConfiguration.Builder builder()
Return a new builder instance.- Returns:
- the builder instance
-
isSecure
public boolean isSecure()
Returns true if any of the endpoints in this configuration is secure.Alias for
anyEndpointSecure().- Returns:
- true if any endpoint is secure
-
anyEndpointSecure
public boolean anyEndpointSecure()
Returns true if any of the endpoints in this configuration is secure.- Returns:
trueif any of endpoint is secure:falseotherwise
-
allEndpointsSecure
public boolean allEndpointsSecure()
Returns true if all of the endpoints in this configuration are secure.- Returns:
trueif all endpoints are secure:falseotherwise
-
getEndpointByTag
public EndpointConfiguration getEndpointByTag(String tag)
Finds theEndpointConfigurationwith the given tag, throwing an exception if not found.- Parameters:
tag- the tag to search for- Returns:
- the EndpointConfiguration with the given tag
- Throws:
IllegalStateException- if there is no such endpoint
-
getEndpointByTagOrEmpty
public Optional<EndpointConfiguration> getEndpointByTagOrEmpty(String tag)
Finds theEndpointConfigurationwith the given tag, returning an empty Optional if not found.- Parameters:
tag- the tag to search for- Returns:
- an
Optionalthat may or may not contain an endpoint
-
getEndpointByPathEnding
public EndpointConfiguration getEndpointByPathEnding(String pathEnding)
Finds theEndpointConfigurationwith a path ending with the givenpathEnding, throwing an exception if not found.- Parameters:
pathEnding- the end of the path to look for in each endpoint- Returns:
- the EndpointConfiguration with the given path ending
- Throws:
IllegalStateException- if there is no such endpoint
-
getEndpointByPathEndingOrEmpty
public Optional<EndpointConfiguration> getEndpointByPathEndingOrEmpty(String pathEnding)
Finds theEndpointConfigurationwith a path ending with the givenpathEnding, returning an empty Optional if not found.- Parameters:
pathEnding- the end of the path to look for in each endpoint- Returns:
- an
Optionalthat may or may not contain an endpoint
-
-