< prev index next >

test/jdk/sun/security/pkcs11/PKCS11Test.java

Print this page
rev 51031 : 8207766: [testbug] Adapt tests for Aix.


 392     // Try to parse the version for the specified library.
 393     // Assuming the library contains either of the following patterns:
 394     // $Header: NSS <version>
 395     // Version: NSS <version>
 396     // Here, <version> stands for NSS version.
 397     static double getNSSInfo(String library) {
 398         // look for two types of headers in NSS libraries
 399         String nssHeader1 = "$Header: NSS";
 400         String nssHeader2 = "Version: NSS";
 401         boolean found = false;
 402         String s = null;
 403         int i = 0;
 404         String libfile = "";
 405 
 406         if (library.compareTo("softokn3") == 0 && softoken3_version > -1)
 407             return softoken3_version;
 408         if (library.compareTo("nss3") == 0 && nss3_version > -1)
 409             return nss3_version;
 410 
 411         try {
 412             libfile = getNSSLibDir() + System.mapLibraryName(library);




 413             try (FileInputStream is = new FileInputStream(libfile)) {
 414                 byte[] data = new byte[1000];
 415                 int read = 0;
 416 
 417                 while (is.available() > 0) {
 418                     if (read == 0) {
 419                         read = is.read(data, 0, 1000);
 420                     } else {
 421                         // Prepend last 100 bytes in case the header was split
 422                         // between the reads.
 423                         System.arraycopy(data, 900, data, 0, 100);
 424                         read = 100 + is.read(data, 100, 900);
 425                     }
 426 
 427                     s = new String(data, 0, read, StandardCharsets.US_ASCII);
 428                     i = s.indexOf(nssHeader1);
 429                     if (i > 0 || (i = s.indexOf(nssHeader2)) > 0) {
 430                         found = true;
 431                         // If the nssHeader is before 920 we can break, otherwise
 432                         // we may not have the whole header so do another read.  If




 392     // Try to parse the version for the specified library.
 393     // Assuming the library contains either of the following patterns:
 394     // $Header: NSS <version>
 395     // Version: NSS <version>
 396     // Here, <version> stands for NSS version.
 397     static double getNSSInfo(String library) {
 398         // look for two types of headers in NSS libraries
 399         String nssHeader1 = "$Header: NSS";
 400         String nssHeader2 = "Version: NSS";
 401         boolean found = false;
 402         String s = null;
 403         int i = 0;
 404         String libfile = "";
 405 
 406         if (library.compareTo("softokn3") == 0 && softoken3_version > -1)
 407             return softoken3_version;
 408         if (library.compareTo("nss3") == 0 && nss3_version > -1)
 409             return nss3_version;
 410 
 411         try {
 412             String libdir = getNSSLibDir();
 413             if (libdir == null) {
 414                 return 0.0;
 415             }
 416             libfile = libdir + System.mapLibraryName(library);
 417             try (FileInputStream is = new FileInputStream(libfile)) {
 418                 byte[] data = new byte[1000];
 419                 int read = 0;
 420 
 421                 while (is.available() > 0) {
 422                     if (read == 0) {
 423                         read = is.read(data, 0, 1000);
 424                     } else {
 425                         // Prepend last 100 bytes in case the header was split
 426                         // between the reads.
 427                         System.arraycopy(data, 900, data, 0, 100);
 428                         read = 100 + is.read(data, 100, 900);
 429                     }
 430 
 431                     s = new String(data, 0, read, StandardCharsets.US_ASCII);
 432                     i = s.indexOf(nssHeader1);
 433                     if (i > 0 || (i = s.indexOf(nssHeader2)) > 0) {
 434                         found = true;
 435                         // If the nssHeader is before 920 we can break, otherwise
 436                         // we may not have the whole header so do another read.  If


< prev index next >