526 oos.writeObject(signers);
527 }
528 }
529
530 /**
531 * Restores this object from a stream (i.e., deserializes it).
532 */
533 private void readObject(java.io.ObjectInputStream ois)
534 throws IOException, ClassNotFoundException
535 {
536 CertificateFactory cf;
537 Hashtable<String, CertificateFactory> cfs = null;
538
539 ois.defaultReadObject(); // location
540
541 // process any new-style certs in the stream (if present)
542 int size = ois.readInt();
543 if (size > 0) {
544 // we know of 3 different cert types: X.509, PGP, SDSI, which
545 // could all be present in the stream at the same time
546 cfs = new Hashtable<String, CertificateFactory>(3);
547 this.certs = new java.security.cert.Certificate[size];
548 }
549
550 for (int i = 0; i < size; i++) {
551 // read the certificate type, and instantiate a certificate
552 // factory of that type (reuse existing factory if possible)
553 String certType = ois.readUTF();
554 if (cfs.containsKey(certType)) {
555 // reuse certificate factory
556 cf = cfs.get(certType);
557 } else {
558 // create new certificate factory
559 try {
560 cf = CertificateFactory.getInstance(certType);
561 } catch (CertificateException ce) {
562 throw new ClassNotFoundException
563 ("Certificate factory for " + certType + " not found");
564 }
565 // store the certificate factory so we can reuse it later
566 cfs.put(certType, cf);
|
526 oos.writeObject(signers);
527 }
528 }
529
530 /**
531 * Restores this object from a stream (i.e., deserializes it).
532 */
533 private void readObject(java.io.ObjectInputStream ois)
534 throws IOException, ClassNotFoundException
535 {
536 CertificateFactory cf;
537 Hashtable<String, CertificateFactory> cfs = null;
538
539 ois.defaultReadObject(); // location
540
541 // process any new-style certs in the stream (if present)
542 int size = ois.readInt();
543 if (size > 0) {
544 // we know of 3 different cert types: X.509, PGP, SDSI, which
545 // could all be present in the stream at the same time
546 cfs = new Hashtable<>(3);
547 this.certs = new java.security.cert.Certificate[size];
548 }
549
550 for (int i = 0; i < size; i++) {
551 // read the certificate type, and instantiate a certificate
552 // factory of that type (reuse existing factory if possible)
553 String certType = ois.readUTF();
554 if (cfs.containsKey(certType)) {
555 // reuse certificate factory
556 cf = cfs.get(certType);
557 } else {
558 // create new certificate factory
559 try {
560 cf = CertificateFactory.getInstance(certType);
561 } catch (CertificateException ce) {
562 throw new ClassNotFoundException
563 ("Certificate factory for " + certType + " not found");
564 }
565 // store the certificate factory so we can reuse it later
566 cfs.put(certType, cf);
|