Class PushCertificateIdent


  • public class PushCertificateIdent
    extends java.lang.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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String raw  
      private int tzOffset  
      private java.lang.String userId  
      private long when  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PushCertificateIdent​(java.lang.String userId, long when, int tzOffset)
      Construct a new identity from an OpenPGP User ID.
      private PushCertificateIdent​(java.lang.String raw, java.lang.String userId, long when, int tzOffset)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      java.lang.String getEmailAddress()
      Get the email portion of the User ID
      java.lang.String getName()
      Get the name portion of the User ID.
      java.lang.String getRaw()
      Get the raw string from which this identity was parsed.
      java.util.TimeZone getTimeZone()
      Get this person's declared time zone
      int getTimeZoneOffset()
      Get this person's declared time zone as minutes east of UTC.
      java.lang.String getUserId()
      Get the OpenPGP User ID, which may be any string.
      java.util.Date getWhen()
      Get the timestamp of the identity.
      int hashCode()
      static PushCertificateIdent parse​(java.lang.String str)
      Parse an identity from a string.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • raw

        private final java.lang.String raw
      • userId

        private final java.lang.String userId
      • when

        private final long when
      • tzOffset

        private final int tzOffset
    • Constructor Detail

      • PushCertificateIdent

        public PushCertificateIdent​(java.lang.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().
      • PushCertificateIdent

        private PushCertificateIdent​(java.lang.String raw,
                                     java.lang.String userId,
                                     long when,
                                     int tzOffset)
    • Method Detail

      • parse

        public static PushCertificateIdent parse​(java.lang.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 java.lang.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 java.lang.String getUserId()
        Get the OpenPGP User ID, which may be any string.
        Returns:
        the OpenPGP User ID, which may be any string.
      • getName

        public java.lang.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 java.lang.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 java.util.Date getWhen()
        Get the timestamp of the identity.
        Returns:
        the timestamp of the identity.
      • getTimeZone

        public java.util.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.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object