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 23import org.apache.harmony.security.internal.nls.Messages; 24 25/** 26 * The result of the PKIX certification path builder, returned by 27 * {@link CertPathBuilder#build(CertPathParameters)}. 28 */ 29public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult 30 implements CertPathBuilderResult { 31 // Built and validated certification path 32 private final CertPath certPath; 33 34 /** 35 * Creates a new {@code PKIXCertPathBuilderResult} instance with the 36 * specified validated certification path, the trust anchor of the 37 * certification path, the policy tree and the public key of the subject. 38 * 39 * @param certPath 40 * the validated certification path. 41 * @param trustAnchor 42 * the trust anchor. 43 * @param policyTree 44 * the policy tree (or {@code null} if not used). 45 * @param subjectPublicKey 46 * the public key. 47 * @throws NullPointerException 48 * if the {@code cerPath}, {@code trustAnchor} or {@code 49 * subjectPolicyKey} is {@code null}. 50 */ 51 public PKIXCertPathBuilderResult(CertPath certPath, TrustAnchor trustAnchor, 52 PolicyNode policyTree, PublicKey subjectPublicKey) { 53 super(trustAnchor, policyTree, subjectPublicKey); 54 this.certPath = certPath; 55 if (this.certPath == null) { 56 throw new NullPointerException(Messages.getString("security.55")); //$NON-NLS-1$ 57 } 58 } 59 60 /** 61 * Returns the validated certification path. 62 * 63 * @return the validated certification path. 64 */ 65 public CertPath getCertPath() { 66 return certPath; 67 } 68 69 /** 70 * Returns a string representation of this {@code PKIXCertPathBuilderResult} 71 * instance. 72 * 73 * @return a string representation of this {@code PKIXCertPathBuilderResult} 74 * instance. 75 */ 76 public String toString() { 77 StringBuilder sb = new StringBuilder(super.toString()); 78 sb.append("\n Certification Path: "); //$NON-NLS-1$ 79 sb.append(certPath.toString()); 80 sb.append("\n]"); //$NON-NLS-1$ 81 return sb.toString(); 82 } 83} 84