Class SecuritySettings

java.lang.Object
com.codingchili.core.configuration.system.SecuritySettings
All Implemented Interfaces:
Configurable, Serializable

public class SecuritySettings extends Object implements Configurable
Contains mappings of security dependencies between services.

For example: service A may depend on a shared secret with service B, or depend on service B generating a token of its secret.

To establish such dependencies, a dependency is added to service A with a path or a regex to match the path of service B. The AuthenticationDependency class contains the type of configuration that is requested, for example a token or shared secret.

See Also:
Serialized Form
  • Constructor Details

    • SecuritySettings

      public SecuritySettings()
  • Method Details

    • getPath

      public String getPath()
      Description copied from interface: Configurable
      Get the path of a loaded configuration file.
      Specified by:
      getPath in interface Configurable
      Returns:
      the directory path to the configuration file.
    • addKeystore

      public KeyStoreBuilder<SecuritySettings> addKeystore()
      Loads a certificate from disk and saves it with the given name. Requires manual input to enter the secret for the keystore.
      Returns:
      a keystore builder.
    • getKeystore

      public TrustAndKeyProvider getKeystore(String storeId)
      Parameters:
      storeId - name of the keystore to retrieve: the mapped shortname of the filename with extension.
      Returns:
      a keystore if it is loaded, if no keystore is added with the given shortname uses a self signed certificate. If it fails to load a keystore then the application shuts down.
    • getByName

      public Optional<KeyStoreReference> getByName(String storeId)
      Retrieve a keystore given its short name (ID).
      Parameters:
      storeId - the store id to retrieve.
      Returns:
      a keystore that matches the given id, empty otherwise.
    • getKeystores

      public Set<KeyStoreReference> getKeystores()
      Returns:
      a list of configured keystores.
    • setKeystores

      public SecuritySettings setKeystores(Set<KeyStoreReference> keystores)
      Parameters:
      keystores - keystores to set
      Returns:
      fluent
    • getSecretBytes

      public int getSecretBytes()
      Returns:
      the number of bytes a secret must have at a minimum.
    • setSecretBytes

      public void setSecretBytes(int secretBytes)
      Parameters:
      secretBytes - the number of bytes generated secrets consists of.
    • getArgon

      public ArgonSettings getArgon()
      Returns:
      argon2 parameters used for password hashing.
    • setArgon

      public void setArgon(ArgonSettings argon)
      Parameters:
      argon - the argon2 parameters used for password hashing.
    • getSignatureAlgorithm

      public String getSignatureAlgorithm()
      Returns:
      the signature algorithm to use for signatures.
    • setSignatureAlgorithm

      public void setSignatureAlgorithm(String signatureAlgorithm)
      Sets the signature algorithm to use for signing.

      supported by the default provider: - SHA1withDSA - SHA1withRSA - SHA256withRSA

      Parameters:
      signatureAlgorithm - the algorithm identifier to use.
    • getHmacAlgorithm

      public String getHmacAlgorithm()
      Returns:
      the HMAC algorithm identifier used to create HMAC tokens.
    • setHmacAlgorithm

      public void setHmacAlgorithm(String hmacAlgorithm)
      Parameters:
      hmacAlgorithm - the HMAC algorithm used to create HMAC tokens, the specified algorithm must be available in the JVM.
    • getDependencies

      public Map<String,​AuthenticationDependency> getDependencies()
      Returns:
      a map of dependencies, where the key is the regex that match other configurations. The value contains the actual security configuration to be applied.
    • setDependencies

      public void setDependencies(Map<String,​AuthenticationDependency> dependencies)
      Parameters:
      dependencies - set the security configuration dependencies.
    • getDependency

      public Optional<AuthenticationDependency> getDependency(String path)
      Parameters:
      path - the regex (compared as text) dependency identifier.
      Returns:
      the defined dependency with the given dependency path.
    • addDependency

      public SecuritySettings addDependency(String path, AuthenticationDependency dependency)
      Parameters:
      path - a regex to match the path of configuration files that the dependency applies to.
      dependency - the dependency that requires security parameters from files that the path mataches.
      Returns:
      fluent
    • getTokenttl

      public int getTokenttl()
      Returns:
      the time to live for generated tokens in seconds.
    • setTokenttl

      public SecuritySettings setTokenttl(int tokenttl)
      Parameters:
      tokenttl - the time to live for generated tokens in seconds.
      Returns:
      fluent.