src/java.base/share/classes/java/security/cert/TrustAnchor.java

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


 303      * Note that the byte array returned is cloned to protect against
 304      * subsequent modifications.
 305      *
 306      * @return a byte array containing the ASN.1 DER encoding of
 307      *         a NameConstraints extension used for checking name constraints,
 308      *         or {@code null} if not set.
 309      */
 310     public final byte [] getNameConstraints() {
 311         return ncBytes == null ? null : ncBytes.clone();
 312     }
 313 
 314     /**
 315      * Returns a formatted string describing the {@code TrustAnchor}.
 316      *
 317      * @return a formatted string describing the {@code TrustAnchor}
 318      */
 319     public String toString() {
 320         StringBuilder sb = new StringBuilder();
 321         sb.append("[\n");
 322         if (pubKey != null) {
 323             sb.append("  Trusted CA Public Key: " + pubKey.toString() + "\n");
 324             sb.append("  Trusted CA Issuer Name: "
 325                 + String.valueOf(caName) + "\n");

 326         } else {
 327             sb.append("  Trusted CA cert: " + trustedCert.toString() + "\n");





 328         }
 329         if (nc != null)
 330             sb.append("  Name Constraints: " + nc.toString() + "\n");
 331         return sb.toString();
 332     }
 333 }


 303      * Note that the byte array returned is cloned to protect against
 304      * subsequent modifications.
 305      *
 306      * @return a byte array containing the ASN.1 DER encoding of
 307      *         a NameConstraints extension used for checking name constraints,
 308      *         or {@code null} if not set.
 309      */
 310     public final byte [] getNameConstraints() {
 311         return ncBytes == null ? null : ncBytes.clone();
 312     }
 313 
 314     /**
 315      * Returns a formatted string describing the {@code TrustAnchor}.
 316      *
 317      * @return a formatted string describing the {@code TrustAnchor}
 318      */
 319     public String toString() {
 320         StringBuilder sb = new StringBuilder();
 321         sb.append("[\n");
 322         if (pubKey != null) {
 323             sb.append("  Trusted CA Public Key: ").append(pubKey)
 324                     .append('\n');
 325             sb.append("  Trusted CA Issuer Name: ")
 326                     .append(caName).append('\n');
 327         } else {
 328             sb.append("  Trusted CA cert: ").append(trustedCert)
 329                     .append('\n');
 330         }
 331         if (nc != null) {
 332             sb.append("  Name Constraints: ").append(nc)
 333                     .append('\n');
 334         }


 335         return sb.toString();
 336     }
 337 }