1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19package java.security.cert; 20 21import java.security.PublicKey; 22 23/** 24 * The result of the PKIX certification path builder, returned by 25 * {@link CertPathBuilder#build(CertPathParameters)}. 26 */ 27public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult 28 implements CertPathBuilderResult { 29 // Built and validated certification path 30 private final CertPath certPath; 31 32 /** 33 * Creates a new {@code PKIXCertPathBuilderResult} instance with the 34 * specified validated certification path, the trust anchor of the 35 * certification path, the policy tree and the public key of the subject. 36 * 37 * @param certPath 38 * the validated certification path. 39 * @param trustAnchor 40 * the trust anchor. 41 * @param policyTree 42 * the policy tree (or {@code null} if not used). 43 * @param subjectPublicKey 44 * the public key. 45 * @throws NullPointerException 46 * if the {@code cerPath}, {@code trustAnchor} or {@code 47 * subjectPolicyKey} is {@code null}. 48 */ 49 public PKIXCertPathBuilderResult(CertPath certPath, TrustAnchor trustAnchor, 50 PolicyNode policyTree, PublicKey subjectPublicKey) { 51 super(trustAnchor, policyTree, subjectPublicKey); 52 if (certPath == null) { 53 throw new NullPointerException("certPath == null"); 54 } 55 this.certPath = certPath; 56 } 57 58 /** 59 * Returns the validated certification path. 60 * 61 * @return the validated certification path. 62 */ 63 public CertPath getCertPath() { 64 return certPath; 65 } 66 67 /** 68 * Returns a string representation of this {@code PKIXCertPathBuilderResult} 69 * instance. 70 * 71 * @return a string representation of this {@code PKIXCertPathBuilderResult} 72 * instance. 73 */ 74 public String toString() { 75 StringBuilder sb = new StringBuilder(super.toString()); 76 sb.append("\n Certification Path: "); 77 sb.append(certPath.toString()); 78 sb.append("\n]"); 79 return sb.toString(); 80 } 81} 82