001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Vladimir N. Molotkov
020: * @version $Revision$
021: */package java.security.cert;
022:
023: import java.security.PublicKey;
024:
025: import org.apache.harmony.security.internal.nls.Messages;
026:
027: /**
028: * @com.intel.drl.spec_ref
029: *
030: */
031: public class PKIXCertPathValidatorResult implements
032: CertPathValidatorResult {
033: // A trust anchor used during validation of certification path
034: private final TrustAnchor trustAnchor;
035: // Valid policy tree resulting from PKIX
036: // certification path validation algorithm
037: private final PolicyNode policyTree;
038: // Public key of the subject (target) certificate
039: private final PublicKey subjectPublicKey;
040:
041: /**
042: * @com.intel.drl.spec_ref
043: */
044: public PKIXCertPathValidatorResult(TrustAnchor trustAnchor,
045: PolicyNode policyTree, PublicKey subjectPublicKey) {
046: this .trustAnchor = trustAnchor;
047: this .policyTree = policyTree;
048: this .subjectPublicKey = subjectPublicKey;
049: if (this .trustAnchor == null) {
050: throw new NullPointerException(Messages
051: .getString("security.64")); //$NON-NLS-1$
052: }
053: if (this .subjectPublicKey == null) {
054: throw new NullPointerException(Messages
055: .getString("security.65")); //$NON-NLS-1$
056: }
057: }
058:
059: /**
060: * @com.intel.drl.spec_ref
061: */
062: public PolicyNode getPolicyTree() {
063: return policyTree;
064: }
065:
066: /**
067: * @com.intel.drl.spec_ref
068: */
069: public PublicKey getPublicKey() {
070: return subjectPublicKey;
071: }
072:
073: /**
074: * @com.intel.drl.spec_ref
075: */
076: public TrustAnchor getTrustAnchor() {
077: return trustAnchor;
078: }
079:
080: /**
081: * @com.intel.drl.spec_ref
082: */
083: public Object clone() {
084: try {
085: return super .clone();
086: } catch (CloneNotSupportedException e) {
087: // Actually, the exception will not be thrown out.
088: throw new Error(e);
089: }
090: }
091:
092: /**
093: * @com.intel.drl.spec_ref
094: */
095: public String toString() {
096: StringBuffer sb = new StringBuffer(super .toString());
097: sb.append(": [\n Trust Anchor: "); //$NON-NLS-1$
098: sb.append(trustAnchor.toString());
099: sb.append("\n Policy Tree: "); //$NON-NLS-1$
100: sb.append(policyTree == null ? "no valid policy tree\n" //$NON-NLS-1$
101: : policyTree.toString());
102: sb.append("\n Subject Public Key: "); //$NON-NLS-1$
103: sb.append(subjectPublicKey.toString());
104: sb.append("\n]"); //$NON-NLS-1$
105: return sb.toString();
106: }
107: }
|