use of i2p.bote.email.EmailIdentity in project i2p.i2p-bote by i2p.
the class EmailChecker method checkForMail.
public synchronized void checkForMail(String key) throws PasswordException, IOException, GeneralSecurityException {
if (!isCheckingForMail()) {
previousMailCheckTime = lastMailCheckTime;
lastMailCheckTime = System.currentTimeMillis();
}
EmailIdentity identity = identities.get(key);
if (identity != null)
checkForMail(identity);
}
use of i2p.bote.email.EmailIdentity in project i2p.i2p-bote by i2p.
the class ContactTest method setUp.
@Before
public void setUp() throws Exception {
EmailIdentity identity = new EmailIdentity("0FXoqTc2bakNPiNZWD7rwT4Q465bFnF66yV7p5emCl6s9shuU3pdTBExBgLf7Pn6KswQ2hn8amqJKepFW7RgUYFncf-UXH~IWrD0E3VAR94WVuSzpqK33LA1aS7By4juHOSDDmDTL0sMBESQADS0NLLp7y7nrNUD93loexkO63DF");
identity.setPublicName(contactName);
String text = "Der Friederich, der Friederich,\n" + "Das war ein arger Wüterich!\n" + "Er fing die Fliegen in dem Haus\n" + "Und riß ihnen die Flügel aus.\n" + "Er schlug die Stühl’ und Vögel tot,\n" + "Die Katzen litten große Not.\n" + "Und höre nur, wie bös er war:\n" + "Er peitschte, ach, sein Gretchen gar!\n" + "\n" + "Am Brunnen stand ein großer Hund,\n" + "Trank Wasser dort mit seinem Mund.\n" + "Da mit der Peitsch’ herzu sich schlich\n" + "Der bitterböse Friederich;\n" + "Und schlug den Hund, der heulte sehr,\n" + "Und trat und schlug ihn immer mehr.\n" + "Da biß der Hund ihn in das Bein,\n" + "Recht tief bis in das Blut hinein.\n" + "Der bitterböse Friederich,\n" + "Der schrie und weinte bitterlich.\n" + "Jedoch nach Hause lief der Hund\n" + "Und trug die Peitsche in dem Mund.\n" + "\n" + "Ins Bett muß Friedrich nun hinein,\n" + "Litt vielen Schmerz an seinem Bein;\n" + "Und der Herr Doktor sitzt dabei\n" + "Und gibt ihm bitt’re Arzenei.\n" + "Der Hund an Friedrichs Tischchen saß,\n" + "Wo er den großen Kuchen aß;\n" + "Aß auch die gute Leberwurst\n" + "Und trank den Wein für seinen Durst.\n" + "Die Peitsche hat er mitgebracht\n" + "Und nimmt sie sorglich sehr in acht.\n";
InputStream inputStream = getClass().getResourceAsStream("Struwwelpeter.jpg");
byte[] picture = Util.readBytes(inputStream);
KeyUpdateHandler keyUpdateHandler = TestUtil.createVerifyingKeyUpdateHandler(1);
identity.generateFingerprint();
contact = new Contact(identity, keyUpdateHandler, picture, text, identity.getFingerprint());
}
use of i2p.bote.email.EmailIdentity in project i2p.i2p-bote by i2p.
the class IndexPacketTest method setUp.
@Before
public void setUp() throws Exception {
identity = new EmailIdentity("5LqFf~U3aLbJfbfTVtp7kXLPFoeIFo4l8WTg1Wi52bWoxAYaevVVBtR9AvKqy1YmZHbnOIcu59~2X6wMmi6SveljmvAeTc5YEHvfIRrJhnxqjaC4IczYKXfUdrXfaeVEKMQ~PKuvhINh~EhlJUQne0NZQ~S6QAGfUAu83mMoBTVaz0eoUnAzySxbSf~NpxUoK-H6iULsFekmYfaz-yq8cxPFy62LyylTRMGFFwb9is7E~mFnV6Fa0iGSDJvpFfYV29efVUjxiW9JT5T0HwgdaDB4ssSNr0-hthigJmB7zLXOJ8F1gxi3qCfTX9SiGMrZ9KZsOLc7Qs7Iix3ECqesfGTIs9n5G1qnfZriyc1FZdylCMQcnq5QvTITV-Cil0XrU1csV5CEFYEUGfGdLP1xP2SCZr8KJwOI0xfUnkkVnNPc2y~ZGhqxpHeIcnZCpScW-p81vFvTe5fwvEVWixgk6MlFKYyQku28brQ19Tz5tsIH3tUvl4cqGzLVQUbi3cODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmogzaNWx7p~GTVQxl1JzqcOTyRfELoxqEGS5BowqPe4FNa3Bo-diEcU3k90Cx5MX");
// Make an IndexPacket with 3 entries
emailPacket1 = makeEmailPacket("abc");
emailPacket2 = makeEmailPacket("abcd");
emailPacket3 = makeEmailPacket("abcde");
indexPacket1 = new IndexPacket(identity);
indexPacket1.put(emailPacket1);
indexPacket1.put(emailPacket2);
indexPacket1.put(emailPacket3);
// Make an IndexPacket with 2 entries
emailPacket4 = makeEmailPacket("abcdef");
emailPacket5 = makeEmailPacket("abcdefg");
indexPacket2 = new IndexPacket(identity);
indexPacket2.put(emailPacket4);
indexPacket2.put(emailPacket5);
}
use of i2p.bote.email.EmailIdentity in project i2p.i2p-bote by i2p.
the class GeneralHelper method getOneLocalRecipient.
/**
* Returns the recipient address for an email that has been received by
* the local node.<br/>
* If the email was sent to more than one local Email Destination, one
* of them is returned.<br/>
* If the email does not contain a local Email Destination, a non-local
* recipient is returned.<br/>
* If the email contains no recipients at all, or if an error occurred,
* <code>null</code> is returned.
* @param email
* @throws PasswordException
* @throws GeneralSecurityException
* @throws IOException
*/
public static Address getOneLocalRecipient(Email email) throws PasswordException, IOException, GeneralSecurityException {
Address[] recipients;
try {
recipients = email.getAllRecipients();
} catch (MessagingException e) {
return null;
}
if (recipients == null)
return null;
Identities identities = I2PBote.getInstance().getIdentities();
Iterator<EmailIdentity> iterator = identities.iterator();
if (iterator == null)
return null;
while (iterator.hasNext()) {
EmailDestination localDestination = iterator.next();
String base64Dest = localDestination.toBase64();
for (Address recipient : recipients) if (recipient.toString().contains(base64Dest))
return recipient;
}
if (recipients.length > 0)
return recipients[0];
else
return null;
}
Aggregations