@Test public void testSign() throws MessagingException, SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException, GeneralSecurityException, PasswordException { assertEquals(emails.size()-1, identities.size()); for (Email email: emails) { EmailIdentity identity = identities.get(email); if (identity == null) continue; email.sign(identity, TestUtil.createDummyKeyUpdateHandler()); assertTrue(email.isSignatureValid()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); KeyUpdateHandler keyUpdateHandler = TestUtil.createDummyKeyUpdateHandler(); for (UnencryptedEmailPacket packet: email.createEmailPackets(identity, keyUpdateHandler, null, I2PBotePacket.MAX_DATAGRAM_SIZE)) outputStream.write(packet.getContent()); email = new Email(outputStream.toByteArray()); assertTrue(email.isSignatureValid()); } }
public void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler) throws MessagingException, GeneralSecurityException, PasswordException { removeHeader(SIGNATURE_HEADER); removeHeader(SIGNATURE_VALID_HEADER); CryptoImplementation cryptoImpl = senderIdentity.getCryptoImpl(); PrivateKey privateSigningKey = senderIdentity.getPrivateSigningKey(); byte[] signature = cryptoImpl.sign(toByteArray(), privateSigningKey, keyUpdateHandler); String foldedSignature = foldSignature(cryptoImpl.getId() + "_" + Base64.encode(signature)); setHeader(SIGNATURE_HEADER, foldedSignature); }
Email extends MimeMessage { public void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler) throws MessagingException, GeneralSecurityException, PasswordException { removeHeader(SIGNATURE_HEADER); removeHeader(SIGNATURE_VALID_HEADER); CryptoImplementation cryptoImpl = senderIdentity.getCryptoImpl(); PrivateKey privateSigningKey = senderIdentity.getPrivateSigningKey(); byte[] signature = cryptoImpl.sign(toByteArray(), privateSigningKey, keyUpdateHandler); String foldedSignature = foldSignature(cryptoImpl.getId() + "_" + Base64.encode(signature)); setHeader(SIGNATURE_HEADER, foldedSignature); } }
Email extends MimeMessage { public void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler) throws MessagingException, GeneralSecurityException, PasswordException { removeHeader(SIGNATURE_HEADER); removeHeader(SIGNATURE_VALID_HEADER); CryptoImplementation cryptoImpl = senderIdentity.getCryptoImpl(); PrivateKey privateSigningKey = senderIdentity.getPrivateSigningKey(); byte[] signature = cryptoImpl.sign(toByteArray(), privateSigningKey, keyUpdateHandler); String foldedSignature = foldSignature(cryptoImpl.getId() + "_" + Base64.encode(signature)); setHeader(SIGNATURE_HEADER, foldedSignature); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); }
Email extends MimeMessage { public void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler) throws MessagingException, GeneralSecurityException, PasswordException { removeHeader(SIGNATURE_HEADER); removeHeader(SIGNATURE_VALID_HEADER); CryptoImplementation cryptoImpl = senderIdentity.getCryptoImpl(); PrivateKey privateSigningKey = senderIdentity.getPrivateSigningKey(); byte[] signature = cryptoImpl.sign(toByteArray(), privateSigningKey, keyUpdateHandler); String foldedSignature = foldSignature(cryptoImpl.getId() + "_" + Base64.encode(signature)); setHeader(SIGNATURE_HEADER, foldedSignature); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); void setContent(String text, List<Attachment> attachments); void setMetadata(EmailMetadata metadata); EmailMetadata getMetadata(); boolean isAnonymous(); String getOneFromAddress(); String getOneRecipient(); void setHashCash(HashCash hashCash); @Override void updateHeaders(); void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler); void setSignatureFlag(); void removeSignatureFlag(); boolean isSignatureValid(); void checkAddresses(); static void checkSender(Address address); static void checkRecipient(Address address); Collection<Address> getAllFromAddresses(); Collection<Address> getAllAddresses(boolean includeFrom); Address[] getReplyToAddresses(); String getReplyAddress(Identities identities); Address[] getToAddresses(); Address[] getCCAddresses(); Address[] getBCCAddresses(); void removeBoteSuffixes(); static String removeBoteSuffix(String addr); void setMessageID(String messageIdString); void setMessageID(UniqueId messageId); @Override String getMessageID(); void setRecent(boolean recent); boolean isRecent(); void setUnread(boolean unread); boolean isUnread(); void setCreateTime(Date createTime); boolean isDelivered(); void setReplied(boolean replied); boolean isReplied(); void setDeleted(boolean deleted); boolean isDeleted(); int getDeliveryPercentage(); Date getCreateTime(); @Override Date getReceivedDate(); @Override synchronized void setFlags(Flags flag, boolean set); @Override Flags getFlags(); Collection<UnencryptedEmailPacket> createEmailPackets(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler, String bccToKeep, int maxPacketSize); String getText(); boolean isContainingAttachments(); List<Part> getParts(); @Override String toString(); }
Email extends MimeMessage { public void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler) throws MessagingException, GeneralSecurityException, PasswordException { removeHeader(SIGNATURE_HEADER); removeHeader(SIGNATURE_VALID_HEADER); CryptoImplementation cryptoImpl = senderIdentity.getCryptoImpl(); PrivateKey privateSigningKey = senderIdentity.getPrivateSigningKey(); byte[] signature = cryptoImpl.sign(toByteArray(), privateSigningKey, keyUpdateHandler); String foldedSignature = foldSignature(cryptoImpl.getId() + "_" + Base64.encode(signature)); setHeader(SIGNATURE_HEADER, foldedSignature); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); void setContent(String text, List<Attachment> attachments); void setMetadata(EmailMetadata metadata); EmailMetadata getMetadata(); boolean isAnonymous(); String getOneFromAddress(); String getOneRecipient(); void setHashCash(HashCash hashCash); @Override void updateHeaders(); void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler); void setSignatureFlag(); void removeSignatureFlag(); boolean isSignatureValid(); void checkAddresses(); static void checkSender(Address address); static void checkRecipient(Address address); Collection<Address> getAllFromAddresses(); Collection<Address> getAllAddresses(boolean includeFrom); Address[] getReplyToAddresses(); String getReplyAddress(Identities identities); Address[] getToAddresses(); Address[] getCCAddresses(); Address[] getBCCAddresses(); void removeBoteSuffixes(); static String removeBoteSuffix(String addr); void setMessageID(String messageIdString); void setMessageID(UniqueId messageId); @Override String getMessageID(); void setRecent(boolean recent); boolean isRecent(); void setUnread(boolean unread); boolean isUnread(); void setCreateTime(Date createTime); boolean isDelivered(); void setReplied(boolean replied); boolean isReplied(); void setDeleted(boolean deleted); boolean isDeleted(); int getDeliveryPercentage(); Date getCreateTime(); @Override Date getReceivedDate(); @Override synchronized void setFlags(Flags flag, boolean set); @Override Flags getFlags(); Collection<UnencryptedEmailPacket> createEmailPackets(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler, String bccToKeep, int maxPacketSize); String getText(); boolean isContainingAttachments(); List<Part> getParts(); @Override String toString();  }