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

101 lines
3.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
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 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.IrisInfo;
/* loaded from: classes6.dex */
public class DG4File extends CBEFFDataGroup<IrisInfo> {
private static final ISO781611Decoder DECODER = new ISO781611Decoder(new BiometricDataBlockDecoder<IrisInfo>() { // from class: org.jmrtd.lds.icao.DG4File.1
@Override // org.jmrtd.cbeff.BiometricDataBlockDecoder
public final IrisInfo decode(InputStream inputStream, StandardBiometricHeader standardBiometricHeader, int i, int i2) throws IOException {
return new IrisInfo(standardBiometricHeader, inputStream);
}
});
private static final ISO781611Encoder<IrisInfo> ENCODER = new ISO781611Encoder<>(new BiometricDataBlockEncoder<IrisInfo>() { // from class: org.jmrtd.lds.icao.DG4File.2
@Override // org.jmrtd.cbeff.BiometricDataBlockEncoder
public final void encode(IrisInfo irisInfo, OutputStream outputStream) throws IOException {
irisInfo.writeObject(outputStream);
}
});
private static final long serialVersionUID = -1290365855823447586L;
private boolean shouldAddRandomDataIfEmpty;
public DG4File(List<IrisInfo> list) {
this(list, true);
}
public DG4File(List<IrisInfo> list, boolean z) {
super(118, list);
this.shouldAddRandomDataIfEmpty = z;
}
public DG4File(InputStream inputStream) throws IOException {
super(118, 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 IrisInfo)) {
StringBuilder sb2 = new StringBuilder("Was expecting an IrisInfo, found ");
sb2.append(biometricDataBlock.getClass().getSimpleName());
throw new IOException(sb2.toString());
}
add((IrisInfo) biometricDataBlock);
}
}
@Override // org.jmrtd.lds.AbstractTaggedLDSFile
public void writeContent(OutputStream outputStream) throws IOException {
ComplexCBEFFInfo complexCBEFFInfo = new ComplexCBEFFInfo();
Iterator<IrisInfo> 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("DG4File [");
sb.append(super.toString());
sb.append("]");
return sb.toString();
}
public List<IrisInfo> getIrisInfos() {
return getSubRecords();
}
public void addIrisInfo(IrisInfo irisInfo) {
add(irisInfo);
}
public void removeIrisInfo(int i) {
remove(i);
}
}