OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.net; |
| 6 |
| 7 import org.chromium.base.CalledByNative; |
| 8 import org.chromium.base.JNINamespace; |
| 9 |
| 10 import java.security.cert.CertificateEncodingException; |
| 11 import java.security.cert.X509Certificate; |
| 12 import java.util.ArrayList; |
| 13 import java.util.Collections; |
| 14 import java.util.List; |
| 15 |
| 16 /** |
| 17 * The result of a certification verification. |
| 18 */ |
| 19 @JNINamespace("net::android") |
| 20 public class AndroidCertVerifyResult { |
| 21 |
| 22 /** |
| 23 * The verification status. One of the values in CertVerifyStatusAndroid. |
| 24 */ |
| 25 private final int mStatus; |
| 26 |
| 27 /** |
| 28 * True if the root CA in the chain is in the system store. |
| 29 */ |
| 30 private final boolean mIsIssuedByKnownRoot; |
| 31 |
| 32 /** |
| 33 * The properly ordered certificate chain used for verification. |
| 34 */ |
| 35 private final List<X509Certificate> mCertificateChain; |
| 36 |
| 37 public AndroidCertVerifyResult(int status, |
| 38 boolean isIssuedByKnownRoot, |
| 39 List<X509Certificate> certificateChain) { |
| 40 mStatus = status; |
| 41 mIsIssuedByKnownRoot = isIssuedByKnownRoot; |
| 42 mCertificateChain = new ArrayList<X509Certificate>(certificateChain); |
| 43 } |
| 44 |
| 45 public AndroidCertVerifyResult(int status) { |
| 46 mStatus = status; |
| 47 mIsIssuedByKnownRoot = false; |
| 48 mCertificateChain = Collections.<X509Certificate>emptyList(); |
| 49 } |
| 50 |
| 51 @CalledByNative |
| 52 public int getStatus() { |
| 53 return mStatus; |
| 54 } |
| 55 |
| 56 @CalledByNative |
| 57 public boolean isIssuedByKnownRoot() { |
| 58 return mIsIssuedByKnownRoot; |
| 59 } |
| 60 |
| 61 @CalledByNative |
| 62 public byte[][] getCertificateChainEncoded() { |
| 63 byte[][] verifiedChainArray = new byte[mCertificateChain.size()][]; |
| 64 try { |
| 65 for (int i = 0; i < mCertificateChain.size(); i++) { |
| 66 verifiedChainArray[i] = mCertificateChain.get(i).getEncoded(); |
| 67 } |
| 68 } catch (CertificateEncodingException e) { |
| 69 return new byte[0][]; |
| 70 } |
| 71 return verifiedChainArray; |
| 72 } |
| 73 } |
OLD | NEW |