Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68612bae authored by Brian Carlstrom's avatar Brian Carlstrom Committed by Android (Google) Code Review
Browse files

Merge "SslCertificate should clone Dates"

parents 6b1806b2 a5987a51
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -128,8 +128,8 @@ public class SslCertificate {
            String issuedTo, String issuedBy, Date validNotBefore, Date validNotAfter) {
        mIssuedTo = new DName(issuedTo);
        mIssuedBy = new DName(issuedBy);
        mValidNotBefore = validNotBefore;
        mValidNotAfter = validNotAfter;
        mValidNotBefore = cloneDate(validNotBefore);
        mValidNotAfter  = cloneDate(validNotAfter);
    }

    /**
@@ -148,7 +148,7 @@ public class SslCertificate {
     * "" if none has been set
     */
    public Date getValidNotBeforeDate() {
        return mValidNotBefore;
        return cloneDate(mValidNotBefore);
    }

    /**
@@ -166,7 +166,7 @@ public class SslCertificate {
     * "" if none has been set
     */
    public Date getValidNotAfterDate() {
        return mValidNotAfter;
        return cloneDate(mValidNotAfter);
    }

    /**
@@ -223,6 +223,16 @@ public class SslCertificate {
        return new SimpleDateFormat(ISO_8601_DATE_FORMAT).format(date);
    }

    /**
     * Clone a possibly null Date
     */
    private static Date cloneDate(Date date) {
        if (date == null) {
            return null;
        }
        return (Date) date.clone();
    }

    /**
     * A distinguished name helper class: a 3-tuple of:
     * - common name (CN),