1 /*
2 * Copyright (c) 2003, 2011, 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
46 * @serial
47 */
48 private CertPath signerCertPath;
49
50 /*
51 * The signature timestamp.
52 *
53 * @serial
54 */
55 private Timestamp timestamp;
56
57 /*
58 * Hash code for this code signer.
59 */
60 private transient int myhash = -1;
61
62 /**
63 * Constructs a CodeSigner object.
64 *
65 * @param signerCertPath The signer's certificate path.
66 * It must not be <code>null</code>.
67 * @param timestamp A signature timestamp.
68 * If <code>null</code> then no timestamp was generated
69 * for the signature.
70 * @throws NullPointerException if <code>signerCertPath</code> is
71 * <code>null</code>.
72 */
73 public CodeSigner(CertPath signerCertPath, Timestamp timestamp) {
74 if (signerCertPath == null) {
75 throw new NullPointerException();
76 }
77 this.signerCertPath = signerCertPath;
78 this.timestamp = timestamp;
79 }
80
81 /**
82 * Returns the signer's certificate path.
83 *
84 * @return A certificate path.
85 */
86 public CertPath getSignerCertPath() {
87 return signerCertPath;
88 }
89
90 /**
91 * Returns the signature timestamp.
92 *
93 * @return The timestamp or <code>null</code> if none is present.
94 */
95 public Timestamp getTimestamp() {
96 return timestamp;
97 }
98
99 /**
100 * Returns the hash code value for this code signer.
101 * The hash code is generated using the signer's certificate path and the
102 * timestamp, if present.
103 *
104 * @return a hash code value for this code signer.
105 */
106 public int hashCode() {
107 if (myhash == -1) {
108 if (timestamp == null) {
109 myhash = signerCertPath.hashCode();
110 } else {
111 myhash = signerCertPath.hashCode() + timestamp.hashCode();
112 }
113 }
|
1 /*
2 * Copyright (c) 2003, 2013, 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
46 * @serial
47 */
48 private CertPath signerCertPath;
49
50 /*
51 * The signature timestamp.
52 *
53 * @serial
54 */
55 private Timestamp timestamp;
56
57 /*
58 * Hash code for this code signer.
59 */
60 private transient int myhash = -1;
61
62 /**
63 * Constructs a CodeSigner object.
64 *
65 * @param signerCertPath The signer's certificate path.
66 * It must not be {@code null}.
67 * @param timestamp A signature timestamp.
68 * If {@code null} then no timestamp was generated
69 * for the signature.
70 * @throws NullPointerException if {@code signerCertPath} is
71 * {@code null}.
72 */
73 public CodeSigner(CertPath signerCertPath, Timestamp timestamp) {
74 if (signerCertPath == null) {
75 throw new NullPointerException();
76 }
77 this.signerCertPath = signerCertPath;
78 this.timestamp = timestamp;
79 }
80
81 /**
82 * Returns the signer's certificate path.
83 *
84 * @return A certificate path.
85 */
86 public CertPath getSignerCertPath() {
87 return signerCertPath;
88 }
89
90 /**
91 * Returns the signature timestamp.
92 *
93 * @return The timestamp or {@code null} if none is present.
94 */
95 public Timestamp getTimestamp() {
96 return timestamp;
97 }
98
99 /**
100 * Returns the hash code value for this code signer.
101 * The hash code is generated using the signer's certificate path and the
102 * timestamp, if present.
103 *
104 * @return a hash code value for this code signer.
105 */
106 public int hashCode() {
107 if (myhash == -1) {
108 if (timestamp == null) {
109 myhash = signerCertPath.hashCode();
110 } else {
111 myhash = signerCertPath.hashCode() + timestamp.hashCode();
112 }
113 }
|