diff options
author | Yuuta Liang <yuutaw@students.cs.ubc.ca> | 2023-10-14 05:12:06 +0800 |
---|---|---|
committer | Yuuta Liang <yuutaw@students.cs.ubc.ca> | 2023-10-14 05:12:06 +0800 |
commit | 0bcc057e741af3fbc108f42b75f9d42f48f6a51e (patch) | |
tree | d638c81c0778554a8902efc59000e61db74060be /src/main/model/pki/cert | |
parent | f369da34cf9aca151df0150d90e651e6a88ee700 (diff) | |
download | jca-0bcc057e741af3fbc108f42b75f9d42f48f6a51e.tar jca-0bcc057e741af3fbc108f42b75f9d42f48f6a51e.tar.gz jca-0bcc057e741af3fbc108f42b75f9d42f48f6a51e.tar.bz2 jca-0bcc057e741af3fbc108f42b75f9d42f48f6a51e.zip |
Implement the CA
Signed-off-by: Yuuta Liang <yuutaw@students.cs.ubc.ca>
Diffstat (limited to 'src/main/model/pki/cert')
-rw-r--r-- | src/main/model/pki/cert/TbsCertificate.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/model/pki/cert/TbsCertificate.java b/src/main/model/pki/cert/TbsCertificate.java index 1175456..ce228af 100644 --- a/src/main/model/pki/cert/TbsCertificate.java +++ b/src/main/model/pki/cert/TbsCertificate.java @@ -229,6 +229,21 @@ public class TbsCertificate extends ASN1Object { .toArray(Byte[]::new); } + /** + * EFFECT: Get the extension by ID. If the certificate is V1 or does not have any extensions or does not have the + * specified extension, null is returned. + * REQUIRES: extnId should be a valid X.509 certificate extension ID. + */ + public Extension getExtension(Integer[] extnId) { + if (extensions == null) { + return null; + } + return Arrays.stream(extensions.getExtensions()) + .filter(extn -> Arrays.equals(extnId, extn.getExtnId().getInts())) + .findFirst() + .orElse(null); + } + public Int getVersion() { return version; } |