< prev index next >

src/java.base/share/classes/java/security/UnresolvedPermission.java

Print this page




 543 
 544     /**
 545      * Restores this object from a stream (i.e., deserializes it).
 546      */
 547     private void readObject(java.io.ObjectInputStream ois)
 548         throws IOException, ClassNotFoundException
 549     {
 550         CertificateFactory cf;
 551         Hashtable<String, CertificateFactory> cfs = null;
 552 
 553         ois.defaultReadObject();
 554 
 555         if (type == null)
 556                 throw new NullPointerException("type can't be null");
 557 
 558         // process any new-style certs in the stream (if present)
 559         int size = ois.readInt();
 560         if (size > 0) {
 561             // we know of 3 different cert types: X.509, PGP, SDSI, which
 562             // could all be present in the stream at the same time
 563             cfs = new Hashtable<String, CertificateFactory>(3);
 564             this.certs = new java.security.cert.Certificate[size];
 565         }
 566 
 567         for (int i=0; i<size; i++) {
 568             // read the certificate type, and instantiate a certificate
 569             // factory of that type (reuse existing factory if possible)
 570             String certType = ois.readUTF();
 571             if (cfs.containsKey(certType)) {
 572                 // reuse certificate factory
 573                 cf = cfs.get(certType);
 574             } else {
 575                 // create new certificate factory
 576                 try {
 577                     cf = CertificateFactory.getInstance(certType);
 578                 } catch (CertificateException ce) {
 579                     throw new ClassNotFoundException
 580                         ("Certificate factory for "+certType+" not found");
 581                 }
 582                 // store the certificate factory so we can reuse it later
 583                 cfs.put(certType, cf);


 543 
 544     /**
 545      * Restores this object from a stream (i.e., deserializes it).
 546      */
 547     private void readObject(java.io.ObjectInputStream ois)
 548         throws IOException, ClassNotFoundException
 549     {
 550         CertificateFactory cf;
 551         Hashtable<String, CertificateFactory> cfs = null;
 552 
 553         ois.defaultReadObject();
 554 
 555         if (type == null)
 556                 throw new NullPointerException("type can't be null");
 557 
 558         // process any new-style certs in the stream (if present)
 559         int size = ois.readInt();
 560         if (size > 0) {
 561             // we know of 3 different cert types: X.509, PGP, SDSI, which
 562             // could all be present in the stream at the same time
 563             cfs = new Hashtable<>(3);
 564             this.certs = new java.security.cert.Certificate[size];
 565         }
 566 
 567         for (int i=0; i<size; i++) {
 568             // read the certificate type, and instantiate a certificate
 569             // factory of that type (reuse existing factory if possible)
 570             String certType = ois.readUTF();
 571             if (cfs.containsKey(certType)) {
 572                 // reuse certificate factory
 573                 cf = cfs.get(certType);
 574             } else {
 575                 // create new certificate factory
 576                 try {
 577                     cf = CertificateFactory.getInstance(certType);
 578                 } catch (CertificateException ce) {
 579                     throw new ClassNotFoundException
 580                         ("Certificate factory for "+certType+" not found");
 581                 }
 582                 // store the certificate factory so we can reuse it later
 583                 cfs.put(certType, cf);
< prev index next >