Java 类org.bouncycastle.asn1.x509.qualified.TypeOfBiometricData 实例源码

项目:irma_future_id    文件:BiometricDataUnitTest.java   
private void checkConstruction(
    BiometricData bd,
    TypeOfBiometricData dataType, 
    AlgorithmIdentifier hashAlgorithm,
    ASN1OctetString dataHash, 
    DERIA5String dataUri)
    throws Exception
{
    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);

    bd = BiometricData.getInstance(bd);

    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);

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

    ASN1Sequence seq = (ASN1Sequence)aIn.readObject();

    bd = BiometricData.getInstance(seq);

    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);
}
项目:bc-java    文件:BiometricDataUnitTest.java   
private void checkConstruction(
    BiometricData bd,
    TypeOfBiometricData dataType, 
    AlgorithmIdentifier hashAlgorithm,
    ASN1OctetString dataHash, 
    DERIA5String dataUri)
    throws Exception
{
    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);

    bd = BiometricData.getInstance(bd);

    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);

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

    ASN1Sequence seq = (ASN1Sequence)aIn.readObject();

    bd = BiometricData.getInstance(seq);

    checkValues(bd, dataType, hashAlgorithm, dataHash, dataUri);
}
项目:xipki    文件:BiometricInfoOption.java   
public boolean isTypePermitted(TypeOfBiometricData type) {
    ParamUtil.requireNonNull("type", type);

    if (type.isPredefined()) {
        return predefinedTypes.contains(type.getPredefinedBiometricType());
    } else {
        return idTypes.contains(type.getBiometricDataOid());
    }
}
项目:irma_future_id    文件:TypeOfBiometricDataUnitTest.java   
private void checkPredefined(
    TypeOfBiometricData type,
    int                 value)
{
    if (!type.isPredefined())
    {
        fail("predefined type expected but not found.");
    }

    if (type.getPredefinedBiometricType() != value)
    {
        fail("predefined type does not match.");
    }
}
项目:irma_future_id    文件:TypeOfBiometricDataUnitTest.java   
private void checkNonPredefined(
    TypeOfBiometricData type,
    DERObjectIdentifier value)
{
    if (type.isPredefined())
    {
        fail("predefined type found when not expected.");
    }

    if (!type.getBiometricDataOid().equals(value))
    {
        fail("data oid does not match.");
    }
}
项目:irma_future_id    文件:BiometricDataUnitTest.java   
private void checkValues(
    BiometricData       bd,
    TypeOfBiometricData dataType,
    AlgorithmIdentifier algID,
    ASN1OctetString     dataHash,
    DERIA5String        sourceDataURI)
{
    if (!bd.getTypeOfBiometricData().equals(dataType))
    {
        fail("types don't match.");
    }

    if (!bd.getHashAlgorithm().equals(algID))
    {
        fail("hash algorithms don't match.");
    }

    if (!bd.getBiometricDataHash().equals(dataHash))
    {
        fail("hash algorithms don't match.");
    }

    if (sourceDataURI != null)
    {
        if (!bd.getSourceDataUri().equals(sourceDataURI))
        {
            fail("data uris don't match.");
        }
    }
    else if (bd.getSourceDataUri() != null)
    {
        fail("data uri found when none expected.");
    }
}
项目:bc-java    文件:TypeOfBiometricDataUnitTest.java   
private void checkPredefined(
    TypeOfBiometricData type,
    int                 value)
{
    if (!type.isPredefined())
    {
        fail("predefined type expected but not found.");
    }

    if (type.getPredefinedBiometricType() != value)
    {
        fail("predefined type does not match.");
    }
}
项目:bc-java    文件:TypeOfBiometricDataUnitTest.java   
private void checkNonPredefined(
    TypeOfBiometricData type,
    DERObjectIdentifier value)
{
    if (type.isPredefined())
    {
        fail("predefined type found when not expected.");
    }

    if (!type.getBiometricDataOid().equals(value))
    {
        fail("data oid does not match.");
    }
}
项目:bc-java    文件:BiometricDataUnitTest.java   
private void checkValues(
    BiometricData       bd,
    TypeOfBiometricData dataType,
    AlgorithmIdentifier algID,
    ASN1OctetString     dataHash,
    DERIA5String        sourceDataURI)
{
    if (!bd.getTypeOfBiometricData().equals(dataType))
    {
        fail("types don't match.");
    }

    if (!bd.getHashAlgorithm().equals(algID))
    {
        fail("hash algorithms don't match.");
    }

    if (!bd.getBiometricDataHash().equals(dataHash))
    {
        fail("hash algorithms don't match.");
    }

    if (sourceDataURI != null)
    {
        if (!bd.getSourceDataUri().equals(sourceDataURI))
        {
            fail("data uris don't match.");
        }
    }
    else if (bd.getSourceDataUri() != null)
    {
        fail("data uri found when none expected.");
    }
}
项目:keystore-explorer    文件:X509Ext.java   
private String getBiometricInfoStringValue(byte[] octets) {

        // @formatter:off

        /*
            BiometricSyntax ::= SEQUENCE OF BiometricData
            BiometricData ::= SEQUENCE
            {
                typeOfBiometricData TypeOfBiometricData,
                hashAlgorithm AlgorithmIdentifier,
                biometricDataHash OCTET STRING,
                sourceDataUri IA5String OPTIONAL
            }
            TypeOfBiometricData ::= CHOICE
            {
                predefinedBiometricType PredefinedBiometricType,
                biometricDataId OBJECT IDENTIIFER
            }
            PredefinedBiometricType ::= INTEGER
            {
                picture(0),
                handwritten-signature(1)
            }
         */

        // @formatter:on

        StringBuilder sb = new StringBuilder();
        int biometricDataNr = 0;

        ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(octets);

        for (ASN1Encodable asn1Encodable : asn1Sequence.toArray()) {
            BiometricData biometricData = BiometricData.getInstance(asn1Encodable);
            TypeOfBiometricData typeOfBiometricData = biometricData.getTypeOfBiometricData();
            AlgorithmIdentifier hashAlgorithm = biometricData.getHashAlgorithm();
            ASN1OctetString biometricDataHash = biometricData.getBiometricDataHash();
            DERIA5String sourceDataUri = biometricData.getSourceDataUri();

            sb.append(MessageFormat.format(res.getString("BiometricInfo.BiometricData"), biometricDataNr));
            sb.append(NEWLINE);

            sb.append(INDENT);
            if (typeOfBiometricData.isPredefined()) {
                int type = typeOfBiometricData.getPredefinedBiometricType();
                sb.append(MessageFormat.format(res.getString("BiometricInfo.TypeOfBiometricData"), type));
            } else {
                String biometricDataOid = typeOfBiometricData.getBiometricDataOid().getId();
                sb.append(MessageFormat.format(res.getString("BiometricInfo.TypeOfBiometricData"), biometricDataOid));
            }
            sb.append(NEWLINE);

            sb.append(INDENT);
            sb.append(MessageFormat.format(res.getString("BiometricInfo.HashAlgorithm"),
                    hashAlgorithm.getAlgorithm().getId()));
            sb.append(NEWLINE);

            sb.append(INDENT);
            sb.append(MessageFormat.format(res.getString("BiometricInfo.BiometricDataHash"),
                    HexUtil.getHexString(biometricDataHash.getOctets())));
            sb.append(NEWLINE);

            if (sourceDataUri != null) { // optional
                sb.append(INDENT);
                sb.append(MessageFormat.format(res.getString("BiometricInfo.SourceDataUri"), sourceDataUri.toString()));
                sb.append(NEWLINE);
            }
        }

        return sb.toString();
    }
项目:irma_future_id    文件:TypeOfBiometricDataUnitTest.java   
private void checkPredefinedType(
    int predefinedType)
    throws IOException
{
    TypeOfBiometricData type = new TypeOfBiometricData(predefinedType);

    checkPredefined(type, predefinedType);

    type = TypeOfBiometricData.getInstance(type);

    checkPredefined(type, predefinedType);

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

    ASN1Primitive obj = aIn.readObject();

    type = TypeOfBiometricData.getInstance(obj);

    checkPredefined(type, predefinedType);
}
项目:bc-java    文件:TypeOfBiometricDataUnitTest.java   
private void checkPredefinedType(
    int predefinedType)
    throws IOException
{
    TypeOfBiometricData type = new TypeOfBiometricData(predefinedType);

    checkPredefined(type, predefinedType);

    type = TypeOfBiometricData.getInstance(type);

    checkPredefined(type, predefinedType);

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

    ASN1Primitive obj = aIn.readObject();

    type = TypeOfBiometricData.getInstance(obj);

    checkPredefined(type, predefinedType);
}