Class ApiKeyConfig

java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.config.ApiKeyConfig

@Component @Configuration public class ApiKeyConfig extends Object
The ApiKeyConfig class is responsible for managing the Kassal API key. This class provides a way to access the API key, but only if the user is authenticated with a JWT token. If the user is not authenticated, a RuntimeException with message "Not authenticated" will be thrown.
Author:
Brage Halvorsen Kvamme, Trym Hamer Gudvangen
  • Constructor Details

    • ApiKeyConfig

      public ApiKeyConfig()
  • Method Details

    • getApiKey

      public String getApiKey()
      This method returns the Kassal API key if the user is authenticated. If the user is not authenticated, a RuntimeException with message "Not authenticated" will be thrown.
      Returns:
      The Kassal API key.
      Throws:
      RuntimeException - If the user is not authenticated.