Package org.eclipse.jgit.transport
Class PushCertificateIdent
- java.lang.Object
-
- org.eclipse.jgit.transport.PushCertificateIdent
-
public class PushCertificateIdent extends Object
Identity in a push certificate.This is similar to a
PersonIdent
in that it contains a name, timestamp, and timezone offset, but differs in the following ways:- It is always parsed from a UTF-8 string, rather than a raw commit buffer.
- It is not guaranteed to contain a name and email portion, since any UTF-8
string is a valid OpenPGP User ID (RFC4880 5.1.1). The raw User ID is always
available as
getUserId()
, butgetEmailAddress()
may return null. - The raw text from which the identity was parsed is available with
getRaw()
. This is necessary for losslessly reconstructing the signed push certificate payload.
- Since:
- 4.1
-
-
Constructor Summary
Constructors Constructor Description PushCertificateIdent(String userId, long when, int tzOffset)
Construct a new identity from an OpenPGP User ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getEmailAddress()
Get the email portion of the User IDString
getName()
Get the name portion of the User ID.String
getRaw()
Get the raw string from which this identity was parsed.TimeZone
getTimeZone()
Get this person's declared time zoneint
getTimeZoneOffset()
Get this person's declared time zone as minutes east of UTC.String
getUserId()
Get the OpenPGP User ID, which may be any string.Date
getWhen()
Get the timestamp of the identity.int
hashCode()
static PushCertificateIdent
parse(String str)
Parse an identity from a string.String
toString()
-
-
-
Constructor Detail
-
PushCertificateIdent
public PushCertificateIdent(String userId, long when, int tzOffset)
Construct a new identity from an OpenPGP User ID.- Parameters:
userId
- OpenPGP User ID; any UTF-8 string.when
- local time.tzOffset
- timezone offset; seegetTimeZoneOffset()
.
-
-
Method Detail
-
parse
public static PushCertificateIdent parse(String str)
Parse an identity from a string.Spaces are trimmed when parsing the timestamp and timezone offset, with one exception. The timestamp must be preceded by a single space, and the rest of the string prior to that space (including any additional whitespace) is treated as the OpenPGP User ID.
If either the timestamp or timezone offsets are missing, mimics
RawParseUtils.parsePersonIdent(String)
behavior and sets them both to zero.- Parameters:
str
- string to parse.- Returns:
- a
PushCertificateIdent
object.
-
getRaw
public String getRaw()
Get the raw string from which this identity was parsed.If the string was constructed manually, a suitable canonical string is returned.
For the purposes of bytewise comparisons with other OpenPGP IDs, the string must be encoded as UTF-8.
- Returns:
- the raw string.
-
getUserId
public String getUserId()
Get the OpenPGP User ID, which may be any string.- Returns:
- the OpenPGP User ID, which may be any string.
-
getName
public String getName()
Get the name portion of the User ID.- Returns:
- the name portion of the User ID. If no email address would be
parsed by
getEmailAddress()
, returns the full User ID with spaces trimmed.
-
getEmailAddress
public String getEmailAddress()
Get the email portion of the User ID- Returns:
- the email portion of the User ID, if one was successfully parsed
from
getUserId()
, or null.
-
getWhen
public Date getWhen()
Get the timestamp of the identity.- Returns:
- the timestamp of the identity.
-
getTimeZone
public TimeZone getTimeZone()
Get this person's declared time zone- Returns:
- this person's declared time zone; null if the timezone is unknown.
-
getTimeZoneOffset
public int getTimeZoneOffset()
Get this person's declared time zone as minutes east of UTC.- Returns:
- this person's declared time zone as minutes east of UTC. If the timezone is to the west of UTC it is negative.
-
-