what-the-bank/sources/org/jmrtd/lds/icao/DG3File.java

103 lines
4.1 KiB
Java

package org.jmrtd.lds.icao;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import org.jmrtd.cbeff.BiometricDataBlock;
import org.jmrtd.cbeff.BiometricDataBlockDecoder;
import org.jmrtd.cbeff.BiometricDataBlockEncoder;
import org.jmrtd.cbeff.CBEFFInfo;
import org.jmrtd.cbeff.ComplexCBEFFInfo;
import org.jmrtd.cbeff.ISO781611Decoder;
import org.jmrtd.cbeff.ISO781611Encoder;
import org.jmrtd.cbeff.SimpleCBEFFInfo;
import org.jmrtd.cbeff.StandardBiometricHeader;
import org.jmrtd.lds.CBEFFDataGroup;
import org.jmrtd.lds.iso19794.FingerInfo;
/* loaded from: classes6.dex */
public class DG3File extends CBEFFDataGroup<FingerInfo> {
private static final long serialVersionUID = -1037522331623814528L;
private boolean shouldAddRandomDataIfEmpty;
private static final Logger LOGGER = Logger.getLogger("org.jmrtd");
private static final ISO781611Decoder DECODER = new ISO781611Decoder(new BiometricDataBlockDecoder<FingerInfo>() { // from class: org.jmrtd.lds.icao.DG3File.1
@Override // org.jmrtd.cbeff.BiometricDataBlockDecoder
public final FingerInfo decode(InputStream inputStream, StandardBiometricHeader standardBiometricHeader, int i, int i2) throws IOException {
return new FingerInfo(standardBiometricHeader, inputStream);
}
});
private static final ISO781611Encoder<FingerInfo> ENCODER = new ISO781611Encoder<>(new BiometricDataBlockEncoder<FingerInfo>() { // from class: org.jmrtd.lds.icao.DG3File.2
@Override // org.jmrtd.cbeff.BiometricDataBlockEncoder
public final void encode(FingerInfo fingerInfo, OutputStream outputStream) throws IOException {
fingerInfo.writeObject(outputStream);
}
});
public DG3File(List<FingerInfo> list) {
this(list, true);
}
public DG3File(List<FingerInfo> list, boolean z) {
super(99, list);
this.shouldAddRandomDataIfEmpty = z;
}
public DG3File(InputStream inputStream) throws IOException {
super(99, inputStream);
}
@Override // org.jmrtd.lds.AbstractTaggedLDSFile
public void readContent(InputStream inputStream) throws IOException {
for (CBEFFInfo cBEFFInfo : DECODER.decode(inputStream).getSubRecords()) {
if (!(cBEFFInfo instanceof SimpleCBEFFInfo)) {
StringBuilder sb = new StringBuilder("Was expecting a SimpleCBEFFInfo, found ");
sb.append(cBEFFInfo.getClass().getSimpleName());
throw new IOException(sb.toString());
}
BiometricDataBlock biometricDataBlock = ((SimpleCBEFFInfo) cBEFFInfo).getBiometricDataBlock();
if (!(biometricDataBlock instanceof FingerInfo)) {
StringBuilder sb2 = new StringBuilder("Was expecting a FingerInfo, found ");
sb2.append(biometricDataBlock.getClass().getSimpleName());
throw new IOException(sb2.toString());
}
add((FingerInfo) biometricDataBlock);
}
}
@Override // org.jmrtd.lds.AbstractTaggedLDSFile
public void writeContent(OutputStream outputStream) throws IOException {
ComplexCBEFFInfo complexCBEFFInfo = new ComplexCBEFFInfo();
Iterator<FingerInfo> it = getSubRecords().iterator();
while (it.hasNext()) {
complexCBEFFInfo.add(new SimpleCBEFFInfo(it.next()));
}
ENCODER.encode(complexCBEFFInfo, outputStream);
if (this.shouldAddRandomDataIfEmpty) {
writeOptionalRandomData(outputStream);
}
}
@Override // org.jmrtd.lds.DataGroup, org.jmrtd.lds.AbstractTaggedLDSFile
public String toString() {
StringBuilder sb = new StringBuilder("DG3File [");
sb.append(super.toString());
sb.append("]");
return sb.toString();
}
public List<FingerInfo> getFingerInfos() {
return getSubRecords();
}
public void addFingerInfo(FingerInfo fingerInfo) {
add(fingerInfo);
}
public void removeFingerInfo(int i) {
remove(i);
}
}