1 /*
2 * Copyright (c) 1997, 2012, 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
468
469 if (this.certs != null && this.certs.length > 0) {
470 for (int i = 0; i < this.certs.length; i++) {
471 sb.append( " " + this.certs[i]);
472 }
473
474 } else if (this.signers != null && this.signers.length > 0) {
475 for (int i = 0; i < this.signers.length; i++) {
476 sb.append( " " + this.signers[i]);
477 }
478 } else {
479 sb.append(" <no signer certificates>");
480 }
481 sb.append(")");
482 return sb.toString();
483 }
484
485 /**
486 * Writes this object out to a stream (i.e., serializes it).
487 *
488 * @serialData An initial <code>URL</code> is followed by an
489 * <code>int</code> indicating the number of certificates to follow
490 * (a value of "zero" denotes that there are no certificates associated
491 * with this object).
492 * Each certificate is written out starting with a <code>String</code>
493 * denoting the certificate type, followed by an
494 * <code>int</code> specifying the length of the certificate encoding,
495 * followed by the certificate encoding itself which is written out as an
496 * array of bytes. Finally, if any code signers are present then the array
497 * of code signers is serialized and written out too.
498 */
499 private void writeObject(java.io.ObjectOutputStream oos)
500 throws IOException
501 {
502 oos.defaultWriteObject(); // location
503
504 // Serialize the array of certs
505 if (certs == null || certs.length == 0) {
506 oos.writeInt(0);
507 } else {
508 // write out the total number of certs
509 oos.writeInt(certs.length);
510 // write out each cert, including its type
511 for (int i = 0; i < certs.length; i++) {
512 java.security.cert.Certificate cert = certs[i];
513 try {
514 oos.writeUTF(cert.getType());
|
1 /*
2 * Copyright (c) 1997, 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
468
469 if (this.certs != null && this.certs.length > 0) {
470 for (int i = 0; i < this.certs.length; i++) {
471 sb.append( " " + this.certs[i]);
472 }
473
474 } else if (this.signers != null && this.signers.length > 0) {
475 for (int i = 0; i < this.signers.length; i++) {
476 sb.append( " " + this.signers[i]);
477 }
478 } else {
479 sb.append(" <no signer certificates>");
480 }
481 sb.append(")");
482 return sb.toString();
483 }
484
485 /**
486 * Writes this object out to a stream (i.e., serializes it).
487 *
488 * @serialData An initial {@code URL} is followed by an
489 * {@code int} indicating the number of certificates to follow
490 * (a value of "zero" denotes that there are no certificates associated
491 * with this object).
492 * Each certificate is written out starting with a {@code String}
493 * denoting the certificate type, followed by an
494 * {@code int} specifying the length of the certificate encoding,
495 * followed by the certificate encoding itself which is written out as an
496 * array of bytes. Finally, if any code signers are present then the array
497 * of code signers is serialized and written out too.
498 */
499 private void writeObject(java.io.ObjectOutputStream oos)
500 throws IOException
501 {
502 oos.defaultWriteObject(); // location
503
504 // Serialize the array of certs
505 if (certs == null || certs.length == 0) {
506 oos.writeInt(0);
507 } else {
508 // write out the total number of certs
509 oos.writeInt(certs.length);
510 // write out each cert, including its type
511 for (int i = 0; i < certs.length; i++) {
512 java.security.cert.Certificate cert = certs[i];
513 try {
514 oos.writeUTF(cert.getType());
|