use of com.unboundid.asn1.ASN1Set in project AttestationServer by GrapheneOS.
the class AttestationApplicationId method parseAttestationPackageInfos.
private List<AttestationPackageInfo> parseAttestationPackageInfos(ASN1Encodable asn1Encodable) throws CertificateParsingException {
if (!(asn1Encodable instanceof ASN1Set)) {
throw new CertificateParsingException("Expected set for AttestationApplicationsInfos, found " + asn1Encodable.getClass().getName());
}
ASN1Set set = (ASN1Set) asn1Encodable;
List<AttestationPackageInfo> result = new ArrayList<>();
for (ASN1Encodable e : set) {
result.add(new AttestationPackageInfo(e));
}
return result;
}
use of com.unboundid.asn1.ASN1Set in project gdmatrix by gdmatrix.
the class P7MUtils method printAttribute.
public static void printAttribute(Attribute attribute) throws Exception {
ASN1Set set = attribute.getAttrValues();
ASN1Primitive der = set.getObjectAt(0).toASN1Primitive();
System.out.println(der.getClass());
if (der instanceof DEROctetString) {
DEROctetString octet = (DEROctetString) der;
byte[] data = octet.getOctets();
System.out.println(new String(data, "UTF-16LE"));
} else if (der instanceof ASN1UTCTime) {
ASN1UTCTime utcTime = (ASN1UTCTime) der;
String time = utcTime.getAdjustedTime();
System.out.println(time);
} else if (der instanceof ASN1ObjectIdentifier) {
ASN1ObjectIdentifier id = (ASN1ObjectIdentifier) der;
System.out.println(id.getId());
}
}
use of com.unboundid.asn1.ASN1Set in project ca3sCore by kuehne-trustable-de.
the class CertificateUtil method getSANList.
public Set<GeneralName> getSANList(Pkcs10RequestHolder p10ReqHolder) {
Set<GeneralName> generalNameSet = new HashSet<>();
for (Attribute attr : p10ReqHolder.getReqAttributes()) {
if (PKCSObjectIdentifiers.pkcs_9_at_extensionRequest.equals(attr.getAttrType())) {
ASN1Set valueSet = attr.getAttrValues();
LOG.debug("ExtensionRequest / AttrValues has {} elements", valueSet.size());
for (ASN1Encodable asn1Enc : valueSet) {
DERSequence derSeq = (DERSequence) asn1Enc;
LOG.debug("ExtensionRequest / DERSequence has {} elements", derSeq.size());
LOG.debug("ExtensionRequest / DERSequence[0] is a {}", derSeq.getObjectAt(0).getClass().getName());
DERSequence derSeq2 = (DERSequence) derSeq.getObjectAt(0);
LOG.debug("ExtensionRequest / DERSequence2 has {} elements", derSeq2.size());
LOG.debug("ExtensionRequest / DERSequence2[0] is a {}", derSeq2.getObjectAt(0).getClass().getName());
ASN1ObjectIdentifier objId = (ASN1ObjectIdentifier) (derSeq2.getObjectAt(0));
if (Extension.subjectAlternativeName.equals(objId)) {
DEROctetString derStr = (DEROctetString) derSeq2.getObjectAt(1);
GeneralNames names = GeneralNames.getInstance(derStr.getOctets());
LOG.debug("Attribute value SAN" + names);
LOG.debug("SAN values #" + names.getNames().length);
for (GeneralName gnSAN : names.getNames()) {
LOG.debug("GN " + gnSAN.toString());
generalNameSet.add(gnSAN);
}
} else {
LOG.info("Unexpected Extensions Attribute value " + objId.getId());
}
}
}
}
return generalNameSet;
}
use of com.unboundid.asn1.ASN1Set in project Auditor by GrapheneOS.
the class AttestationApplicationId method parseAttestationPackageInfos.
private List<AttestationPackageInfo> parseAttestationPackageInfos(ASN1Encodable asn1Encodable) throws CertificateParsingException {
if (!(asn1Encodable instanceof ASN1Set)) {
throw new CertificateParsingException("Expected set for AttestationApplicationsInfos, found " + asn1Encodable.getClass().getName());
}
ASN1Set set = (ASN1Set) asn1Encodable;
List<AttestationPackageInfo> result = new ArrayList<>();
for (ASN1Encodable e : set) {
result.add(new AttestationPackageInfo(e));
}
return result;
}
use of com.unboundid.asn1.ASN1Set in project Falcon-File-Transfer-Optimizer by arif-zaman.
the class X509NameHelper method toString.
private static String toString(ASN1Sequence seq) {
if (seq == null) {
return null;
}
Enumeration e = seq.getObjects();
StringBuffer buf = new StringBuffer();
while (e.hasMoreElements()) {
ASN1Set set = (ASN1Set) e.nextElement();
Enumeration ee = set.getObjects();
buf.append('/');
while (ee.hasMoreElements()) {
ASN1Sequence s = (ASN1Sequence) ee.nextElement();
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) s.getObjectAt(0);
String sym = (String) X509Name.DefaultSymbols.get(oid);
if (sym == null) {
buf.append(oid.getId());
} else {
buf.append(sym);
}
buf.append('=');
buf.append(((ASN1String) s.getObjectAt(1)).getString());
if (ee.hasMoreElements()) {
buf.append('+');
}
}
}
return buf.toString();
}
Aggregations