Class EncryptedSecretConfig
java.lang.Object
com.scivicslab.actoriac.EncryptedSecretConfig
Parser for encrypted secret configuration files.
This class reads an encrypted INI-format file containing secrets (SSH keys, passphrases, sudo passwords), decrypts it, and provides access to the secrets with host/group/global priority.
File Format (before encryption)
[secrets:all] ssh_key=-----BEGIN OPENSSH PRIVATE KEY-----\nb3BlbnNz... ssh_passphrase=MyPassphrase123 sudo_password=MySudoPassword [secrets:webservers] sudo_password=WebServerSudoPassword [secrets:host:web1.example.com] ssh_key=...different key...
Usage Example
InputStream encryptedInput = new FileInputStream("secrets.enc");
String key = System.getenv("ACTOR_IAC_SECRET_KEY");
EncryptedSecretConfig config = EncryptedSecretConfig.parse(encryptedInput, key);
Map<String, String> secrets = config.getSecretsForHost("web1.example.com", "webservers");
String sshKey = secrets.get("ssh_key");
String passphrase = secrets.get("ssh_passphrase");
- Author:
- devteam@scivics-lab.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets global secrets.getSecretsForHost(String hostname, String... groupNames) Gets secrets for a specific host, applying priority rules.static EncryptedSecretConfigparse(InputStream encryptedInput, String encryptionKey) Parses an encrypted secret configuration file.private static EncryptedSecretConfigparseDecrypted(String content) Parses decrypted INI-format content.
-
Field Details
-
globalSecrets
-
groupSecrets
-
hostSecrets
-
-
Constructor Details
-
EncryptedSecretConfig
public EncryptedSecretConfig()
-
-
Method Details
-
parse
public static EncryptedSecretConfig parse(InputStream encryptedInput, String encryptionKey) throws IOException Parses an encrypted secret configuration file.- Parameters:
encryptedInput- InputStream of the encrypted fileencryptionKey- Base64-encoded encryption key- Returns:
- parsed EncryptedSecretConfig
- Throws:
IOException- if reading or decryption fails
-
parseDecrypted
Parses decrypted INI-format content.- Parameters:
content- decrypted INI content- Returns:
- parsed EncryptedSecretConfig
- Throws:
IOException- if parsing fails
-
getSecretsForHost
Gets secrets for a specific host, applying priority rules. Priority: host-specific > group-specific > global- Parameters:
hostname- HostnamegroupNames- Group names this host belongs to- Returns:
- Map of secrets for this host
-
getGlobalSecrets
-