@Test public void getValidAutocryptHeader__withBrokenBase64__shouldReturnNull() throws Exception { MimeMessage message = parseFromResource("autocrypt/rsa2048-broken-base64.eml"); AutocryptHeader autocryptHeader = autocryptHeaderParser.getValidAutocryptHeader(message); assertNull(autocryptHeader); }
@Nullable AutocryptHeader getValidAutocryptHeader(Message currentMessage) { String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER); ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers); boolean isSingleValidHeader = autocryptHeaders.size() == 1; return isSingleValidHeader ? autocryptHeaders.get(0) : null; }
AutocryptHeaderParser { @Nullable AutocryptHeader getValidAutocryptHeader(Message currentMessage) { String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER); ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers); boolean isSingleValidHeader = autocryptHeaders.size() == 1; return isSingleValidHeader ? autocryptHeaders.get(0) : null; } }
AutocryptHeaderParser { @Nullable AutocryptHeader getValidAutocryptHeader(Message currentMessage) { String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER); ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers); boolean isSingleValidHeader = autocryptHeaders.size() == 1; return isSingleValidHeader ? autocryptHeaders.get(0) : null; } private  AutocryptHeaderParser(); }
AutocryptHeaderParser { @Nullable AutocryptHeader getValidAutocryptHeader(Message currentMessage) { String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER); ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers); boolean isSingleValidHeader = autocryptHeaders.size() == 1; return isSingleValidHeader ? autocryptHeaders.get(0) : null; } private  AutocryptHeaderParser(); static AutocryptHeaderParser getInstance(); }
AutocryptHeaderParser { @Nullable AutocryptHeader getValidAutocryptHeader(Message currentMessage) { String[] headers = currentMessage.getHeader(AutocryptHeader.AUTOCRYPT_HEADER); ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers); boolean isSingleValidHeader = autocryptHeaders.size() == 1; return isSingleValidHeader ? autocryptHeaders.get(0) : null; } private  AutocryptHeaderParser(); static AutocryptHeaderParser getInstance();  }