package org.jmrtd.lds.icao; import com.airbnb.deeplinkdispatch.UrlTreeKt; import com.google.common.primitives.UnsignedBytes; import java.io.ByteArrayInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; import net.sf.scuba.tlv.TLVInputStream; import net.sf.scuba.tlv.TLVOutputStream; import o.C15109ghW; import o.ghS; import okhttp3.HttpUrl; import org.jmrtd.lds.DataGroup; /* loaded from: classes6.dex */ public class DG11File extends DataGroup { public static final int CONTENT_SPECIFIC_CONSTRUCTED_TAG = 160; public static final int COUNT_TAG = 2; public static final int CUSTODY_INFORMATION_TAG = 24344; public static final int FULL_DATE_OF_BIRTH_TAG = 24363; public static final int FULL_NAME_TAG = 24334; public static final int OTHER_NAME_TAG = 24335; public static final int OTHER_VALID_TD_NUMBERS_TAG = 24343; public static final int PERMANENT_ADDRESS_TAG = 24386; public static final int PERSONAL_NUMBER_TAG = 24336; public static final int PERSONAL_SUMMARY_TAG = 24341; public static final int PLACE_OF_BIRTH_TAG = 24337; public static final int PROFESSION_TAG = 24339; public static final int PROOF_OF_CITIZENSHIP_TAG = 24342; public static final int TAG_LIST_TAG = 92; public static final int TELEPHONE_TAG = 24338; public static final int TITLE_TAG = 24340; private static final long serialVersionUID = 8566312538928662937L; private String custodyInformation; private Date fullDateOfBirth; private String nameOfHolder; private List otherNames; private List otherValidTDNumbers; private List permanentAddress; private String personalNumber; private String personalSummary; private List placeOfBirth; private String profession; private byte[] proofOfCitizenship; private List tagPresenceList; private String telephone; private String title; private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd"); private static final Logger LOGGER = Logger.getLogger("org.jmrtd"); @Override // org.jmrtd.lds.AbstractTaggedLDSFile public int getTag() { return 107; } public DG11File(String str, List list, String str2, Date date, List list2, List list3, String str3, String str4, String str5, String str6, byte[] bArr, List list4, String str7) { super(107); this.nameOfHolder = str; this.otherNames = list == null ? new ArrayList() : new ArrayList(list); this.personalNumber = str2; this.fullDateOfBirth = date; this.placeOfBirth = list2 == null ? new ArrayList() : new ArrayList(list2); this.permanentAddress = list3; this.telephone = str3; this.profession = str4; this.title = str5; this.personalSummary = str6; this.proofOfCitizenship = bArr; this.otherValidTDNumbers = list4 == null ? new ArrayList() : new ArrayList(list4); this.custodyInformation = str7; } public DG11File(InputStream inputStream) throws IOException { super(107, inputStream); } @Override // org.jmrtd.lds.AbstractTaggedLDSFile public void readContent(InputStream inputStream) throws IOException { TLVInputStream tLVInputStream = inputStream instanceof TLVInputStream ? (TLVInputStream) inputStream : new TLVInputStream(inputStream); if (tLVInputStream.b() != 92) { throw new IllegalArgumentException("Expected tag list in DG11"); } int c = tLVInputStream.c(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(tLVInputStream.d()); ArrayList arrayList = new ArrayList((c / 2) + 1); int i = 0; while (i < c) { int b = new TLVInputStream(byteArrayInputStream).b(); i += C15109ghW.b(b).length; arrayList.add(Integer.valueOf(b)); } Iterator it = arrayList.iterator(); while (it.hasNext()) { readField(((Integer) it.next()).intValue(), tLVInputStream); } } private void readField(int i, TLVInputStream tLVInputStream) throws IOException { int b = tLVInputStream.b(); if (b == 160) { tLVInputStream.c(); int b2 = tLVInputStream.b(); if (b2 != 2) { StringBuilder sb = new StringBuilder("Expected "); sb.append(Integer.toHexString(2)); sb.append(", found "); sb.append(Integer.toHexString(b2)); throw new IllegalArgumentException(sb.toString()); } int c = tLVInputStream.c(); if (c != 1) { throw new IllegalArgumentException("Expected length 1 count length, found ".concat(String.valueOf(c))); } byte[] d = tLVInputStream.d(); if (d.length != 1) { StringBuilder sb2 = new StringBuilder("Number of content specific fields should be encoded in single byte, found "); sb2.append(Arrays.toString(d)); throw new IllegalArgumentException(sb2.toString()); } byte b3 = d[0]; for (int i2 = 0; i2 < (b3 & UnsignedBytes.MAX_VALUE); i2++) { int b4 = tLVInputStream.b(); if (b4 != 24335) { StringBuilder sb3 = new StringBuilder("Expected "); sb3.append(Integer.toHexString(OTHER_NAME_TAG)); sb3.append(", found "); sb3.append(Integer.toHexString(b4)); throw new IllegalArgumentException(sb3.toString()); } tLVInputStream.c(); parseOtherName(tLVInputStream.d()); } return; } if (b != i) { StringBuilder sb4 = new StringBuilder("Expected "); sb4.append(Integer.toHexString(i)); sb4.append(", but found "); sb4.append(Integer.toHexString(b)); throw new IllegalArgumentException(sb4.toString()); } tLVInputStream.c(); byte[] d2 = tLVInputStream.d(); if (b == 24363) { parseFullDateOfBirth(d2); return; } if (b != 24386) { switch (b) { case FULL_NAME_TAG /* 24334 */: parseNameOfHolder(d2); return; case OTHER_NAME_TAG /* 24335 */: parseOtherName(d2); return; case PERSONAL_NUMBER_TAG /* 24336 */: parsePersonalNumber(d2); return; case PLACE_OF_BIRTH_TAG /* 24337 */: parsePlaceOfBirth(d2); return; case TELEPHONE_TAG /* 24338 */: parseTelephone(d2); return; case PROFESSION_TAG /* 24339 */: parseProfession(d2); return; case TITLE_TAG /* 24340 */: parseTitle(d2); return; case PERSONAL_SUMMARY_TAG /* 24341 */: parsePersonalSummary(d2); return; case PROOF_OF_CITIZENSHIP_TAG /* 24342 */: parseProofOfCitizenShip(d2); return; case OTHER_VALID_TD_NUMBERS_TAG /* 24343 */: parseOtherValidTDNumbers(d2); return; case CUSTODY_INFORMATION_TAG /* 24344 */: parseCustodyInformation(d2); return; default: StringBuilder sb5 = new StringBuilder("Unknown field tag in DG11: "); sb5.append(Integer.toHexString(b)); throw new IllegalArgumentException(sb5.toString()); } } parsePermanentAddress(d2); } private void parseCustodyInformation(byte[] bArr) { try { this.custodyInformation = new String(bArr, "UTF-8").trim(); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); this.custodyInformation = new String(bArr).trim(); } } private void parseOtherValidTDNumbers(byte[] bArr) { String trim = new String(bArr).trim(); try { trim = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } this.otherValidTDNumbers = new ArrayList(); StringTokenizer stringTokenizer = new StringTokenizer(trim, UrlTreeKt.configurablePathSegmentPrefix); while (stringTokenizer.hasMoreTokens()) { this.otherValidTDNumbers.add(stringTokenizer.nextToken().trim()); } } private void parsePersonalSummary(byte[] bArr) { try { this.personalSummary = new String(bArr, "UTF-8").trim(); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); this.personalSummary = new String(bArr).trim(); } } private void parseTitle(byte[] bArr) { try { this.title = new String(bArr, "UTF-8").trim(); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); this.title = new String(bArr).trim(); } } private void parseProfession(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } this.profession = str.trim(); } private void parseTelephone(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } this.telephone = str.replace(UrlTreeKt.configurablePathSegmentPrefix, " ").trim(); } private void parsePermanentAddress(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } StringTokenizer stringTokenizer = new StringTokenizer(str, UrlTreeKt.configurablePathSegmentPrefix); this.permanentAddress = new ArrayList(); while (stringTokenizer.hasMoreTokens()) { this.permanentAddress.add(stringTokenizer.nextToken().trim()); } } private void parsePlaceOfBirth(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } StringTokenizer stringTokenizer = new StringTokenizer(str, UrlTreeKt.configurablePathSegmentPrefix); this.placeOfBirth = new ArrayList(); while (stringTokenizer.hasMoreTokens()) { this.placeOfBirth.add(stringTokenizer.nextToken().trim()); } } private void parseFullDateOfBirth(byte[] bArr) { String str; try { if (bArr.length == 4) { str = ghS.c(bArr); } else { String str2 = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); str = str2; } } this.fullDateOfBirth = SDF.parse(str); } catch (ParseException e2) { throw new IllegalArgumentException(e2.toString()); } } private void parseOtherName(byte[] bArr) { synchronized (this) { if (this.otherNames == null) { this.otherNames = new ArrayList(); } try { this.otherNames.add(new String(bArr, "UTF-8").trim()); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); this.otherNames.add(new String(bArr).trim()); } } } private void parsePersonalNumber(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } this.personalNumber = str.trim(); } private void parseNameOfHolder(byte[] bArr) { String str = new String(bArr); try { str = new String(bArr, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger logger = LOGGER; StringBuilder sb = new StringBuilder("Exception: "); sb.append(e.getMessage()); logger.severe(sb.toString()); } this.nameOfHolder = str.trim(); } public List getTagPresenceList() { List list = this.tagPresenceList; if (list != null) { return list; } ArrayList arrayList = new ArrayList(12); this.tagPresenceList = arrayList; if (this.nameOfHolder != null) { arrayList.add(Integer.valueOf(FULL_NAME_TAG)); } List list2 = this.otherNames; if (list2 != null && list2.size() > 0) { this.tagPresenceList.add(Integer.valueOf(OTHER_NAME_TAG)); } if (this.personalNumber != null) { this.tagPresenceList.add(Integer.valueOf(PERSONAL_NUMBER_TAG)); } if (this.fullDateOfBirth != null) { this.tagPresenceList.add(24363); } List list3 = this.placeOfBirth; if (list3 != null && list3.size() > 0) { this.tagPresenceList.add(Integer.valueOf(PLACE_OF_BIRTH_TAG)); } List list4 = this.permanentAddress; if (list4 != null && list4.size() > 0) { this.tagPresenceList.add(24386); } if (this.telephone != null) { this.tagPresenceList.add(Integer.valueOf(TELEPHONE_TAG)); } if (this.profession != null) { this.tagPresenceList.add(Integer.valueOf(PROFESSION_TAG)); } if (this.title != null) { this.tagPresenceList.add(Integer.valueOf(TITLE_TAG)); } if (this.personalSummary != null) { this.tagPresenceList.add(Integer.valueOf(PERSONAL_SUMMARY_TAG)); } if (this.proofOfCitizenship != null) { this.tagPresenceList.add(Integer.valueOf(PROOF_OF_CITIZENSHIP_TAG)); } List list5 = this.otherValidTDNumbers; if (list5 != null && list5.size() > 0) { this.tagPresenceList.add(Integer.valueOf(OTHER_VALID_TD_NUMBERS_TAG)); } if (this.custodyInformation != null) { this.tagPresenceList.add(Integer.valueOf(CUSTODY_INFORMATION_TAG)); } return this.tagPresenceList; } public List getOtherNames() { return this.otherNames == null ? new ArrayList() : new ArrayList(this.otherNames); } @Override // org.jmrtd.lds.DataGroup, org.jmrtd.lds.AbstractTaggedLDSFile public String toString() { String obj; StringBuffer stringBuffer = new StringBuffer("DG11File ["); String str = this.nameOfHolder; if (str == null) { str = ""; } stringBuffer.append(str); stringBuffer.append(", "); List list = this.otherNames; String str2 = HttpUrl.PATH_SEGMENT_ENCODE_SET_URI; stringBuffer.append((list == null || list.size() == 0) ? HttpUrl.PATH_SEGMENT_ENCODE_SET_URI : this.otherNames); stringBuffer.append(", "); String str3 = this.personalNumber; if (str3 == null) { str3 = ""; } stringBuffer.append(str3); stringBuffer.append(", "); Date date = this.fullDateOfBirth; stringBuffer.append(date == null ? "" : SDF.format(date)); stringBuffer.append(", "); List list2 = this.placeOfBirth; stringBuffer.append((list2 == null || list2.size() == 0) ? HttpUrl.PATH_SEGMENT_ENCODE_SET_URI : this.placeOfBirth.toString()); stringBuffer.append(", "); List list3 = this.permanentAddress; stringBuffer.append((list3 == null || list3.size() == 0) ? HttpUrl.PATH_SEGMENT_ENCODE_SET_URI : this.permanentAddress.toString()); stringBuffer.append(", "); String str4 = this.telephone; if (str4 == null) { str4 = ""; } stringBuffer.append(str4); stringBuffer.append(", "); String str5 = this.profession; if (str5 == null) { str5 = ""; } stringBuffer.append(str5); stringBuffer.append(", "); String str6 = this.title; if (str6 == null) { str6 = ""; } stringBuffer.append(str6); stringBuffer.append(", "); String str7 = this.personalSummary; if (str7 == null) { str7 = ""; } stringBuffer.append(str7); stringBuffer.append(", "); if (this.proofOfCitizenship == null) { obj = ""; } else { StringBuilder sb = new StringBuilder("image ("); sb.append(this.proofOfCitizenship.length); sb.append(")"); obj = sb.toString(); } stringBuffer.append(obj); stringBuffer.append(", "); List list4 = this.otherValidTDNumbers; if (list4 != null && list4.size() != 0) { str2 = this.otherValidTDNumbers.toString(); } stringBuffer.append(str2); stringBuffer.append(", "); String str8 = this.custodyInformation; stringBuffer.append(str8 != null ? str8 : ""); stringBuffer.append("]"); return stringBuffer.toString(); } public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass().equals(getClass())) { return toString().equals(((DG11File) obj).toString()); } return false; } public int hashCode() { return (toString().hashCode() * 13) + 111; } @Override // org.jmrtd.lds.AbstractTaggedLDSFile public void writeContent(OutputStream outputStream) throws IOException { TLVOutputStream tLVOutputStream = outputStream instanceof TLVOutputStream ? (TLVOutputStream) outputStream : new TLVOutputStream(outputStream); tLVOutputStream.d(92); DataOutputStream dataOutputStream = new DataOutputStream(tLVOutputStream); List tagPresenceList = getTagPresenceList(); Iterator it = tagPresenceList.iterator(); while (it.hasNext()) { dataOutputStream.writeShort(it.next().intValue()); } dataOutputStream.flush(); tLVOutputStream.c(); Iterator it2 = tagPresenceList.iterator(); while (it2.hasNext()) { int intValue = it2.next().intValue(); if (intValue != 24363) { boolean z = true; if (intValue != 24386) { switch (intValue) { case FULL_NAME_TAG /* 24334 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.nameOfHolder.trim().getBytes("UTF-8")); break; case OTHER_NAME_TAG /* 24335 */: if (this.otherNames == null) { this.otherNames = new ArrayList(); } tLVOutputStream.d(160); tLVOutputStream.d(2); tLVOutputStream.write(this.otherNames.size()); tLVOutputStream.c(); for (String str : this.otherNames) { tLVOutputStream.d(OTHER_NAME_TAG); tLVOutputStream.d(str.trim().getBytes("UTF-8")); } tLVOutputStream.c(); break; case PERSONAL_NUMBER_TAG /* 24336 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.personalNumber.trim().getBytes("UTF-8")); break; case PLACE_OF_BIRTH_TAG /* 24337 */: tLVOutputStream.d(intValue); for (String str2 : this.placeOfBirth) { if (str2 != null) { if (z) { z = false; } else { tLVOutputStream.write(60); } tLVOutputStream.write(str2.trim().getBytes("UTF-8")); } } tLVOutputStream.c(); break; case TELEPHONE_TAG /* 24338 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.telephone.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); break; case PROFESSION_TAG /* 24339 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.profession.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); break; case TITLE_TAG /* 24340 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.title.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); break; case PERSONAL_SUMMARY_TAG /* 24341 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.personalSummary.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); break; case PROOF_OF_CITIZENSHIP_TAG /* 24342 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.proofOfCitizenship); break; case OTHER_VALID_TD_NUMBERS_TAG /* 24343 */: tLVOutputStream.d(intValue); for (String str3 : this.otherValidTDNumbers) { if (str3 != null) { if (z) { z = false; } else { tLVOutputStream.write(60); } tLVOutputStream.write(str3.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); } } tLVOutputStream.c(); break; case CUSTODY_INFORMATION_TAG /* 24344 */: tLVOutputStream.d(intValue); tLVOutputStream.d(this.custodyInformation.trim().replace(' ', UrlTreeKt.configurablePathSegmentPrefixChar).getBytes("UTF-8")); break; default: StringBuilder sb = new StringBuilder("Unknown tag in DG11: "); sb.append(Integer.toHexString(intValue)); throw new IllegalStateException(sb.toString()); } } else { tLVOutputStream.d(intValue); for (String str4 : this.permanentAddress) { if (str4 != null) { if (z) { z = false; } else { tLVOutputStream.write(60); } tLVOutputStream.write(str4.trim().getBytes("UTF-8")); } } tLVOutputStream.c(); } } else { tLVOutputStream.d(intValue); tLVOutputStream.d(SDF.format(this.fullDateOfBirth).getBytes("UTF-8")); } } } public String getTitle() { return this.title; } public String getTelephone() { return this.telephone; } public byte[] getProofOfCitizenship() { return this.proofOfCitizenship; } public String getProfession() { return this.profession; } public List getPlaceOfBirth() { return this.placeOfBirth; } public String getPersonalSummary() { return this.personalSummary; } public String getPersonalNumber() { return this.personalNumber; } public List getPermanentAddress() { return this.permanentAddress; } public List getOtherValidTDNumbers() { return this.otherValidTDNumbers; } public String getNameOfHolder() { return this.nameOfHolder; } public Date getFullDateOfBirth() { return this.fullDateOfBirth; } public String getCustodyInformation() { return this.custodyInformation; } private void parseProofOfCitizenShip(byte[] bArr) { this.proofOfCitizenship = bArr; } }