< prev index next >

## src/java.base/share/classes/java/security/Timestamp.java

Print this page

      1 /*
      2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    138     /**
    139      * Returns a string describing this timestamp.
    140      *
    141      * @return A string comprising the date and time of the timestamp and
    142      *         its signer's certificate.
    143      */
    144     public String toString() {
    145         StringBuilder sb = new StringBuilder();
    146         sb.append("(");
    147         sb.append("timestamp: " + timestamp);
    148         List<? extends Certificate> certs = signerCertPath.getCertificates();
    149         if (!certs.isEmpty()) {
    150             sb.append("TSA: " + certs.get(0));
    151         } else {
    152             sb.append("TSA: <empty>");
    153         }
    154         sb.append(")");
    155         return sb.toString();
    156     }
    157
    158     // Explicitly reset hash code value to -1

    159     @java.io.Serial
    160     private void readObject(ObjectInputStream ois)
    161         throws IOException, ClassNotFoundException {
    162         ois.defaultReadObject();
    163         myhash = -1;
    164         timestamp = new Date(timestamp.getTime());
    165     }
    166 }
      1 /*
      2  * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    138     /**
    139      * Returns a string describing this timestamp.
    140      *
    141      * @return A string comprising the date and time of the timestamp and
    142      *         its signer's certificate.
    143      */
    144     public String toString() {
    145         StringBuilder sb = new StringBuilder();
    146         sb.append("(");
    147         sb.append("timestamp: " + timestamp);
    148         List<? extends Certificate> certs = signerCertPath.getCertificates();
    149         if (!certs.isEmpty()) {
    150             sb.append("TSA: " + certs.get(0));
    151         } else {
    152             sb.append("TSA: <empty>");
    153         }
    154         sb.append(")");
    155         return sb.toString();
    156     }
    157
    158     /**
    159      * Restores the state of this object from the stream, and explicitly
    160      * reset hash code value to -1
    161      *
    162      * @param  ois the {@code ObjectInputStream} from which data is read
    163      * @throws IOException if an I/O error occurs
    164      * @throws ClassNotFoundException if a serialized class cannot be loaded
    165      */
    166     @java.io.Serial
    167     private void readObject(ObjectInputStream ois)
    168         throws IOException, ClassNotFoundException {
    169         ois.defaultReadObject();
    170         myhash = -1;
    171         timestamp = new Date(timestamp.getTime());
    172     }
    173 }

< prev index next >