Java 类org.bouncycastle.asn1.isismtt.x509.DeclarationOfMajority 实例源码

项目:gwt-crypto    文件:DeclarationOfMajorityUnitTest.java   
private void checkConstruction(
    DeclarationOfMajority decl,
    int                   type,
    ASN1GeneralizedTime   dateOfBirth,
    int                   notYoungerThan)
    throws IOException
{
    checkValues(decl, type, dateOfBirth, notYoungerThan);

    decl = DeclarationOfMajority.getInstance(decl);

    checkValues(decl, type, dateOfBirth, notYoungerThan);

    ASN1InputStream aIn = new ASN1InputStream(decl.toASN1Primitive().getEncoded());

    DERTaggedObject info = (DERTaggedObject)aIn.readObject();

    decl = DeclarationOfMajority.getInstance(info);

    checkValues(decl, type, dateOfBirth, notYoungerThan);
}
项目:irma_future_id    文件:DeclarationOfMajorityUnitTest.java   
private void checkConstruction(
    DeclarationOfMajority decl,
    int                   type,
    DERGeneralizedTime    dateOfBirth,
    int                   notYoungerThan)
    throws IOException
{
    checkValues(decl, type, dateOfBirth, notYoungerThan);

    decl = DeclarationOfMajority.getInstance(decl);

    checkValues(decl, type, dateOfBirth, notYoungerThan);

    ASN1InputStream aIn = new ASN1InputStream(decl.toASN1Object().getEncoded());

    DERTaggedObject info = (DERTaggedObject)aIn.readObject();

    decl = DeclarationOfMajority.getInstance(info);

    checkValues(decl, type, dateOfBirth, notYoungerThan);
}
项目:bc-java    文件:DeclarationOfMajorityUnitTest.java   
private void checkConstruction(
    DeclarationOfMajority decl,
    int                   type,
    DERGeneralizedTime    dateOfBirth,
    int                   notYoungerThan)
    throws IOException
{
    checkValues(decl, type, dateOfBirth, notYoungerThan);

    decl = DeclarationOfMajority.getInstance(decl);

    checkValues(decl, type, dateOfBirth, notYoungerThan);

    ASN1InputStream aIn = new ASN1InputStream(decl.toASN1Object().getEncoded());

    DERTaggedObject info = (DERTaggedObject)aIn.readObject();

    decl = DeclarationOfMajority.getInstance(info);

    checkValues(decl, type, dateOfBirth, notYoungerThan);
}
项目:gwt-crypto    文件:DeclarationOfMajorityUnitTest.java   
private void checkValues(
    DeclarationOfMajority decl,
    int                   type,
    ASN1GeneralizedTime   dateOfBirth,
    int                   notYoungerThan)
{
    checkMandatoryField("type", type, decl.getType());
    checkOptionalField("dateOfBirth", dateOfBirth, decl.getDateOfBirth());
    if (notYoungerThan != -1 && notYoungerThan != decl.notYoungerThan())
    {
        fail("notYoungerThan mismatch");
    }
}
项目:irma_future_id    文件:DeclarationOfMajorityUnitTest.java   
private void checkValues(
    DeclarationOfMajority decl,
    int                   type,
    DERGeneralizedTime    dateOfBirth,
    int                   notYoungerThan)
{
    checkMandatoryField("type", type, decl.getType());
    checkOptionalField("dateOfBirth", dateOfBirth, decl.getDateOfBirth());
    if (notYoungerThan != -1 && notYoungerThan != decl.notYoungerThan())
    {
        fail("notYoungerThan mismatch");
    }
}
项目:bc-java    文件:DeclarationOfMajorityUnitTest.java   
private void checkValues(
    DeclarationOfMajority decl,
    int                   type,
    DERGeneralizedTime    dateOfBirth,
    int                   notYoungerThan)
{
    checkMandatoryField("type", type, decl.getType());
    checkOptionalField("dateOfBirth", dateOfBirth, decl.getDateOfBirth());
    if (notYoungerThan != -1 && notYoungerThan != decl.notYoungerThan())
    {
        fail("notYoungerThan mismatch");
    }
}
项目:keystore-explorer    文件:X509Ext.java   
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();
    }