694
695 try {
696 // Body format: see store method
697
698 int xMagic = dis.readInt();
699 int xVersion = dis.readInt();
700
701 // Accept the following keystore implementations:
702 // - JCEKS (this implementation), versions 1 and 2
703 // - JKS (Sun's keystore implementation in JDK 1.2),
704 // versions 1 and 2
705 if (((xMagic != JCEKS_MAGIC) && (xMagic != JKS_MAGIC)) ||
706 ((xVersion != VERSION_1) && (xVersion != VERSION_2))) {
707 throw new IOException("Invalid keystore format");
708 }
709
710 if (xVersion == VERSION_1) {
711 cf = CertificateFactory.getInstance("X509");
712 } else {
713 // version 2
714 cfs = new Hashtable<String, CertificateFactory>(3);
715 }
716
717 entries.clear();
718 int count = dis.readInt();
719
720 for (int i = 0; i < count; i++) {
721 int tag;
722 String alias;
723
724 tag = dis.readInt();
725
726 if (tag == 1) { // private-key entry
727
728 PrivateKeyEntry entry = new PrivateKeyEntry();
729
730 // read the alias
731 alias = dis.readUTF();
732
733 // read the (entry creation) date
734 entry.date = new Date(dis.readLong());
|
694
695 try {
696 // Body format: see store method
697
698 int xMagic = dis.readInt();
699 int xVersion = dis.readInt();
700
701 // Accept the following keystore implementations:
702 // - JCEKS (this implementation), versions 1 and 2
703 // - JKS (Sun's keystore implementation in JDK 1.2),
704 // versions 1 and 2
705 if (((xMagic != JCEKS_MAGIC) && (xMagic != JKS_MAGIC)) ||
706 ((xVersion != VERSION_1) && (xVersion != VERSION_2))) {
707 throw new IOException("Invalid keystore format");
708 }
709
710 if (xVersion == VERSION_1) {
711 cf = CertificateFactory.getInstance("X509");
712 } else {
713 // version 2
714 cfs = new Hashtable<>(3);
715 }
716
717 entries.clear();
718 int count = dis.readInt();
719
720 for (int i = 0; i < count; i++) {
721 int tag;
722 String alias;
723
724 tag = dis.readInt();
725
726 if (tag == 1) { // private-key entry
727
728 PrivateKeyEntry entry = new PrivateKeyEntry();
729
730 // read the alias
731 alias = dis.readUTF();
732
733 // read the (entry creation) date
734 entry.date = new Date(dis.readLong());
|