public abstract class ExternalId
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
ExternalId.Key |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SCHEME_EXTERNAL
Scheme for external auth used during authentication, e.g.
|
static java.lang.String |
SCHEME_GERRIT
Scheme used for
AuthType.LDAP , AuthType.CLIENT_SSL_CERT_LDAP , AuthType.HTTP_LDAP , and AuthType.LDAP_BIND usernames. |
static java.lang.String |
SCHEME_GPGKEY
Scheme used for GPG public keys.
|
static java.lang.String |
SCHEME_MAILTO
Scheme used to represent only an email address.
|
static java.lang.String |
SCHEME_USERNAME
Scheme for the username used to authenticate an account, e.g.
|
static java.lang.String |
SCHEME_UUID
Scheme used for randomly created identities constructed by a UUID.
|
Constructor and Description |
---|
ExternalId() |
Modifier and Type | Method and Description |
---|---|
abstract Account.Id |
accountId() |
abstract org.eclipse.jgit.lib.ObjectId |
blobId()
ID of the note blob in the external IDs branch that stores this external ID.
|
void |
checkThatBlobIdIsSet() |
static ExternalId |
create(ExternalId.Key key,
Account.Id accountId) |
static ExternalId |
create(ExternalId.Key key,
Account.Id accountId,
java.lang.String email,
java.lang.String hashedPassword) |
static ExternalId |
create(ExternalId.Key key,
Account.Id accountId,
java.lang.String email,
java.lang.String hashedPassword,
org.eclipse.jgit.lib.ObjectId blobId) |
static ExternalId |
create(java.lang.String scheme,
java.lang.String id,
Account.Id accountId)
Creates an external ID.
|
static ExternalId |
create(java.lang.String scheme,
java.lang.String id,
Account.Id accountId,
java.lang.String email,
java.lang.String hashedPassword)
Creates an external ID.
|
static ExternalId |
createEmail(Account.Id accountId,
java.lang.String email) |
static ExternalId |
createUsername(java.lang.String id,
Account.Id accountId,
java.lang.String plainPassword)
Create a external ID for a username (scheme "username").
|
static ExternalId |
createWithEmail(ExternalId.Key key,
Account.Id accountId,
java.lang.String email) |
static ExternalId |
createWithEmail(java.lang.String scheme,
java.lang.String id,
Account.Id accountId,
java.lang.String email)
Creates an external ID with an email.
|
static ExternalId |
createWithPassword(ExternalId.Key key,
Account.Id accountId,
java.lang.String email,
java.lang.String plainPassword) |
abstract java.lang.String |
email() |
boolean |
equals(java.lang.Object obj)
For checking if two external IDs are equals the blobId is excluded and external IDs that have
different blob IDs but identical other fields are considered equal.
|
static java.util.stream.Stream<java.lang.String> |
getEmails(java.util.Collection<ExternalId> extIds)
Returns all IDs of the provided external IDs that have the
SCHEME_MAILTO
scheme as a distinct stream. |
static java.util.Optional<java.lang.String> |
getUserName(java.util.Collection<ExternalId> extIds)
Returns the ID of the first external ID from the provided external IDs that has the
SCHEME_USERNAME scheme. |
int |
hashCode() |
boolean |
isScheme(java.lang.String scheme) |
static boolean |
isValidUsername(java.lang.String username) |
abstract ExternalId.Key |
key() |
static ExternalId |
parse(java.lang.String noteId,
byte[] raw,
org.eclipse.jgit.lib.ObjectId blobId)
Parses an external ID from a byte array that contain the external ID as an Git config file
text.
|
static ExternalId |
parse(java.lang.String noteId,
org.eclipse.jgit.lib.Config externalIdConfig,
org.eclipse.jgit.lib.ObjectId blobId) |
abstract java.lang.String |
password() |
byte[] |
toByteArray() |
java.lang.String |
toString()
Exports this external ID as Git config file text.
|
void |
writeToConfig(org.eclipse.jgit.lib.Config c) |
public static final java.lang.String SCHEME_GERRIT
AuthType.LDAP
, AuthType.CLIENT_SSL_CERT_LDAP
, AuthType.HTTP_LDAP
, and AuthType.LDAP_BIND
usernames.
The name gerrit:
was a very poor choice.
Scheme names must not contain colons (':').
public static final java.lang.String SCHEME_UUID
public static final java.lang.String SCHEME_MAILTO
public static final java.lang.String SCHEME_USERNAME
public static final java.lang.String SCHEME_GPGKEY
public static final java.lang.String SCHEME_EXTERNAL
public static boolean isValidUsername(java.lang.String username)
public static java.util.Optional<java.lang.String> getUserName(java.util.Collection<ExternalId> extIds)
SCHEME_USERNAME
scheme.extIds
- external IDsSCHEME_USERNAME
schemepublic static java.util.stream.Stream<java.lang.String> getEmails(java.util.Collection<ExternalId> extIds)
SCHEME_MAILTO
scheme as a distinct stream.extIds
- external IDsSCHEME_MAILTO
schemepublic static ExternalId create(java.lang.String scheme, java.lang.String id, Account.Id accountId)
scheme
- the scheme name, must not contain colons (':')id
- the external ID, must not contain colons (':')accountId
- the ID of the account to which the external ID belongspublic static ExternalId create(java.lang.String scheme, java.lang.String id, Account.Id accountId, java.lang.String email, java.lang.String hashedPassword)
scheme
- the scheme name, must not contain colons (':')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 be null
hashedPassword
- the hashed password of the external ID, may be null
public static ExternalId create(ExternalId.Key key, Account.Id accountId)
public static ExternalId create(ExternalId.Key key, Account.Id accountId, java.lang.String email, java.lang.String hashedPassword)
public static ExternalId createWithPassword(ExternalId.Key key, Account.Id accountId, java.lang.String email, java.lang.String plainPassword)
public static ExternalId createUsername(java.lang.String id, Account.Id accountId, java.lang.String plainPassword)
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 be null
public static ExternalId createWithEmail(java.lang.String scheme, java.lang.String id, Account.Id accountId, java.lang.String email)
scheme
- the scheme name, must not contain colons (':')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 be null
public static ExternalId createWithEmail(ExternalId.Key key, Account.Id accountId, java.lang.String email)
public static ExternalId createEmail(Account.Id accountId, java.lang.String email)
public static ExternalId create(ExternalId.Key key, Account.Id accountId, java.lang.String email, java.lang.String hashedPassword, org.eclipse.jgit.lib.ObjectId blobId)
public static ExternalId parse(java.lang.String noteId, byte[] raw, org.eclipse.jgit.lib.ObjectId blobId) throws org.eclipse.jgit.errors.ConfigInvalidException
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
org.eclipse.jgit.errors.ConfigInvalidException
public static ExternalId parse(java.lang.String noteId, org.eclipse.jgit.lib.Config externalIdConfig, org.eclipse.jgit.lib.ObjectId blobId) throws org.eclipse.jgit.errors.ConfigInvalidException
org.eclipse.jgit.errors.ConfigInvalidException
public abstract ExternalId.Key key()
public abstract Account.Id accountId()
public abstract java.lang.String email()
public abstract java.lang.String password()
public abstract org.eclipse.jgit.lib.ObjectId blobId()
null
if
the external ID was created in code and is not yet stored in Git.public void checkThatBlobIdIsSet()
public boolean isScheme(java.lang.String scheme)
public byte[] toByteArray()
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
The Git config has 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
toString
in class java.lang.Object
public void writeToConfig(org.eclipse.jgit.lib.Config c)