use of org.bouncycastle.asn1.isismtt.x509.NamingAuthority in project xipki by xipki.
the class XmlX509CertprofileUtil method buildNamingAuthority.
private static NamingAuthority buildNamingAuthority(NamingAuthorityType jaxb) {
ASN1ObjectIdentifier oid = (jaxb.getOid() == null) ? null : new ASN1ObjectIdentifier(jaxb.getOid().getValue());
String url = StringUtil.isBlank(jaxb.getUrl()) ? null : jaxb.getUrl();
DirectoryString text = StringUtil.isBlank(jaxb.getText()) ? null : new DirectoryString(jaxb.getText());
return new NamingAuthority(oid, url, text);
}
use of org.bouncycastle.asn1.isismtt.x509.NamingAuthority 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);
}
use of org.bouncycastle.asn1.isismtt.x509.NamingAuthority in project keystore-explorer by kaikramer.
the class X509Ext method getNamingAuthorityStringValue.
private String getNamingAuthorityStringValue(NamingAuthority namingAuthority, int indentLevel) throws IOException {
// @formatter:off
/*
NamingAuthority ::= SEQUENCE
{
namingAuthorityId OBJECT IDENTIFIER OPTIONAL,
namingAuthorityUrl IA5String OPTIONAL,
namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL
}
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
ASN1ObjectIdentifier namingAuthorityId = namingAuthority.getNamingAuthorityId();
String namingAuthorityUrl = namingAuthority.getNamingAuthorityUrl();
DirectoryString namingAuthorityText = namingAuthority.getNamingAuthorityText();
if (namingAuthorityId != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityOID"), namingAuthorityId.getId()));
sb.append(NEWLINE);
}
if (namingAuthorityUrl != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityURL"), namingAuthorityUrl));
sb.append(NEWLINE);
}
if (namingAuthorityText != null) {
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityText"), namingAuthorityText.toString()));
sb.append(NEWLINE);
}
return sb.toString();
}
use of org.bouncycastle.asn1.isismtt.x509.NamingAuthority 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