Class ExternalIdFactory
- java.lang.Object
-
- com.google.gerrit.server.account.externalids.ExternalIdFactory
-
@Singleton public class ExternalIdFactory extends Object
-
-
Constructor Summary
Constructors Constructor Description ExternalIdFactory(ExternalIdKeyFactory externalIdKeyFactory, AuthConfig authConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExternalId
create(ExternalId.Key key, Account.Id accountId)
Creates an external ID.ExternalId
create(ExternalId.Key key, Account.Id accountId, String email, String hashedPassword)
Creates an external ID.ExternalId
create(ExternalId.Key key, Account.Id accountId, String email, String hashedPassword, org.eclipse.jgit.lib.ObjectId blobId)
Creates an external ID.ExternalId
create(String scheme, String id, Account.Id accountId)
Creates an external ID.ExternalId
create(String scheme, String id, Account.Id accountId, String email, String hashedPassword)
Creates an external ID.ExternalId
createEmail(Account.Id accountId, String email)
Creates an external ID using the `mailto`-scheme.ExternalId
createUsername(String id, Account.Id accountId, String plainPassword)
Create a external ID for a username (scheme "username").ExternalId
createWithEmail(ExternalId.Key key, Account.Id accountId, String email)
Creates an external ID with an email.ExternalId
createWithEmail(String scheme, String id, Account.Id accountId, String email)
Creates an external ID with an email.ExternalId
createWithPassword(ExternalId.Key key, Account.Id accountId, String email, String plainPassword)
Creates an external ID adding a hashed password computed from a plain password.ExternalId
parse(String noteId, byte[] raw, org.eclipse.jgit.lib.ObjectId blobId)
Parses an external ID from a byte array that contains the external ID as a Git config file text.
-
-
-
Constructor Detail
-
ExternalIdFactory
@Inject public ExternalIdFactory(ExternalIdKeyFactory externalIdKeyFactory, AuthConfig authConfig)
-
-
Method Detail
-
create
public ExternalId create(String scheme, String id, Account.Id accountId)
Creates an external ID.- Parameters:
scheme
- the scheme name, must not contain colons (':'). E.g.ExternalId.SCHEME_USERNAME
.id
- the external ID, must not contain colons (':')accountId
- the ID of the account to which the external ID belongs- Returns:
- the created external ID
-
create
public ExternalId create(String scheme, String id, Account.Id accountId, String email, String hashedPassword)
Creates an external ID.- Parameters:
scheme
- the scheme name, must not contain colons (':'). E.g.ExternalId.SCHEME_USERNAME
.id
- the external ID, must not contain colons (':')accountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
hashedPassword
- the hashed password of the external ID, may benull
- Returns:
- the created external ID
-
create
public ExternalId create(ExternalId.Key key, Account.Id accountId)
Creates an external ID.- Parameters:
key
- the external Id keyaccountId
- the ID of the account to which the external ID belongs- Returns:
- the created external ID
-
create
public ExternalId create(ExternalId.Key key, Account.Id accountId, String email, String hashedPassword)
Creates an external ID.- Parameters:
key
- the external Id keyaccountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
hashedPassword
- the hashed password of the external ID, may benull
- Returns:
- the created external ID
-
createWithPassword
public ExternalId createWithPassword(ExternalId.Key key, Account.Id accountId, String email, String plainPassword)
Creates an external ID adding a hashed password computed from a plain password.- Parameters:
key
- the external Id keyaccountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
plainPassword
- the plain HTTP password, may benull
- Returns:
- the created external ID
-
createUsername
public ExternalId createUsername(String id, Account.Id accountId, String plainPassword)
Create a external ID for a username (scheme "username").- Parameters:
id
- the external ID, must not contain colons (':')accountId
- the ID of the account to which the external ID belongsplainPassword
- the plain HTTP password, may benull
- Returns:
- the created external ID
-
createWithEmail
public ExternalId createWithEmail(String scheme, String id, Account.Id accountId, String email)
Creates an external ID with an email.- Parameters:
scheme
- the scheme name, must not contain colons (':'). E.g.ExternalId.SCHEME_USERNAME
.id
- the external ID, must not contain colons (':')accountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
- Returns:
- the created external ID
-
createWithEmail
public ExternalId createWithEmail(ExternalId.Key key, Account.Id accountId, String email)
Creates an external ID with an email.- Parameters:
key
- the external Id keyaccountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
- Returns:
- the created external ID
-
createEmail
public ExternalId createEmail(Account.Id accountId, String email)
Creates an external ID using the `mailto`-scheme.- Parameters:
accountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
- Returns:
- the created external ID
-
create
public ExternalId create(ExternalId.Key key, Account.Id accountId, String email, String hashedPassword, org.eclipse.jgit.lib.ObjectId blobId)
Creates an external ID.- Parameters:
key
- the external Id keyaccountId
- the ID of the account to which the external ID belongsemail
- the email of the external ID, may benull
hashedPassword
- the hashed password of the external ID, may benull
blobId
- the ID of the note blob in the external IDs branch that stores this external ID.null
if the external ID was created in code and is not yet stored in Git.- Returns:
- the created external ID
-
parse
public ExternalId parse(String noteId, byte[] raw, org.eclipse.jgit.lib.ObjectId blobId) throws org.eclipse.jgit.errors.ConfigInvalidException
Parses an external ID from a byte array that contains the external ID as a Git config file text.The Git config must have exactly one externalId subsection with an accountId and optionally email and password:
[externalId "username:jdoe"] accountId = 1003407 email = [email protected] password = bcrypt:4:LCbmSBDivK/hhGVQMfkDpA==:XcWn0pKYSVU/UJgOvhidkEtmqCp6oKB7
- Parameters:
noteId
- the SHA-1 sum of the external ID used as the note's IDraw
- a byte array that contains the external ID as a Git config file text.blobId
- the ID of the note blob in the external IDs branch that stores this external ID.null
if the external ID was created in code and is not yet stored in Git.- Returns:
- the parsed external ID
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
-