Search in sources :

Example 1 with DeclarationOfMajority

use of org.bouncycastle.asn1.isismtt.x509.DeclarationOfMajority in project keystore-explorer by kaikramer.

the class X509Ext method getDeclarationOfMajorityStringValue.

private String getDeclarationOfMajorityStringValue(byte[] octets) {
    // @formatter:off
    /*
			DeclarationOfMajoritySyntax ::= CHOICE
			{
				notYoungerThan [0] IMPLICIT INTEGER,
				fullAgeAtCountry [1] IMPLICIT SEQUENCE {
					fullAge BOOLEAN DEFAULT TRUE,
					country PrintableString (SIZE(2))
				},
				dateOfBirth [2] IMPLICIT GeneralizedTime
			}
		 */
    // @formatter:on
    StringBuilder sb = new StringBuilder();
    DeclarationOfMajority declarationOfMajority = DeclarationOfMajority.getInstance(octets);
    int notYoungerThan = declarationOfMajority.notYoungerThan();
    ASN1Sequence fullAgeAtCountry = declarationOfMajority.fullAgeAtCountry();
    ASN1GeneralizedTime dateOfBirth = declarationOfMajority.getDateOfBirth();
    if (notYoungerThan != -1) {
        sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.notYoungerThan"), notYoungerThan));
        sb.append(NEWLINE);
    }
    if (fullAgeAtCountry != null) {
        ASN1Boolean fullAge = ASN1Boolean.getInstance(fullAgeAtCountry.getObjectAt(0));
        DERPrintableString country = DERPrintableString.getInstance(fullAgeAtCountry.getObjectAt(1));
        sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.fullAgeAtCountry"), country.toString(), fullAge.toString()));
        sb.append(NEWLINE);
    }
    if (dateOfBirth != null) {
        sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.dateOfBirth"), dateOfBirth));
        sb.append(NEWLINE);
    }
    return sb.toString();
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DeclarationOfMajority(org.bouncycastle.asn1.isismtt.x509.DeclarationOfMajority) DERPrintableString(org.bouncycastle.asn1.DERPrintableString) ASN1GeneralizedTime(org.bouncycastle.asn1.ASN1GeneralizedTime) ASN1Boolean(org.bouncycastle.asn1.ASN1Boolean) IssuingDistributionPoint(org.bouncycastle.asn1.x509.IssuingDistributionPoint) CRLDistPoint(org.bouncycastle.asn1.x509.CRLDistPoint) DistributionPoint(org.bouncycastle.asn1.x509.DistributionPoint)

Aggregations

ASN1Boolean (org.bouncycastle.asn1.ASN1Boolean)1 ASN1GeneralizedTime (org.bouncycastle.asn1.ASN1GeneralizedTime)1 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)1 DeclarationOfMajority (org.bouncycastle.asn1.isismtt.x509.DeclarationOfMajority)1 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)1 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)1 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)1