Class CredentialService
java.lang.Object
io.github.jbastgen.stemma.app.credential.CredentialService
- All Implemented Interfaces:
io.github.jbastgen.stemma.git.api.CredentialLookup
public final class CredentialService
extends Object
implements io.github.jbastgen.stemma.git.api.CredentialLookup
The accounts Stemma knows (which host, which user, which key) and their secrets. The accounts are kept in a small
properties file; the secrets are in the
SecretVault, encrypted with the master password. Git backends use
this class as their CredentialLookup.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.github.jbastgen.stemma.git.api.CredentialLookup
io.github.jbastgen.stemma.git.api.CredentialLookup.Credential, io.github.jbastgen.stemma.git.api.CredentialLookup.Kind -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe account with this id.accounts()A copy of the list of accounts.add(String label, io.github.jbastgen.stemma.git.api.CredentialLookup.Kind kind, String host, String username, String keyFile) Adds an account (without secret); returns it with its new id.voidcleanUp()After unlocking: forgets secrets of accounts that are gone.static Pathaccounts.propertiesin the configuration folder.static Pathcredentials.vaultin the configuration folder.Optional<io.github.jbastgen.stemma.git.api.CredentialLookup.Credential> booleanWhether the secrets are needed but the vault is locked, so the user should be asked for the master password.voidRemoves the account; its secret goes too if the vault is open, else with the next clean-up.voidStores the secret of an account; the vault must be unlocked.voidupdate(CredentialService.Account changed) Replaces the account with the same id; nothing happens when there is none.vault()The vault that holds the secrets.
-
Constructor Details
-
CredentialService
- Parameters:
file-accounts.properties; the accounts without their secretsvault- the encrypted store of the secrets
-
-
Method Details
-
defaultFile
accounts.propertiesin the configuration folder. -
defaultVaultFile
credentials.vaultin the configuration folder. -
vault
The vault that holds the secrets. -
accounts
A copy of the list of accounts. -
account
The account with this id. -
add
public CredentialService.Account add(String label, io.github.jbastgen.stemma.git.api.CredentialLookup.Kind kind, String host, String username, String keyFile) throws IOException Adds an account (without secret); returns it with its new id.- Throws:
IOException
-
update
Replaces the account with the same id; nothing happens when there is none.- Throws:
IOException
-
remove
Removes the account; its secret goes too if the vault is open, else with the next clean-up.- Throws:
IOException
-
setSecret
Stores the secret of an account; the vault must be unlocked. An empty secret removes it.- Throws:
IOException
-
cleanUp
public void cleanUp()After unlocking: forgets secrets of accounts that are gone. -
needsUnlock
public boolean needsUnlock()Whether the secrets are needed but the vault is locked, so the user should be asked for the master password. -
find
public Optional<io.github.jbastgen.stemma.git.api.CredentialLookup.Credential> find(String accountId, String url) - Specified by:
findin interfaceio.github.jbastgen.stemma.git.api.CredentialLookup
-