use of org.xipki.ca.certprofile.commonpki.AdmissionSyntaxOption in project xipki by xipki.
the class ExtensionsChecker method checkExtensionAdmission.
// method checkExtensionDeltaCrlDistributionPoints
private void checkExtensionAdmission(StringBuilder failureMsg, byte[] extensionValue, Extensions requestedExtensions, ExtensionControl extControl) {
AdmissionSyntaxOption conf = certProfile.getAdmission();
ASN1ObjectIdentifier type = ObjectIdentifiers.id_extension_admission;
if (conf == null) {
byte[] expected = getExpectedExtValue(type, requestedExtensions, extControl);
if (!Arrays.equals(expected, extensionValue)) {
addViolation(failureMsg, "extension value", hex(extensionValue), (expected == null) ? "not present" : hex(expected));
}
return;
}
List<List<String>> reqRegNumsList = null;
if (requestedExtensions != null && conf.isInputFromRequestRequired()) {
Extension extension = requestedExtensions.getExtension(type);
if (extension == null) {
failureMsg.append("no Admission extension is contained in the request;");
return;
}
Admissions[] reqAdmissions = org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax.getInstance(extension.getParsedValue()).getContentsOfAdmissions();
final int n = reqAdmissions.length;
reqRegNumsList = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
Admissions reqAdmission = reqAdmissions[i];
ProfessionInfo[] reqPis = reqAdmission.getProfessionInfos();
List<String> reqNums = new ArrayList<>(reqPis.length);
reqRegNumsList.add(reqNums);
for (ProfessionInfo reqPi : reqPis) {
String reqNum = reqPi.getRegistrationNumber();
reqNums.add(reqNum);
}
}
}
try {
byte[] expected = conf.getExtensionValue(reqRegNumsList).getValue().toASN1Primitive().getEncoded();
if (!Arrays.equals(expected, extensionValue)) {
addViolation(failureMsg, "extension valus", hex(extensionValue), hex(expected));
}
} catch (IOException ex) {
LogUtil.error(LOG, ex);
failureMsg.append("IOException while computing the expected extension value;");
return;
} catch (BadCertTemplateException ex) {
LogUtil.error(LOG, ex);
failureMsg.append("BadCertTemplateException while computing the expected extension value;");
}
}
use of org.xipki.ca.certprofile.commonpki.AdmissionSyntaxOption in project xipki by xipki.
the class XmlX509CertprofileUtil method buildAdmissionSyntax.
public static AdmissionSyntaxOption buildAdmissionSyntax(boolean critical, AdmissionSyntax type) throws CertprofileException {
List<AdmissionsOption> admissionsList = new LinkedList<>();
for (AdmissionsType at : type.getContentsOfAdmissions()) {
List<ProfessionInfoOption> professionInfos = new LinkedList<>();
for (ProfessionInfoType pi : at.getProfessionInfo()) {
NamingAuthority namingAuthorityL3 = null;
if (pi.getNamingAuthority() != null) {
namingAuthorityL3 = buildNamingAuthority(pi.getNamingAuthority());
}
List<OidWithDescType> oidTypes = pi.getProfessionOid();
List<ASN1ObjectIdentifier> oids = null;
if (CollectionUtil.isNonEmpty(oidTypes)) {
oids = new LinkedList<>();
for (OidWithDescType k : oidTypes) {
oids.add(new ASN1ObjectIdentifier(k.getValue()));
}
}
RegistrationNumber rnType = pi.getRegistrationNumber();
RegistrationNumberOption rno = (rnType == null) ? null : new RegistrationNumberOption(rnType.getRegex(), rnType.getConstant());
ProfessionInfoOption pio = new ProfessionInfoOption(namingAuthorityL3, pi.getProfessionItem(), oids, rno, pi.getAddProfessionInfo());
professionInfos.add(pio);
}
GeneralName admissionAuthority = null;
if (at.getNamingAuthority() != null) {
admissionAuthority = GeneralName.getInstance(asn1PrimitivefromByteArray(at.getAdmissionAuthority()));
}
NamingAuthority namingAuthority = null;
if (at.getNamingAuthority() != null) {
namingAuthority = buildNamingAuthority(at.getNamingAuthority());
}
AdmissionsOption admissionsOption = new AdmissionsOption(admissionAuthority, namingAuthority, professionInfos);
admissionsList.add(admissionsOption);
}
GeneralName admissionAuthority = null;
if (type.getAdmissionAuthority() != null) {
admissionAuthority = GeneralName.getInstance(type.getAdmissionAuthority());
}
return new AdmissionSyntaxOption(critical, admissionAuthority, admissionsList);
}
Aggregations