Klasse ApiKeyManager
java.lang.Object
com.currencycalc.currencycalculatorjavafx.utils.ApiKeyManager
Utility class for managing the storage and retrieval of the API key.
The API key is stored in a serialized file within the operating system's
designated application data folder. The class ensures cross-platform
compatibility for Windows, macOS, and Linux.
The folder structure and file name are as follows:
- Windows:
%LOCALAPPDATA%/exchange-calculator/api_key.ser
- macOS:
~/Library/Application Support/exchange-calculator/api_key.ser
- Linux:
~/.config/exchange-calculator/api_key.ser
- Version:
- 1.0.0
- Autor:
- Tim Platzer
-
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprivate static File
Retrieves the file where the API key is stored.private static File
Retrieves the path to the application data folder based on the operating system.static String
Loads the API key from the storage file.static void
saveApiKey
(String apiKey) Saves the provided API key to the storage file.
-
Felddetails
-
APP_FOLDER_NAME
The folder name where the application data is stored.- Siehe auch:
-
API_KEY_FILE_NAME
The file name for storing the API key.- Siehe auch:
-
-
Konstruktordetails
-
ApiKeyManager
public ApiKeyManager()
-
-
Methodendetails
-
getAppDataFolder
Retrieves the path to the application data folder based on the operating system.- Gibt zurück:
- A
File
object representing the application data folder.
-
getApiKeyFile
Retrieves the file where the API key is stored. Ensures the application data folder exists, creating it if necessary.- Gibt zurück:
- A
File
object representing the API key file. - Löst aus:
RuntimeException
- if the application data directory cannot be created.
-
saveApiKey
Saves the provided API key to the storage file.- Parameter:
apiKey
- The API key to save.- Löst aus:
IOException
- If an I/O error occurs while saving the key.
-
loadApiKey
Loads the API key from the storage file.- Gibt zurück:
- The stored API key as a
String
. - Löst aus:
IOException
- If the file does not exist or an I/O error occurs.ClassNotFoundException
- If the serialized object cannot be deserialized.
-