use of com.github.zhenwei.core.asn1.ASN1Encodable in project pdfbox by apache.
the class CertInformationHelper method getAuthorityInfoExtensionValue.
/**
* Extracts authority information access extension values from the given data. The Data
* structure has to be implemented as described in RFC 2459, 4.2.2.1.
*
* @param extensionValue byte[] of the extension value.
* @param certInfo where to put the found values
* @throws IOException when there is a problem with the extensionValue
*/
protected static void getAuthorityInfoExtensionValue(byte[] extensionValue, CertSignatureInformation certInfo) throws IOException {
ASN1Sequence asn1Seq = (ASN1Sequence) JcaX509ExtensionUtils.parseExtensionValue(extensionValue);
Enumeration<?> objects = asn1Seq.getObjects();
while (objects.hasMoreElements()) {
// AccessDescription
ASN1Sequence obj = (ASN1Sequence) objects.nextElement();
ASN1Encodable oid = obj.getObjectAt(0);
// accessLocation
ASN1TaggedObject location = (ASN1TaggedObject) obj.getObjectAt(1);
if (X509ObjectIdentifiers.id_ad_ocsp.equals(oid) && location.getTagNo() == GeneralName.uniformResourceIdentifier) {
ASN1OctetString url = (ASN1OctetString) location.getBaseObject();
certInfo.setOcspUrl(new String(url.getOctets()));
} else if (X509ObjectIdentifiers.id_ad_caIssuers.equals(oid)) {
ASN1OctetString uri = (ASN1OctetString) location.getBaseObject();
certInfo.setIssuerUrl(new String(uri.getOctets()));
}
}
}
use of com.github.zhenwei.core.asn1.ASN1Encodable in project keystore-explorer by kaikramer.
the class Pkcs10Util method getExtensions.
/**
* Extract sequence with extensions from CSR
*
* @param pkcs10Csr The CSR
* @return Extensions from that CSR (if any)
*/
public static X509ExtensionSet getExtensions(PKCS10CertificationRequest pkcs10Csr) {
Attribute[] attributes = pkcs10Csr.getAttributes(pkcs_9_at_extensionRequest);
X509ExtensionSet x509ExtensionSet = new X509ExtensionSet();
if ((attributes != null) && (attributes.length > 0)) {
ASN1Encodable[] attributeValues = attributes[0].getAttributeValues();
if (attributeValues.length > 0) {
ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(attributeValues[0]);
x509ExtensionSet = new X509ExtensionSet(asn1Sequence);
}
}
return x509ExtensionSet;
}
use of com.github.zhenwei.core.asn1.ASN1Encodable in project keystore-explorer by kaikramer.
the class EccUtil method convertToECPrivateKeyStructure.
/**
* Converts PKCS#8 EC private key (RFC 5208/5958 ASN.1 PrivateKeyInfo structure) to "traditional" OpenSSL
* ASN.1 structure ECPrivateKey from RFC 5915. As ECPrivateKey is already in the PrivateKey field of PrivateKeyInfo,
* this must only be extracted:
* <p>
* SEQUENCE {
* INTEGER 0
* SEQUENCE {
* OBJECT IDENTIFIER ecPublicKey (1 2 840 10045 2 1)
* OBJECT IDENTIFIER prime256v1 (1 2 840 10045 3 1 7)
* }
* OCTET STRING, encapsulates {
* SEQUENCE {
* INTEGER 1
* OCTET STRING
* 17 12 CA 42 16 79 1B 45 ...B.y.E
* ...
* C8 B2 66 0A E5 60 50 0B
* [0] {
* OBJECT IDENTIFIER prime256v1 (1 2 840 10045 3 1 7)
* }
* [1] {
* BIT STRING
* 04 61 C0 08 B4 89 A0 50 .a.....P
* ...
* AE D5 ED C3 4D 0E 47 91 ....M.G.
* 89 .
* }
* }
* }
* }
*
* @param ecPrivateKey An EC key
* @return Object holding ASN1 ECPrivateKey structure
* @throws IOException When ECPrivateKey structure in PrivateKeyInfo's PrivateKey field cannot be parsed
*/
public static org.bouncycastle.asn1.sec.ECPrivateKey convertToECPrivateKeyStructure(ECPrivateKey ecPrivateKey) throws IOException {
PrivateKeyInfo privateKeyInfo = PrivateKeyInfo.getInstance(ecPrivateKey.getEncoded());
ASN1Encodable privateKey = privateKeyInfo.parsePrivateKey();
return org.bouncycastle.asn1.sec.ECPrivateKey.getInstance(privateKey);
}
use of com.github.zhenwei.core.asn1.ASN1Encodable in project keystore-explorer by kaikramer.
the class RdnPanelList method getRdns.
public List<RDN> getRdns(boolean noEmptyRdns) {
List<RDN> rdns = new ArrayList<>();
for (RdnPanel rdnPanel : entries) {
ASN1ObjectIdentifier attrType = OidDisplayNameMapping.getOidForDisplayName(rdnPanel.getAttributeName());
if (noEmptyRdns && StringUtils.trimAndConvertEmptyToNull(rdnPanel.getAttributeValue()) == null) {
continue;
}
ASN1Encodable attrValue = KseX500NameStyle.INSTANCE.stringToValue(attrType, rdnPanel.getAttributeValue());
rdns.add(new RDN(new AttributeTypeAndValue(attrType, attrValue)));
}
return rdns;
}
use of com.github.zhenwei.core.asn1.ASN1Encodable in project keystore-explorer by kaikramer.
the class DPolicyQualifierInfoChooser method populate.
private void populate(PolicyQualifierInfo policyQualifierInfo) throws IOException {
if (policyQualifierInfo == null) {
jrbCps.setSelected(true);
} else {
ASN1ObjectIdentifier policyQualifierId = policyQualifierInfo.getPolicyQualifierId();
if (policyQualifierId.equals(new ASN1ObjectIdentifier(PKIX_CPS_POINTER_QUALIFIER.oid()))) {
jrbCps.setSelected(true);
jtfCps.setText(((DERIA5String) policyQualifierInfo.getQualifier()).getString());
jtfCps.setCaretPosition(0);
} else if (policyQualifierId.equals(new ASN1ObjectIdentifier(PKIX_USER_NOTICE_QUALIFIER.oid()))) {
jrbUserNotice.setSelected(true);
ASN1Encodable userNoticeObj = policyQualifierInfo.getQualifier();
UserNotice userNotice = UserNotice.getInstance(userNoticeObj);
junUserNotice.setUserNotice(userNotice);
} else {
jrbCps.setSelected(true);
}
}
}
Aggregations