Package com.google.gerrit.server.account
Class VersionedAuthorizedKeys
- java.lang.Object
-
- com.google.gerrit.server.git.meta.VersionedMetaData
-
- com.google.gerrit.server.account.VersionedAuthorizedKeys
-
public class VersionedAuthorizedKeys extends VersionedMetaData
'authorized_keys' file in the refs/users/CD/ABCD branches of the All-Users repository.The `authorized_keys' files stores the public SSH keys of the user. The file format matches the standard SSH file format, which means that each key is stored on a separate line (see https://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#.7E.2F.ssh.2Fauthorized_keys).
The order of the keys in the file determines the sequence numbers of the keys. The first line corresponds to sequence number 1.
Invalid keys are marked with the prefix
# INVALID
.To keep the sequence numbers intact when a key is deleted, a
# DELETED
line is inserted at the position where the key was deleted.Other comment lines are ignored on read, and are not written back when the file is modified.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
VersionedAuthorizedKeys.Accessor
static interface
VersionedAuthorizedKeys.Factory
static class
VersionedAuthorizedKeys.SimpleSshKeyCreator
-
Nested classes/interfaces inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
VersionedMetaData.BatchMetaDataUpdate, VersionedMetaData.PathInfo
-
-
Field Summary
-
Fields inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
inserter, newTree, projectName, reader, revision, rw
-
-
Constructor Summary
Constructors Constructor Description VersionedAuthorizedKeys(SshKeyCreator sshKeyCreator, Account.Id accountId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getRefName()
protected void
onLoad()
Set up the metadata, parsing any state from the loaded revision.protected boolean
onSave(org.eclipse.jgit.lib.CommitBuilder commit)
Save any changes to the metadata in a commit.void
setKeys(Collection<AccountSshKey> newKeys)
Sets new SSH keys.-
Methods inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
commit, commitToNewRef, getObjectId, getPathInfos, getRevision, load, load, load, load, load, openUpdate, readConfig, readConfig, readFile, readTree, readUTF8, saveConfig, saveFile, saveUTF8, set, set, set
-
-
-
-
Constructor Detail
-
VersionedAuthorizedKeys
@Inject public VersionedAuthorizedKeys(SshKeyCreator sshKeyCreator, Account.Id accountId)
-
-
Method Detail
-
getRefName
protected String getRefName()
- Specified by:
getRefName
in classVersionedMetaData
- Returns:
- name of the reference storing this configuration.
-
onLoad
protected void onLoad() throws IOException
Description copied from class:VersionedMetaData
Set up the metadata, parsing any state from the loaded revision.- Specified by:
onLoad
in classVersionedMetaData
- Throws:
IOException
-
onSave
protected boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws IOException
Description copied from class:VersionedMetaData
Save any changes to the metadata in a commit.- Specified by:
onSave
in classVersionedMetaData
- Returns:
- true if the commit should proceed, false to abort.
- Throws:
IOException
-
setKeys
public void setKeys(Collection<AccountSshKey> newKeys)
Sets new SSH keys.The existing SSH keys are overwritten.
- Parameters:
newKeys
- the new public SSH keys
-
-