Example usage for org.bouncycastle.asn1 ASN1Boolean toString

List of usage examples for org.bouncycastle.asn1 ASN1Boolean toString

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 ASN1Boolean toString.

Prototype

public String toString() 

Source Link

Usage

From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java

License:Open Source License

private String getLiabilityLimitationFlagStringValue(byte[] octets) {

    /*   LiabilityLimitationFlagSyntax ::= BOOLEAN */

    ASN1Boolean asn1Boolean = ASN1Boolean.getInstance(octets);
    return asn1Boolean.toString();
}

From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java

License:Open Source License

private String getDeclarationOfMajorityStringValue(byte[] octets) {

    // @formatter:off

    /*/*from w  ww  .  j  av  a2 s.  co  m*/
       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();
}