/** Finds a salt value such that scrypt(nameHash|destination, salt) ends with 10 zero bits */ public static Fingerprint generate(EmailIdentity identity) throws GeneralSecurityException { Hash nameHash = EmailIdentity.calculateHash(identity.getPublicName()); return generate(nameHash, identity); }
private void removeRecipientNames(Message.RecipientType type) throws MessagingException { Address[] recipients = getRecipients(type); if (recipients != null) { removeRecipientNames(recipients); setRecipients(type, recipients); } }
/** * @param emailDestination Determines the DHT key of this Index Packet */ public IndexPacket(EmailDestination emailDestination) { this(emailDestination.getHash()); }
public void add(EmailIdentity identity) throws PasswordException, IOException, GeneralSecurityException { initializeIfNeeded(); if (identities.isEmpty()) identity.setDefaultIdentity(true); identities.add(identity); for (IdentitiesListener listener : identitiesListeners) listener.identityAdded(identity.getKey()); }
public static String getFingerprint(EmailIdentity identity, String localeCode) throws GeneralSecurityException { String[] wordList = I2PBote.getInstance().getWordList(localeCode); Fingerprint fingerprint = identity.getFingerprint(); return fingerprint==null ? null : fingerprint.getWords(wordList); }
@Override public int compare(EmailIdentity identity1, EmailIdentity identity2) { int nameComparison = compareNames(identity1, identity2); if (nameComparison == 0) { // if the names are the same, compare destination keys String key1 = identity1.getKey(); String key2 = identity2.getKey(); return key1.compareTo(key2); } else return nameComparison; }
private int getDestinationIndex(EmailDestination destination) { int destIndex = 0; while (true) { String value = getProperty(PROPERTY_DESTINATION + destIndex); if (value==null || destination.toBase64().equals(value)) return destIndex; destIndex++; } }
/** * Returns the default identity, or <code>null</code> if no default is set. * @throws GeneralSecurityException * @throws IOException */ public EmailIdentity getDefault() throws PasswordException, IOException, GeneralSecurityException { initializeIfNeeded(); if (identities == null) return null; for (EmailIdentity identity: identities) if (identity.isDefaultIdentity()) return identity; return null; }
/** * Sets the default identity. Assumes this <code>Identities</code> already * contains <code>defaultIdentity</code>. * @throws GeneralSecurityException * @throws IOException */ public void setDefault(EmailIdentity defaultIdentity) throws PasswordException, IOException, GeneralSecurityException { initializeIfNeeded(); // clear the old default for (EmailIdentity identity: identities) identity.setDefaultIdentity(false); defaultIdentity.setDefaultIdentity(true); this.defaultIdentity = defaultIdentity; }
public int getDeliveryPercentage() { int numPackets = getNumPackets(); if (numPackets == 0) return 0; else return 100 * getNumDeliveredPackets() / numPackets; }
/** Finds a salt value such that scrypt(nameHash|destination, salt) ends with 10 zero bits */ public static Fingerprint generate(Contact contact) throws GeneralSecurityException { EmailDestination destination = contact.getDestination(); Hash nameHash = EmailIdentity.calculateHash(contact.getName()); return generate(nameHash, destination); }
private void removeBoteSuffixes(Address[] addresses) { for (int i = 0; i < addresses.length; i++) { removeBoteSuffix((InternetAddress) addresses[i]); } }
private void removeRecipientNames(Address[] recipients) { for (int i = 0; i < recipients.length; i++) { removeRecipientName((InternetAddress) recipients[i]); } }
/** * Controls whether the identity should be checked for email when using * the global "Check mail" button. */ public boolean getIncludeInGlobalCheck() { return getBooleanParameter(PARAMETER_INCLUDE_IN_GLOBAL_CHECK_MAIL, DEFAULT_INCLUDE_IN_GLOBAL_CHECK_MAIL); }
/** Checks that the 31th byte of the fingerprint is zero. */ public boolean isValid() throws GeneralSecurityException { return getRawFingerprint()[NUM_FINGERPRINT_BYTES-1] == 0; // only require 8 bits for 0.2.7 compatibility } }
@Override public String toString() { return getKey(); } }
/** * Returns the <code>Part</code>s of the email as a <code>List</code>. * <code>Part</code>s that are only containers are not included.<br/> * The <code>List</code> is sorted in ascending order of depth.<br/> * If this method is invoked more than once, the ordering of the elements * is the same. * @throws IOException * @throws MessagingException */ public List<Part> getParts() throws MessagingException, IOException { return getAllSubparts(this); }
/** * Looks for an Email Destination in a sender address. If no Email Destination * is found, </code>null</code> is returned. * @param address */ public static String extractEmailDestination(String address) { return EmailDestination.extractBase64Dest(address); }
/** * @param name A name chosen by the user who created the directory entry * @param destination */ public Contact(String name, EmailDestination destination) { this.name = name; this.destination = destination; nameHash = EmailIdentity.calculateHash(name); }
/** * Removes everything but the email destination from all recipient fields, * in order to keep local contact names private. * @throws MessagingException */ private void removeRecipientNames() throws MessagingException { removeRecipientNames(RecipientType.TO); removeRecipientNames(RecipientType.CC); removeRecipientNames(RecipientType.BCC); }