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

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 275      * @throws IOException on error
 276      */
 277     public Integer getReasonCode() throws IOException {
 278         Object obj = getExtension(PKIXExtensions.ReasonCode_Id);
 279         if (obj == null)
 280             return null;
 281         CRLReasonCodeExtension reasonCode = (CRLReasonCodeExtension)obj;
 282         return reasonCode.get(CRLReasonCodeExtension.REASON);
 283     }
 284 
 285     /**
 286      * Returns a printable string of this revoked certificate.
 287      *
 288      * @return value of this revoked certificate in a printable form.
 289      */
 290     @Override
 291     public String toString() {
 292         StringBuilder sb = new StringBuilder();
 293 
 294         sb.append(serialNumber.toString());
 295         sb.append("  On: " + revocationDate.toString());
 296         if (certIssuer != null) {
 297             sb.append("\n    Certificate issuer: " + certIssuer);
 298         }
 299         if (extensions != null) {
 300             Collection<Extension> allEntryExts = extensions.getAllExtensions();
 301             Extension[] exts = allEntryExts.toArray(new Extension[0]);
 302 
 303             sb.append("\n    CRL Entry Extensions: " + exts.length);
 304             for (int i = 0; i < exts.length; i++) {
 305                 sb.append("\n    [" + (i+1) + "]: ");
 306                 Extension ext = exts[i];
 307                 try {
 308                     if (OIDMap.getClass(ext.getExtensionId()) == null) {
 309                         sb.append(ext.toString());
 310                         byte[] extValue = ext.getExtensionValue();
 311                         if (extValue != null) {
 312                             DerOutputStream out = new DerOutputStream();
 313                             out.putOctetString(extValue);
 314                             extValue = out.toByteArray();
 315                             HexDumpEncoder enc = new HexDumpEncoder();
 316                             sb.append("Extension unknown: "
 317                                       + "DER encoded OCTET string =\n"
 318                                       + enc.encodeBuffer(extValue) + "\n");
 319                         }
 320                     } else
 321                         sb.append(ext.toString()); //sub-class exists
 322                 } catch (Exception e) {
 323                     sb.append(", Error parsing this extension");
 324                 }
 325             }
 326         }
 327         sb.append("\n");
 328         return sb.toString();
 329     }
 330 
 331     /**
 332      * Return true if a critical extension is found that is
 333      * not supported, otherwise return false.
 334      */
 335     public boolean hasUnsupportedCriticalExtension() {
 336         if (extensions == null)
 337             return false;
 338         return extensions.hasUnsupportedCriticalExtension();




 275      * @throws IOException on error
 276      */
 277     public Integer getReasonCode() throws IOException {
 278         Object obj = getExtension(PKIXExtensions.ReasonCode_Id);
 279         if (obj == null)
 280             return null;
 281         CRLReasonCodeExtension reasonCode = (CRLReasonCodeExtension)obj;
 282         return reasonCode.get(CRLReasonCodeExtension.REASON);
 283     }
 284 
 285     /**
 286      * Returns a printable string of this revoked certificate.
 287      *
 288      * @return value of this revoked certificate in a printable form.
 289      */
 290     @Override
 291     public String toString() {
 292         StringBuilder sb = new StringBuilder();
 293 
 294         sb.append(serialNumber.toString());
 295         sb.append("  On: ").append(revocationDate);
 296         if (certIssuer != null) {
 297             sb.append("\n    Certificate issuer: ").append(certIssuer);
 298         }
 299         if (extensions != null) {
 300             Collection<Extension> allEntryExts = extensions.getAllExtensions();
 301             Extension[] exts = allEntryExts.toArray(new Extension[0]);
 302 
 303             sb.append("\n    CRL Entry Extensions: ").append(exts.length);
 304             for (int i = 0; i < exts.length; i++) {
 305                 sb.append("\n    [").append(i + 1).append("]: ");
 306                 Extension ext = exts[i];
 307                 try {
 308                     if (OIDMap.getClass(ext.getExtensionId()) == null) {
 309                         sb.append(ext.toString());
 310                         byte[] extValue = ext.getExtensionValue();
 311                         if (extValue != null) {
 312                             DerOutputStream out = new DerOutputStream();
 313                             out.putOctetString(extValue);
 314                             extValue = out.toByteArray();
 315                             HexDumpEncoder enc = new HexDumpEncoder();
 316                             sb.append("Extension unknown: " + "DER encoded OCTET string =\n")
 317                                     .append(enc.encodeBuffer(extValue)).append('\n');

 318                         }
 319                     } else
 320                         sb.append(ext.toString()); //sub-class exists
 321                 } catch (Exception e) {
 322                     sb.append(", Error parsing this extension");
 323                 }
 324             }
 325         }
 326         sb.append("\n");
 327         return sb.toString();
 328     }
 329 
 330     /**
 331      * Return true if a critical extension is found that is
 332      * not supported, otherwise return false.
 333      */
 334     public boolean hasUnsupportedCriticalExtension() {
 335         if (extensions == null)
 336             return false;
 337         return extensions.hasUnsupportedCriticalExtension();