List of usage examples for org.bouncycastle.asn1.x500 DirectoryString toString
public String toString()
From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java
License:Open Source License
private String getAdmissionStringValue(byte[] octets) throws IOException { // @formatter:off /*//from w w w .j a v a 2 s . co m 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(); }
From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java
License:Open Source License
private String getNamingAuthorityStringValue(NamingAuthority namingAuthority, int indentLevel) throws IOException { // @formatter:off /*//w w w .j a v a2 s . c om 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(); }
From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java
License:Open Source License
private String getProcurationStringValue(byte[] octets) throws IOException { // @formatter:off /*// w w w. j av a 2 s . c o m ProcurationSyntax ::= SEQUENCE { country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL, typeOfSubstitution [2] EXPLICIT DirectoryString(SIZE(1..128)) OPTIONAL, signingFor [3] EXPLICIT SigningFor } SigningFor ::= CHOICE { thirdPerson GeneralName, certRef IssuerSerial } */ // @formatter:on StringBuilder sb = new StringBuilder(); ProcurationSyntax procurationSyntax = ProcurationSyntax.getInstance(octets); String country = procurationSyntax.getCountry(); DirectoryString typeOfSubstitution = procurationSyntax.getTypeOfSubstitution(); GeneralName thirdPerson = procurationSyntax.getThirdPerson(); IssuerSerial certRef = procurationSyntax.getCertRef(); if (country != null) { sb.append(MessageFormat.format(res.getString("Procuration.Country"), country)); sb.append(NEWLINE); } if (typeOfSubstitution != null) { sb.append(MessageFormat.format(res.getString("Procuration.TypeOfSubstitution"), typeOfSubstitution.toString())); sb.append(NEWLINE); } if (thirdPerson != null) { sb.append(MessageFormat.format(res.getString("Procuration.ThirdPerson"), GeneralNameUtil.toString(thirdPerson))); sb.append(NEWLINE); } if (certRef != null) { sb.append(res.getString("Procuration.CertRef")); sb.append(NEWLINE); sb.append(INDENT); sb.append(res.getString("Procuration.CertRef.Issuer")); for (GeneralName generalName : certRef.getIssuer().getNames()) { sb.append(INDENT); sb.append(INDENT); sb.append(GeneralNameUtil.toString(generalName)); sb.append(NEWLINE); } sb.append(NEWLINE); sb.append(INDENT); sb.append(MessageFormat.format(res.getString("Procuration.CertRef.SN"), HexUtil.getHexString(certRef.getSerial().getValue()))); sb.append(NEWLINE); } return sb.toString(); }