Package utu.vbingm.privaterepocloner
package utu.vbingm.privaterepocloner
PrivateRepoCloner: store Git HTTPS access tokens in the OS keyring and clone private repositories.
What this package provides
- PrivateRepoCloner — a small facade offering:
addProfile(name, url, token)
listProfiles()
cloneProfileRepo(name, targetDir)
repoExistsInKeyring(name)
removeProfile(name)
- RepoProfileStore — persists non-sensitive profile metadata (name, repoUrl, lastUsed epochMillis)
to
~/.private-repo-cloner/profiles.json
. Never stores tokens. - TokenKeyring — stores/retrieves/deletes tokens via the host OS keyring.
- Domain exceptions —
CouldNotReadProfilesJson
,IncorrectTokenForHttpsUrlException
,KeyringAccessException
.
Security model
- Tokens are never written to disk or returned by public APIs.
- Tokens are placed in the OS-native keyring (Keychain / Credential Manager / Secret Service).
- On most platforms, any process running as the same OS user can access that user’s keyring. This library prevents accidental disk/log leakage, but cannot protect against untrusted code executing as the same user.
- Do not embed credentials in repository URLs. Such URLs are rejected.
- Prefer least-privilege, short-lived tokens; rotate on compromise.
File format and design
profiles.json
stores an array of objects:{name, repoUrl, lastUsed}
wherelastUsed
is epoch millis.- Malformed or non-array JSON is automatically reset to an empty array and a warning is logged.
- Store creation enforces owner-only permissions where POSIX attributes are supported.
Thread-safety
- Profile store operations are guarded by a JVM-local lock to avoid concurrent file corruption.
- Keyring access uses short-lived handles (try-with-resources).
Error taxonomy (public facade)
IncorrectTokenForHttpsUrlException
— URL contains credentials or unsupported protocol.CouldNotReadProfilesJson
— persistent failure to read/repair/writeprofiles.json
.KeyringAccessException
— keyring backend access errors.IOException
— network/clone failures surfaced from JGit.
-
ClassDescriptionSignals a persistent failure to read, repair, or write
profiles.json
.Signals that the repository URL is incompatible with the HTTPS+token flow.Wraps keyring backend failures (e.g.,PasswordAccessException
,BackendNotSupportedException
).Facade for storing repo credentials and cloning private HTTPS repositories.Immutable DTO for profile metadata (token is never stored here).