< prev index next >

src/java.base/share/classes/sun/security/x509/AVA.java

Print this page
rev 16194 : imported patch XXXXXXX-Use-StringBuilder-appendN-method


 436                     }
 437                 }
 438             } else {
 439                 // check if character should have been escaped
 440                 if (format == RFC2253) {
 441                     if (specialChars2253.indexOf((char)c) != -1) {
 442                         throw new IOException
 443                                 ("Character '" + (char)c +
 444                                  "' in AVA appears without escape");
 445                     }
 446                 } else if (escapedDefault.indexOf((char)c) != -1) {
 447                     throw new IOException
 448                             ("Character '" + (char)c +
 449                             "' in AVA appears without escape");
 450                 }
 451             }
 452 
 453             // add embedded hex bytes before next char
 454             if (embeddedHex.size() > 0) {
 455                 // add space(s) before embedded hex bytes
 456                 for (int i = 0; i < spaceCount; i++) {
 457                     temp.append(' ');
 458                 }
 459                 spaceCount = 0;
 460 
 461                 String hexString = getEmbeddedHexString(embeddedHex);
 462                 temp.append(hexString);
 463                 embeddedHex.clear();
 464             }
 465 
 466             // check for non-PrintableString chars
 467             isPrintableString &= DerValue.isPrintableStringChar((char)c);
 468             if (c == ' ' && escape == false) {
 469                 // do not add non-escaped spaces yet
 470                 // (non-escaped trailing spaces are ignored)
 471                 spaceCount++;
 472             } else {
 473                 // add space(s)
 474                 for (int i = 0; i < spaceCount; i++) {
 475                     temp.append(' ');
 476                 }
 477                 spaceCount = 0;
 478                 temp.append((char)c);
 479             }
 480             c = in.read();
 481             leadingChar = false;
 482         } while (isTerminator(c, format) == false);
 483 
 484         if (format == RFC2253 && spaceCount > 0) {
 485             throw new IOException("Incorrect AVA RFC2253 format - " +
 486                                         "trailing space must be escaped");
 487         }
 488 
 489         // add trailing embedded hex bytes
 490         if (embeddedHex.size() > 0) {
 491             String hexString = getEmbeddedHexString(embeddedHex);
 492             temp.append(hexString);
 493             embeddedHex.clear();
 494         }
 495 
 496         // encode as PrintableString unless value contains




 436                     }
 437                 }
 438             } else {
 439                 // check if character should have been escaped
 440                 if (format == RFC2253) {
 441                     if (specialChars2253.indexOf((char)c) != -1) {
 442                         throw new IOException
 443                                 ("Character '" + (char)c +
 444                                  "' in AVA appears without escape");
 445                     }
 446                 } else if (escapedDefault.indexOf((char)c) != -1) {
 447                     throw new IOException
 448                             ("Character '" + (char)c +
 449                             "' in AVA appears without escape");
 450                 }
 451             }
 452 
 453             // add embedded hex bytes before next char
 454             if (embeddedHex.size() > 0) {
 455                 // add space(s) before embedded hex bytes
 456                 temp.appendN(' ', spaceCount);


 457                 spaceCount = 0;
 458 
 459                 String hexString = getEmbeddedHexString(embeddedHex);
 460                 temp.append(hexString);
 461                 embeddedHex.clear();
 462             }
 463 
 464             // check for non-PrintableString chars
 465             isPrintableString &= DerValue.isPrintableStringChar((char)c);
 466             if (c == ' ' && escape == false) {
 467                 // do not add non-escaped spaces yet
 468                 // (non-escaped trailing spaces are ignored)
 469                 spaceCount++;
 470             } else {
 471                 // add space(s)
 472                 temp.appendN(' ', spaceCount);


 473                 spaceCount = 0;
 474                 temp.append((char)c);
 475             }
 476             c = in.read();
 477             leadingChar = false;
 478         } while (isTerminator(c, format) == false);
 479 
 480         if (format == RFC2253 && spaceCount > 0) {
 481             throw new IOException("Incorrect AVA RFC2253 format - " +
 482                                         "trailing space must be escaped");
 483         }
 484 
 485         // add trailing embedded hex bytes
 486         if (embeddedHex.size() > 0) {
 487             String hexString = getEmbeddedHexString(embeddedHex);
 488             temp.append(hexString);
 489             embeddedHex.clear();
 490         }
 491 
 492         // encode as PrintableString unless value contains


< prev index next >