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); }
public boolean isTypePermitted(TypeOfBiometricData type) { ParamUtil.requireNonNull("type", type); if (type.isPredefined()) { return predefinedTypes.contains(type.getPredefinedBiometricType()); } else { return idTypes.contains(type.getBiometricDataOid()); } }
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."); } }
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."); } }
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."); } }
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(); }
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); }