use of org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax in project xipki by xipki.
the class XmlX509Certprofile method initAdmission.
private void initAdmission(Set<ASN1ObjectIdentifier> extnIds, ExtensionsType extensionsType) throws CertprofileException {
ASN1ObjectIdentifier type = ObjectIdentifiers.id_extension_admission;
if (!extensionControls.containsKey(type)) {
return;
}
extnIds.remove(type);
AdmissionSyntax extConf = (AdmissionSyntax) getExtensionValue(type, extensionsType, AdmissionSyntax.class);
if (extConf == null) {
return;
}
this.admission = XmlX509CertprofileUtil.buildAdmissionSyntax(extensionControls.get(type).isCritical(), extConf);
}
use of org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax in project keystore-explorer by kaikramer.
the class X509Ext method getAdmissionStringValue.
private String getAdmissionStringValue(byte[] octets) throws IOException {
// @formatter:off
/*
AdmissionSyntax ::= SEQUENCE
{
admissionAuthority GeneralName OPTIONAL,
contentsOfAdmissions SEQUENCE OF Admissions
}
Admissions ::= SEQUENCE
{
admissionAuthority [0] EXPLICIT GeneralName OPTIONAL
namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL
professionInfos SEQUENCE OF ProfessionInfo
}
NamingAuthority ::= SEQUENCE
{
namingAuthorityId OBJECT IDENTIFIER OPTIONAL,
namingAuthorityUrl IA5String OPTIONAL,
namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL
}
ProfessionInfo ::= SEQUENCE
{
namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
addProfessionInfo OCTET STRING OPTIONAL
}
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
int indentLevel = 1;
AdmissionSyntax admissionSyntax = AdmissionSyntax.getInstance(ASN1Sequence.getInstance(octets));
GeneralName admissionAuthority = admissionSyntax.getAdmissionAuthority();
if (admissionAuthority != null) {
sb.append(MessageFormat.format(res.getString("Admission.AdmissionAuthority"), GeneralNameUtil.toString(admissionAuthority)));
sb.append(NEWLINE);
}
Admissions[] admissions = admissionSyntax.getContentsOfAdmissions();
int admissionNr = 0;
for (Admissions admission : admissions) {
sb.append(MessageFormat.format(res.getString("Admission.Admission"), ++admissionNr));
sb.append(NEWLINE);
admissionAuthority = admission.getAdmissionAuthority();
NamingAuthority namingAuthority = admission.getNamingAuthority();
ProfessionInfo[] professionInfos = admission.getProfessionInfos();
if (admissionAuthority != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.AdmissionAuthority"), GeneralNameUtil.toString(admissionAuthority)));
sb.append(NEWLINE);
}
if (namingAuthority != null) {
sb.append(getNamingAuthorityStringValue(namingAuthority, indentLevel));
}
for (ProfessionInfo professionInfo : professionInfos) {
namingAuthority = professionInfo.getNamingAuthority();
ASN1ObjectIdentifier[] professionOIDs = professionInfo.getProfessionOIDs();
String registrationNumber = professionInfo.getRegistrationNumber();
ASN1OctetString addProfessionInfo = professionInfo.getAddProfessionInfo();
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString("Admission.ProfessionInfo"));
sb.append(NEWLINE);
indentLevel++;
if (namingAuthority != null) {
sb.append(getNamingAuthorityStringValue(namingAuthority, indentLevel));
}
DirectoryString[] professionItems = professionInfo.getProfessionItems();
for (DirectoryString professionItem : professionItems) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.ProfessionItem"), professionItem.toString()));
sb.append(NEWLINE);
}
if (professionOIDs != null) {
for (ASN1ObjectIdentifier professionOID : professionOIDs) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.ProfessionOID"), professionOID.getId()));
sb.append(NEWLINE);
}
}
if (registrationNumber != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.RegistrationNumber"), registrationNumber));
sb.append(NEWLINE);
}
if (addProfessionInfo != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.AddProfessionInfo"), HexUtil.getHexString(addProfessionInfo.getOctets())));
sb.append(NEWLINE);
}
indentLevel--;
}
}
return sb.toString();
}
Aggregations