Class 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(), but getEmailAddress() 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 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; see getTimeZoneOffset().
    • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object