Class EncryptionAlgorithm

java.lang.Object
lib.pwss.algorithm_switch.EncryptionAlgorithm

public final class EncryptionAlgorithm extends Object
The EncryptionAlgorithm class manages encryption algorithms and ensures that only one instance exists.

This class initializes itself using configuration values read from a config file, ensuring that the chosen algorithm for production is safe and valid.

  • Constructor Details

    • EncryptionAlgorithm

      public EncryptionAlgorithm()
      Constructor to initialize the EncryptionAlgorithm with configuration values.

      If more than one instance is created, it exits the system.

  • Method Details

    • getEncryptionAlgorithmChoices

      public final EncryptionAlgorithmChoices getEncryptionAlgorithmChoices()
      Returns the encryption algorithm choices object.

      This method returns the current instance of EncryptionAlgorithmChoices associated with this class. If, unexpectedly, the encryptionAlgorithmChoices object is null (which should not happen in normal operation), it will exit the system by calling System.exit(1).

      Returns:
      The encryption algorithm choices object containing the available encryption algorithms.
    • getSELECTED_ALGORITHM_FOR_PRODUCTION

      public final int getSELECTED_ALGORITHM_FOR_PRODUCTION()
      Returns the selected algorithm identifier for production.

      This method returns the current value of SELECTED_ALGORITHM_FOR_PRODUCTION, which represents the chosen encryption algorithm for production purposes. The integer returned corresponds to predefined choices in the system (e.g., 1, 2, or 3) that map to specific algorithms.

      Returns:
      An integer representing the selected algorithm identifier for production.
    • getSELECTED_ALGORITHM_FOR_PRODUCTION_STRING

      public final String getSELECTED_ALGORITHM_FOR_PRODUCTION_STRING()
      Returns the selected algorithm for production as a string based on a predefined selection.

      This method checks the value of SELECTED_ALGORITHM_FOR_PRODUCTION and returns the corresponding encryption algorithm name from the encryptionAlgorithmChoices object. If none of the predefined values match, it returns "error".

      Returns:
      The selected algorithm for production as a string, or "error" if the selection is invalid.