From: Mailing l. f. S. c. m. <jtc...@li...> - 2007-10-29 07:54:54
|
Revision: 2871 http://jtcfrost.svn.sourceforge.net/jtcfrost/?rev=2871&view=rev Author: bback Date: 2007-10-29 00:54:49 -0700 (Mon, 29 Oct 2007) Log Message: ----------- - testfix: strict checking for correct uniqueName. During McKoi migration all internal uniqueNames are ensured to have the correct format. NOTE: you should rerun the migration from the stable version! Modified Paths: -------------- trunk/frost-wot/source/frost/boards/TOF.java trunk/frost-wot/source/frost/crypt/SignMetaData.java trunk/frost-wot/source/frost/fileTransfer/FileListFile.java trunk/frost-wot/source/frost/gui/ManageLocalIdentitiesDialog.java trunk/frost-wot/source/frost/identities/Identity.java trunk/frost-wot/source/frost/identities/LocalIdentity.java trunk/frost-wot/source/frost/messages/AbstractMessageStatusProvider.java trunk/frost-wot/source/frost/messages/PersonAttachment.java trunk/frost-wot/source/frost/storage/IdentitiesXmlDAO.java trunk/frost-wot/source/frost/storage/LocalIdentitiesXmlDAO.java trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java trunk/frost-wot/source/frost/transferlayer/MessageDownloader.java trunk/frost-wot/source/frost/util/migration/Migrate1to2.java Modified: trunk/frost-wot/source/frost/boards/TOF.java =================================================================== --- trunk/frost-wot/source/frost/boards/TOF.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/boards/TOF.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -859,14 +859,15 @@ return true; } - //If the message is not signed and contains a @ character in the from field, we block it. - if (message.isMessageStatusOLD() && message.getFromName().indexOf('@') > -1) { - // FIXME: here we fix a problem with older frosts: a message is sent anonymously, - // but the sender is a unique name. We remove the '@' to avoid confusion - // -> this solves the problem that a new msg is indicated, but not shown - message.setFromName(message.getFromName().replace('@','_')); - // return false; // we would block this message - } + // Now fixed during migration from McKoi +// //If the message is not signed and contains a @ character in the from field, we block it. +// if (message.isMessageStatusOLD() && message.getFromName().indexOf('@') > -1) { +// // FIXME: here we fix a problem with older frosts: a message is sent anonymously, +// // but the sender is a unique name. We remove the '@' to avoid confusion +// // -> this solves the problem that a new msg is indicated, but not shown +// message.setFromName(message.getFromName().replace('@','_')); +// // return false; // we would block this message +// } // Block by subject (and rest of the header) if ( blockMsgSubject ) { Modified: trunk/frost-wot/source/frost/crypt/SignMetaData.java =================================================================== --- trunk/frost-wot/source/frost/crypt/SignMetaData.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/crypt/SignMetaData.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -56,7 +56,7 @@ * Represents a metadata of something about to be sent. * Computes signature of plaintext. */ - public SignMetaData(byte[] plaintext, LocalIdentity myId) { + public SignMetaData(final byte[] plaintext, final LocalIdentity myId) { this.person = myId; sig = Core.getCrypto().detachedSign(plaintext, myId.getPrivateKey()); } @@ -64,16 +64,16 @@ /** * Metadata of something that was received. */ - public SignMetaData(byte [] metadata) throws Throwable { + public SignMetaData(final byte [] metadata) throws Throwable { - Document d = XMLTools.parseXmlContent(metadata, false); - Element el = d.getDocumentElement(); + final Document d = XMLTools.parseXmlContent(metadata, false); + final Element el = d.getDocumentElement(); if( el.getTagName().equals("FrostMetaData") == false ) { throw new Exception("This is not FrostMetaData XML file."); } try { loadXMLElement(el); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Exception thrown in constructor", e); throw e; } @@ -85,10 +85,10 @@ * @param plaintext the plaintext to be verified * @param el the xml element to populate from */ - public SignMetaData(Element el) throws SAXException { + public SignMetaData(final Element el) throws SAXException { try { loadXMLElement(el); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Exception thrown in constructor", e); throw e; } @@ -97,12 +97,13 @@ /* (non-Javadoc) * @see frost.XMLizable#getXMLElement(org.w3c.dom.Document) */ - public Element getXMLElement(Document container) { + @Override + public Element getXMLElement(final Document container) { - Element el = super.getXMLElement(container); - - Element _sig = container.createElement("sig"); - CDATASection cdata = container.createCDATASection(sig); + final Element el = super.getXMLElement(container); + + final Element _sig = container.createElement("sig"); + final CDATASection cdata = container.createCDATASection(sig); _sig.appendChild(cdata); el.appendChild(_sig); @@ -112,17 +113,17 @@ /* (non-Javadoc) * @see frost.XMLizable#loadXMLElement(org.w3c.dom.Element) */ - public void loadXMLElement(Element e) throws SAXException { + public void loadXMLElement(final Element e) throws SAXException { // New Frosts send "Identity" and "MyIdentity", old Frosts only "MyIdentity" - List tags = XMLTools.getChildElementsByTagName(e, "Identity"); + List<Element> tags = XMLTools.getChildElementsByTagName(e, "Identity"); if( tags.size() == 0 ) { // fallback to old format tags = XMLTools.getChildElementsByTagName(e, "MyIdentity"); } - - Element _person = (Element) tags.iterator().next(); - person = new Identity(_person); + + final Element _person = tags.iterator().next(); + person = Identity.createIdentityFromXmlElement(_person); sig = XMLTools.getChildElementsCDATAValue(e, "sig"); assert person!=null && sig!=null; @@ -138,6 +139,7 @@ /* (non-Javadoc) * @see frost.crypt.MetaData#getType() */ + @Override public int getType() { return MetaData.SIGN; } Modified: trunk/frost-wot/source/frost/fileTransfer/FileListFile.java =================================================================== --- trunk/frost-wot/source/frost/fileTransfer/FileListFile.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/fileTransfer/FileListFile.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -32,9 +32,9 @@ /** * Signs and writes file list files into an XML file. * Reads and validates file list files from an XML file. - * + * * XML format: - * + * * <FrostFileListFile> * <timestamp>...</timestamp> * <Identity>....</Identity> @@ -47,77 +47,77 @@ public class FileListFile { private static final Logger logger = Logger.getLogger(FileListFile.class.getName()); - + private static final String TAG_FrostFileListFile = "FrostFileListFile"; private static final String TAG_timestamp = "timestamp"; private static final String TAG_sign = "sign"; private static final String TAG_File = "File"; private static final String TAG_files = "files"; private static final String TAG_Identity = "Identity"; - + /** * sign content and create an xml file * @param files List of ... objects * @param targetFile target file */ - public static boolean writeFileListFile(FileListFileContent content, File targetFile) { + public static boolean writeFileListFile(final FileListFileContent content, final File targetFile) { - Document doc = XMLTools.createDomDocument(); + final Document doc = XMLTools.createDomDocument(); if( doc == null ) { logger.severe("Error - writeFileListFile: factory could'nt create XML Document."); return false; } - Element rootElement = doc.createElement(TAG_FrostFileListFile); + final Element rootElement = doc.createElement(TAG_FrostFileListFile); doc.appendChild(rootElement); { - Element timeStampElement = doc.createElement(TAG_timestamp); - Text timeStampText = doc.createTextNode( Long.toString(content.getTimestamp()) ); + final Element timeStampElement = doc.createElement(TAG_timestamp); + final Text timeStampText = doc.createTextNode( Long.toString(content.getTimestamp()) ); timeStampElement.appendChild(timeStampText); rootElement.appendChild( timeStampElement ); } { - Element _sharer = ((Identity)content.getSendOwner()).getXMLElement(doc); + final Element _sharer = ((Identity)content.getSendOwner()).getXMLElement(doc); rootElement.appendChild(_sharer); } { - String signContent = getSignableContent( - content.getFileList(), + final String signContent = getSignableContent( + content.getFileList(), content.getSendOwner().getUniqueName(), content.getTimestamp()); - String sig = Core.getCrypto().detachedSign(signContent, content.getSendOwner().getPrivateKey()); + final String sig = Core.getCrypto().detachedSign(signContent, content.getSendOwner().getPrivateKey()); if( sig == null ) { return false; } - - Element element = doc.createElement(TAG_sign); - CDATASection cdata = doc.createCDATASection(sig); + + final Element element = doc.createElement(TAG_sign); + final CDATASection cdata = doc.createCDATASection(sig); element.appendChild(cdata); rootElement.appendChild(element); } { - Element filesElement = doc.createElement(TAG_files); - + final Element filesElement = doc.createElement(TAG_files); + // Iterate through set of files and add them all - for( SharedFileXmlFile current : content.getFileList() ) { - Element currentElement = current.getXMLElement(doc); + for( final SharedFileXmlFile current : content.getFileList() ) { + final Element currentElement = current.getXMLElement(doc); filesElement.appendChild(currentElement); } - + rootElement.appendChild(filesElement); - } + } boolean writeOK = false; try { writeOK = XMLTools.writeXmlFile(doc, targetFile); - } catch(Throwable t) { + } catch(final Throwable t) { logger.log(Level.SEVERE, "Exception in writeFileListFile/writeXmlFile", t); } - + // compress file if running on 0.5 if( writeOK && FcpHandler.isFreenet05() ) { - File tmp = new File(targetFile.getPath() + ".flftmp"); + final File tmp = new File(targetFile.getPath() + ".flftmp"); if( !FileAccess.compressFileGZip(targetFile, tmp) ) { return false; // error, already logged } @@ -130,17 +130,17 @@ return writeOK; } - + /** * @return content if file is read and signature is valid, otherwise null */ - public static FileListFileContent readFileListFile(File sourceFile) { + public static FileListFileContent readFileListFile(final File sourceFile) { if( !sourceFile.isFile() || !(sourceFile.length() > 0) ) { return null; - } + } // decompress file if running on 0.5 if( FcpHandler.isFreenet05() ) { - File tmp = new File(sourceFile.getPath() + ".flftmp"); + final File tmp = new File(sourceFile.getPath() + ".flftmp"); if( !FileAccess.decompressFileGZip(sourceFile, tmp) ) { return null; // error, already logged } @@ -153,7 +153,7 @@ Document d = null; try { d = XMLTools.parseXmlFile(sourceFile.getPath(), false); - } catch (Throwable t) { + } catch (final Throwable t) { logger.log(Level.SEVERE, "Exception during XML parsing", t); return null; } @@ -162,37 +162,37 @@ logger.log(Level.SEVERE, "Could'nt parse the file"); return null; } - - Element rootNode = d.getDocumentElement(); + final Element rootNode = d.getDocumentElement(); + if( rootNode.getTagName().equals(TAG_FrostFileListFile) == false ) { logger.severe("Error: xml file does not contain the root tag '"+TAG_FrostFileListFile+"'"); return null; } - - String timeStampStr = XMLTools.getChildElementsTextValue(rootNode, TAG_timestamp); + + final String timeStampStr = XMLTools.getChildElementsTextValue(rootNode, TAG_timestamp); if( timeStampStr == null ) { logger.severe("Error: xml file does not contain the tag '"+TAG_timestamp+"'"); return null; } - long timestamp = Long.parseLong(timeStampStr); - - String signature = XMLTools.getChildElementsCDATAValue(rootNode, TAG_sign); + final long timestamp = Long.parseLong(timeStampStr); + + final String signature = XMLTools.getChildElementsCDATAValue(rootNode, TAG_sign); if( signature == null ) { logger.severe("Error: xml file does not contain the tag '"+TAG_sign+"'"); return null; } - + Element identityNode = null; Element filesNode = null; - { + { List<Element> nodelist = XMLTools.getChildElementsByTagName(rootNode, TAG_Identity); if( nodelist.size() != 1 ) { logger.severe("Error: xml files must contain exactly one element '"+TAG_Identity+"'"); return null; } - identityNode = (Element)nodelist.get(0); - + identityNode = nodelist.get(0); + nodelist = XMLTools.getChildElementsByTagName(rootNode, TAG_files); if( nodelist.size() != 1 ) { logger.severe("Error: xml files must contain exactly one element '"+TAG_files+"'"); @@ -200,12 +200,12 @@ } filesNode = nodelist.get(0); } - - LinkedList<SharedFileXmlFile> files = new LinkedList<SharedFileXmlFile>(); - { - List<Element> _files = XMLTools.getChildElementsByTagName(filesNode, TAG_File); - for( Element el : _files ) { - SharedFileXmlFile file = SharedFileXmlFile.getInstance(el); + + final LinkedList<SharedFileXmlFile> files = new LinkedList<SharedFileXmlFile>(); + { + final List<Element> _files = XMLTools.getChildElementsByTagName(filesNode, TAG_File); + for( final Element el : _files ) { + final SharedFileXmlFile file = SharedFileXmlFile.getInstance(el); if( file == null ) { logger.severe("Error: shared files xml parsing failed, most likely the signature verification will fail!"); continue; @@ -214,20 +214,24 @@ } } - Identity owner = new Identity(identityNode); - - String signContent = getSignableContent(files, owner.getUniqueName(), timestamp); + final Identity owner = Identity.createIdentityFromXmlElement(identityNode); + if( owner == null ) { + logger.severe("Error: invalid identity information"); + return null; + } + + final String signContent = getSignableContent(files, owner.getUniqueName(), timestamp); boolean sigIsValid = Core.getCrypto().detachedVerify(signContent, owner.getPublicKey(), signature); if( !sigIsValid ) { logger.severe("Error: invalid file signature from owner "+owner.getUniqueName()); return null; } - + // check each file for validity - for(Iterator<SharedFileXmlFile> i=files.iterator(); i.hasNext(); ) { - SharedFileXmlFile file = i.next(); + for(final Iterator<SharedFileXmlFile> i=files.iterator(); i.hasNext(); ) { + final SharedFileXmlFile file = i.next(); if( !file.isSharedFileValid() ) { - String txt = "Shared file is invalid (missing fields or wrong contents):"+ + final String txt = "Shared file is invalid (missing fields or wrong contents):"+ "\n size="+file.getSize()+ "\n sha="+file.getSha()+ "\n name="+file.getFilename()+ @@ -236,22 +240,21 @@ i.remove(); } } - + // all is valid - FileListFileContent content = new FileListFileContent(timestamp, owner, files); + final FileListFileContent content = new FileListFileContent(timestamp, owner, files); return content; } - - private static String getSignableContent(LinkedList<SharedFileXmlFile> files, String owner, long timestamp) { - StringBuilder signContent = new StringBuilder(); + + private static String getSignableContent(final LinkedList<SharedFileXmlFile> files, final String owner, final long timestamp) { + final StringBuilder signContent = new StringBuilder(); signContent.append(owner); signContent.append(timestamp); - for(Iterator<SharedFileXmlFile> i = files.iterator(); i.hasNext(); ) { - SharedFileXmlFile sfo = i.next(); + for( final SharedFileXmlFile sfo : files ) { signContent.append( sfo.getSha() ); signContent.append( sfo.getFilename() ); signContent.append( sfo.getSize().toString() ); - + if( sfo.getKey() != null ) { signContent.append( sfo.getKey() ); } Modified: trunk/frost-wot/source/frost/gui/ManageLocalIdentitiesDialog.java =================================================================== --- trunk/frost-wot/source/frost/gui/ManageLocalIdentitiesDialog.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/gui/ManageLocalIdentitiesDialog.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -363,7 +363,7 @@ final Element myself = XMLTools.getChildElementsByTagName(rootEl, "MyIdentity").get(0); LocalIdentity myId = null; if( myself != null ) { - myId = new LocalIdentity(myself); + myId = LocalIdentity.createLocalIdentityFromXmlElement(myself); } return myId; } Modified: trunk/frost-wot/source/frost/identities/Identity.java =================================================================== --- trunk/frost-wot/source/frost/identities/Identity.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/identities/Identity.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -62,7 +62,7 @@ //if this was C++ LocalIdentity wouldn't work //fortunately we have virtual construction so loadXMLElement will be called //for the inheriting class ;-) - public Identity(final Element el) { + protected Identity(final Element el) throws Exception { try { loadXMLElement(el); } catch (final SAXException e) { @@ -73,15 +73,9 @@ /** * we use this constructor whenever we have all the info */ - public Identity(final String name, final String key) { + protected Identity(final String name, final String key) { this.publicKey = key; - if( name.indexOf("@") != -1 ) { - this.uniqueName = name; - } else { - this.uniqueName = name + "@" + Core.getCrypto().digest(getPublicKey()); - } - - uniqueName = Mixed.makeFilename(uniqueName); + this.uniqueName = name; } /** @@ -108,6 +102,54 @@ updateStateString(); } + /** + * Create a new Identity from the specified uniqueName and publicKey. + * If uniqueName does not contain an '@', this method creates a new digest + * for the publicKey and appens it to the uniqueName. + * Finally Mixed.makeFilename() is called for the uniqueName. + */ + protected Identity(String name, final String key, final boolean createNew) { + if( name.indexOf("@") < 0 ) { + name = name + "@" + Core.getCrypto().digest(key); + } + name = Mixed.makeFilename(name); + + this.publicKey = key; + this.uniqueName = name; + } + + //////////////////////////////////////////////////////////////////// + // FACTORY METHODS ///////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + + /** + * Create a new Identity from the specified uniqueName and publicKey. + * Does not convert the specified uniqueName using Mixed.makeFilename() ! + * + * @return null if the Identity cannot be created + */ + public static Identity createIdentityFromExactStrings(final String name, final String key) { + return new Identity(name, key); + } + + /** + * Create a new Identity, read from the specified XML element. + * Calls Mixed.makeFilename() on read uniqueName. + * + * @param el the XML element containing the Identity information + * @return the new Identity, or null if Identity cannot be created (invalid input) + */ + public static Identity createIdentityFromXmlElement(final Element el) { + try { + return new Identity(el); + } catch (final Exception e) { + return null; + } + } + + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + @Override public boolean recursiveLoading() { return false; @@ -242,6 +284,10 @@ return uniqueName; } + public void correctUniqueName() { + uniqueName = Mixed.makeFilename(uniqueName); + } + // dont't store BoardAttachment with pubKey=SSK@... public static boolean isForbiddenBoardAttachment(final BoardAttachment ba) { if( ba != null && Modified: trunk/frost-wot/source/frost/identities/LocalIdentity.java =================================================================== --- trunk/frost-wot/source/frost/identities/LocalIdentity.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/identities/LocalIdentity.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -36,7 +36,8 @@ public LocalIdentity() {} - public Element getXMLElement(Document doc) { + @Override + public Element getXMLElement(final Document doc) { // external element, "Identity" return super.getXMLElement(doc); } @@ -44,60 +45,88 @@ /** * Appends the private key! */ - public Element getExportXMLElement(Document doc) { + @Override + public Element getExportXMLElement(final Document doc) { // have to copy all children, no Element.rename()unfortunately - Element el = super.getXMLElement(doc); - Element el2 = doc.createElement("MyIdentity"); - NodeList list = el.getChildNodes(); + final Element el = super.getXMLElement(doc); + final Element el2 = doc.createElement("MyIdentity"); + final NodeList list = el.getChildNodes(); while(list.getLength() > 0) { el2.appendChild(list.item(0)); // removes Node from el } { - Element element = doc.createElement("privKey"); - CDATASection cdata = doc.createCDATASection(getPrivateKey()); + final Element element = doc.createElement("privKey"); + final CDATASection cdata = doc.createCDATASection(getPrivateKey()); element.appendChild( cdata ); el2.appendChild( element ); } if( getSignature() != null ) { - Element element = doc.createElement("signature"); - CDATASection cdata = doc.createCDATASection(getSignature()); + final Element element = doc.createElement("signature"); + final CDATASection cdata = doc.createCDATASection(getSignature()); element.appendChild( cdata ); el2.appendChild( element ); } - + return el2; } - public void loadXMLElement(Element el) throws SAXException { + @Override + public void loadXMLElement(final Element el) throws SAXException { super.loadXMLElement(el); privateKey = XMLTools.getChildElementsCDATAValue(el, "privKey"); signature = XMLTools.getChildElementsCDATAValue(el, "signature"); } - public LocalIdentity(String name, String[] keys) { - super(name, keys[1]); - privateKey=keys[0]; + /** + * Creates a new Identity, adds digest to name. + */ + protected LocalIdentity(final String name, final String key) { + super(name, key, true); } - - public LocalIdentity(String uname, String pubKey, String prvKey, String sign) { - super(uname, pubKey); + + protected LocalIdentity(final String name, final String[] keys) { + this(name, keys[1]); + this.privateKey = keys[0]; + } + + /** + * Only used for migration. + */ + public LocalIdentity(final String uname, final String pubKey, final String prvKey, final String sign) { + this(uname, pubKey); privateKey = prvKey; signature = sign; } - public LocalIdentity(Element el) { + protected LocalIdentity(final Element el) throws Exception { // finally calls loadXMLElement of this class! super(el); } + /** + * Create a new Identity, read from the specified XML element. + * Calls Mixed.makeFilename() on read uniqueName. + * + * @param el the XML element containing the Identity information + * @return the new Identity, or null if Identity cannot be created (invalid input) + */ + public static LocalIdentity createLocalIdentityFromXmlElement(final Element el) { + try { + return new LocalIdentity(el); + } catch (final Exception e) { + return null; + } + } + + /** * constructor that creates an RSA Keypair */ - public LocalIdentity(String name) { + public LocalIdentity(final String name) { this(name, Core.getCrypto().generateKeys()); // generateOwnBoard(); // TODO: generate other than SSK } - + // void generateOwnBoard() { // if( board == null ) { // FcpConnection connection = FcpFactory.getFcpConnectionInstance(); @@ -120,31 +149,35 @@ public String getPrivateKey() { return privateKey; } - + /** * @return the signature the user entered for this identity. */ public String getSignature() { return signature; } - public void setSignature(String s) { + public void setSignature(final String s) { signature = s; updateIdentitiesStorage(); } + @Override public boolean isGOOD() { return true; } + @Override public boolean isCHECK() { return false; } + @Override public boolean isOBSERVE() { return false; } + @Override public boolean isBAD() { return false; } - + public long getLastFilesSharedMillis() { return lastFilesSharedMillis; } @@ -152,7 +185,7 @@ lastFilesSharedMillis = System.currentTimeMillis(); updateIdentitiesStorage(); } - public void setLastFilesSharedMillis(long l) { + public void setLastFilesSharedMillis(final long l) { lastFilesSharedMillis = l; modify(); updateIdentitiesStorage(); Modified: trunk/frost-wot/source/frost/messages/AbstractMessageStatusProvider.java =================================================================== --- trunk/frost-wot/source/frost/messages/AbstractMessageStatusProvider.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/messages/AbstractMessageStatusProvider.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -32,7 +32,7 @@ private static final int xOBSERVE = 4; private static final int xTAMPERED = 5; private static final int xOLD = 6; - + private static String[] messageStateStrings = { "*err*", "GOOD", @@ -53,10 +53,10 @@ private static final String SIGNATURESTATUS_TAMPERED_STR = "TAMPERED"; // wrong signature private static final String SIGNATURESTATUS_OLD_STR = "OLD"; // no signature private static final String SIGNATURESTATUS_VERIFIED_STR = "VERIFIED"; // signature was OK - + private boolean isFromIdentityInitialized = false; private Identity fromIdentity = null; - + private String fromName = ""; private String publicKey = ""; @@ -66,10 +66,10 @@ if( isFromIdentityInitialized == false ) { // set Identity for FROM, or null fromIdentity = Core.getIdentities().getIdentity(getFromName()); - // if identity was NOT found, add it. maybe it was deleted by the user, + // if identity was NOT found, add it. maybe it was deleted by the user, // but we still have a msg from this identity if( fromIdentity == null && getPublicKey() != null && getPublicKey().length() > 0 ) { - fromIdentity = new Identity(getFromName(), getPublicKey()); + fromIdentity = Identity.createIdentityFromExactStrings(getFromName(), getPublicKey()); fromIdentity.setCHECK(); Core.getIdentities().addIdentity(fromIdentity); } @@ -81,16 +81,16 @@ public String getFromName() { return fromName; } - public void setFromName(String from) { + public void setFromName(final String from) { this.fromName = from; } - + /** * Converts the signature status string contained in local XML message file * into the internal constant. * Only used for imports! */ - public boolean setSignatureStatusFromString(String sigStatusStr) { + public boolean setSignatureStatusFromString(final String sigStatusStr) { if( sigStatusStr.equalsIgnoreCase(SIGNATURESTATUS_VERIFIED_STR) ) { setSignatureStatusVERIFIED_V1(); return true; @@ -103,13 +103,14 @@ } return false; } - - private int getMessageStatus(Identity fromIdent) { + + private int getMessageStatus(final Identity fromIdent) { if( isSignatureStatusVERIFIED() ) { // get state of user if( fromIdent == null ) { return xOLD; } + if( fromIdent.isCHECK() ) { return xCHECK; } @@ -138,23 +139,23 @@ } public String getMessageStatusString() { - Identity i = getFromIdentity(); + final Identity i = getFromIdentity(); if (i instanceof LocalIdentity) { return "ME"; } else { return messageStateStrings[getMessageStatus(i)]; } } - + public boolean isMessageFromME() { - Identity i = getFromIdentity(); + final Identity i = getFromIdentity(); if (i instanceof LocalIdentity) { return true; } else { return false; } } - + public boolean isMessageStatusGOOD() { return (getMessageStatus() == xGOOD ); } @@ -173,23 +174,23 @@ public boolean isMessageStatusOLD() { return (getMessageStatus() == xOLD ); } - + public boolean isSignatureStatusVERIFIED() { if( getSignatureStatus() == SIGNATURESTATUS_VERIFIED || getSignatureStatus() == SIGNATURESTATUS_VERIFIED_V1 || getSignatureStatus() == SIGNATURESTATUS_VERIFIED_V2 - ) + ) { return true; } return false; } // utility method - public static boolean isSignatureStatusVERIFIED(int sigstat) { + public static boolean isSignatureStatusVERIFIED(final int sigstat) { if( sigstat == SIGNATURESTATUS_VERIFIED || sigstat == SIGNATURESTATUS_VERIFIED_V1 || sigstat == SIGNATURESTATUS_VERIFIED_V2 - ) + ) { return true; } @@ -207,7 +208,7 @@ public boolean isSignatureStatusTAMPERED() { return (getSignatureStatus() == SIGNATURESTATUS_TAMPERED); } - + public void setSignatureStatusVERIFIED_V1() { signatureStatus = SIGNATURESTATUS_VERIFIED_V1; } @@ -220,18 +221,18 @@ public void setSignatureStatusTAMPERED() { signatureStatus = SIGNATURESTATUS_TAMPERED; } - + public int getSignatureStatus() { return signatureStatus; } - public void setSignatureStatus(int s) { + public void setSignatureStatus(final int s) { signatureStatus = s; } - + public String getPublicKey() { return publicKey; } - public void setPublicKey(String pk) { + public void setPublicKey(final String pk) { publicKey = pk; } } Modified: trunk/frost-wot/source/frost/messages/PersonAttachment.java =================================================================== --- trunk/frost-wot/source/frost/messages/PersonAttachment.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/messages/PersonAttachment.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -18,9 +18,9 @@ */ package frost.messages; import org.w3c.dom.*; -import org.xml.sax.SAXException; +import org.xml.sax.*; -import frost.identities.Identity; +import frost.identities.*; import frost.util.*; public class PersonAttachment extends Attachment { @@ -31,23 +31,23 @@ * @param e * @throws SAXException */ - public PersonAttachment(Element e) throws SAXException { + public PersonAttachment(final Element e) throws SAXException { loadXMLElement(e); } /** * @param newIdentity */ - public PersonAttachment(Identity newIdentity) { + public PersonAttachment(final Identity newIdentity) { identity = newIdentity; } - /* + /* * @see java.lang.Comparable#compareTo(java.lang.Object) */ - public int compareTo(Object o) { - String myKey = identity.getPublicKey(); - String otherKey = ((PersonAttachment) o).getIdentity().getPublicKey(); + public int compareTo(final Object o) { + final String myKey = identity.getPublicKey(); + final String otherKey = ((PersonAttachment) o).getIdentity().getPublicKey(); return myKey.compareTo(otherKey); } @@ -57,19 +57,20 @@ public Identity getIdentity() { return identity; } - + /* (non-Javadoc) * @see frost.messages.Attachment#getType() */ - public int getType() { + @Override + public int getType() { return Attachment.PERSON; } /* (non-Javadoc) * @see frost.XMLizable#getXMLElement(org.w3c.dom.Document) */ - public Element getXMLElement(Document container) { - Element el = container.createElement("Attachment"); + public Element getXMLElement(final Document container) { + final Element el = container.createElement("Attachment"); el.setAttribute("type", "person"); el.appendChild(identity.getXMLElement(container)); return el; @@ -78,9 +79,9 @@ /* (non-Javadoc) * @see frost.XMLizable#loadXMLElement(org.w3c.dom.Element) */ - public void loadXMLElement(Element e) throws SAXException { - Element _person = - (Element) XMLTools.getChildElementsByTagName(e, "Identity").iterator().next(); - identity = new Identity(_person); + public void loadXMLElement(final Element e) throws SAXException { + final Element _person = + XMLTools.getChildElementsByTagName(e, "Identity").iterator().next(); + identity = Identity.createIdentityFromXmlElement(_person); } } Modified: trunk/frost-wot/source/frost/storage/IdentitiesXmlDAO.java =================================================================== --- trunk/frost-wot/source/frost/storage/IdentitiesXmlDAO.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/storage/IdentitiesXmlDAO.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -35,69 +35,69 @@ /** * Loads good, observe and bad identities from xml file. */ - public static List<Identity> loadIdentities(File file) { - - LinkedList<Identity> identities = new LinkedList<Identity>(); + public static List<Identity> loadIdentities(final File file) { - Document d = XMLTools.parseXmlFile(file, false); - Element rootEl = d.getDocumentElement(); + final LinkedList<Identity> identities = new LinkedList<Identity>(); - List lists = XMLTools.getChildElementsByTagName(rootEl, "BuddyList"); - Iterator it = lists.iterator(); + final Document d = XMLTools.parseXmlFile(file, false); + final Element rootEl = d.getDocumentElement(); + final List<Element> lists = XMLTools.getChildElementsByTagName(rootEl, "BuddyList"); + final Iterator<Element> it = lists.iterator(); + while (it.hasNext()) { - Element current = (Element) it.next(); + final Element current = it.next(); if (current.getAttribute("type").equals("friends")) { - BuddyList buddyList = new BuddyList(); + final BuddyList buddyList = new BuddyList(); try { buddyList.loadXMLElement(current); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Error loading good identities", e); } - for(Iterator i = buddyList.getAllValues().iterator(); i.hasNext(); ) { - Identity id = (Identity)i.next(); + for( final Object element : buddyList.getAllValues() ) { + final Identity id = (Identity)element; id.setGOODWithoutUpdate(); identities.add(id); } } else if (current.getAttribute("type").equals("enemies")) { - BuddyList buddyList = new BuddyList(); + final BuddyList buddyList = new BuddyList(); try { buddyList.loadXMLElement(current); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Error loading bad identities", e); } - for(Iterator i = buddyList.getAllValues().iterator(); i.hasNext(); ) { - Identity id = (Identity)i.next(); + for( final Object element : buddyList.getAllValues() ) { + final Identity id = (Identity)element; id.setBADWithoutUpdate(); identities.add(id); } } else if (current.getAttribute("type").equals("neutral")) { - BuddyList buddyList = new BuddyList(); + final BuddyList buddyList = new BuddyList(); try { buddyList.loadXMLElement(current); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Error loading check identities", e); } - for(Iterator i = buddyList.getAllValues().iterator(); i.hasNext(); ) { - Identity id = (Identity)i.next(); + for( final Object element : buddyList.getAllValues() ) { + final Identity id = (Identity)element; id.setCHECKWithoutUpdate(); identities.add(id); } } else if (current.getAttribute("type").equals("observed")) { - BuddyList buddyList = new BuddyList(); + final BuddyList buddyList = new BuddyList(); try { buddyList.loadXMLElement(current); - } catch (SAXException e) { + } catch (final SAXException e) { logger.log(Level.SEVERE, "Error loading observe identities", e); } - for(Iterator i = buddyList.getAllValues().iterator(); i.hasNext(); ) { - Identity id = (Identity)i.next(); + for( final Object element : buddyList.getAllValues() ) { + final Identity id = (Identity)element; id.setOBSERVEWithoutUpdate(); identities.add(id); } } } - + return identities; } @@ -105,16 +105,16 @@ * Returns -1 on error, 0 if no identity is to export and no file was created, * or >0 for exported identity count. */ - public static int saveIdentities(File file, List<Identity> identities) { - - BuddyList friends = new BuddyList(); - BuddyList observed = new BuddyList(); - BuddyList enemies = new BuddyList(); - + public static int saveIdentities(final File file, final List<Identity> identities) { + + final BuddyList friends = new BuddyList(); + final BuddyList observed = new BuddyList(); + final BuddyList enemies = new BuddyList(); + int count = 0; - - for( Iterator i = identities.iterator(); i.hasNext(); ) { - Identity id = (Identity) i.next(); + + for( final Object element : identities ) { + final Identity id = (Identity) element; if( id.isGOOD() ) { friends.add(id); count++; @@ -127,25 +127,25 @@ } // we ignore CHECK ids here! this is the default } - + if( count == 0 ) { // dont create an empty file return count; } - - Document d = XMLTools.createDomDocument(); - Element rootElement = d.createElement("FrostIdentities"); + final Document d = XMLTools.createDomDocument(); + final Element rootElement = d.createElement("FrostIdentities"); + // then friends - Element friendsElement = friends.getXMLElement(d); + final Element friendsElement = friends.getXMLElement(d); friendsElement.setAttribute("type", "friends"); rootElement.appendChild(friendsElement); // then enemies - Element enemiesElement = enemies.getXMLElement(d); + final Element enemiesElement = enemies.getXMLElement(d); enemiesElement.setAttribute("type", "enemies"); rootElement.appendChild(enemiesElement); // then observed - Element observedElement = observed.getXMLElement(d); + final Element observedElement = observed.getXMLElement(d); observedElement.setAttribute("type", "observed"); rootElement.appendChild(observedElement); @@ -175,8 +175,8 @@ * adds a user to the list * returns false if the user exists */ - public synchronized boolean add(Identity user) { - String str = user.getUniqueName(); + public synchronized boolean add(final Identity user) { + final String str = user.getUniqueName(); if (containsKey(str)) { return false; } @@ -185,38 +185,39 @@ return true; } - public boolean containsKey(String key) { - return hashMap.containsKey(Mixed.makeFilename((String) key)); + public boolean containsKey(final String key) { + return hashMap.containsKey(Mixed.makeFilename(key)); } - public synchronized Element getXMLElement(Document doc) { - Element main = doc.createElement("BuddyList"); - Iterator it = hashMap.values().iterator(); + public synchronized Element getXMLElement(final Document doc) { + final Element main = doc.createElement("BuddyList"); + final Iterator<Identity> it = hashMap.values().iterator(); while (it.hasNext()) { - Identity id = (Identity) it.next(); - Element el = id.getExportXMLElement(doc); + final Identity id = it.next(); + final Element el = id.getExportXMLElement(doc); main.appendChild(el); } return main; } - public void loadXMLElement(Element el) throws SAXException { + public void loadXMLElement(final Element el) throws SAXException { if (el == null) { return; } - List l = XMLTools.getChildElementsByTagName(el, "Identity"); - Iterator it = l.iterator(); - while (it.hasNext()) { - add(new Identity((Element) it.next())); + for (final Element idEl : XMLTools.getChildElementsByTagName(el, "Identity") ) { + final Identity id = Identity.createIdentityFromXmlElement( idEl ); + if( id != null ) { + add(id); + } } } - protected Object remove(String key) { + protected Object remove(final String key) { return hashMap.remove(Mixed.makeFilename(key)); } public int size() { return hashMap.size(); } - public Collection getAllValues() { + public Collection<Identity> getAllValues() { return hashMap.values(); } } Modified: trunk/frost-wot/source/frost/storage/LocalIdentitiesXmlDAO.java =================================================================== --- trunk/frost-wot/source/frost/storage/LocalIdentitiesXmlDAO.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/storage/LocalIdentitiesXmlDAO.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -31,28 +31,29 @@ private static final Logger logger = Logger.getLogger(KnownBoardsXmlDAO.class.getName()); - public static List<LocalIdentity> loadLocalidentities(File file) { + public static List<LocalIdentity> loadLocalidentities(final File file) { - LinkedList<LocalIdentity> localIdentities = new LinkedList<LocalIdentity>(); + final LinkedList<LocalIdentity> localIdentities = new LinkedList<LocalIdentity>(); if( file.exists() ) { Document doc = null; try { doc = XMLTools.parseXmlFile(file, false); - } catch (Exception ex) { + } catch (final Exception ex) { logger.log(Level.SEVERE, "Error reading localidentities xml", ex); return localIdentities; } - Element rootNode = doc.getDocumentElement(); + final Element rootNode = doc.getDocumentElement(); if( rootNode.getTagName().equals("FrostLocalIdentities") == false ) { logger.severe("Error - invalid localidentities xml: does not contain the root tag 'FrostLocalIdentities'"); return null; } - - List localIdentitiesElements = XMLTools.getChildElementsByTagName(rootNode, "MyIdentity"); - for( Iterator i = localIdentitiesElements.iterator(); i.hasNext(); ) { - Element lidElement = (Element) i.next(); - LocalIdentity myId = new LocalIdentity(lidElement); - localIdentities.add(myId); + + final List<Element> localIdentitiesElements = XMLTools.getChildElementsByTagName(rootNode, "MyIdentity"); + for( final Element element : localIdentitiesElements ) { + final LocalIdentity myId = LocalIdentity.createLocalIdentityFromXmlElement(element); + if( myId != null ) { + localIdentities.add(myId); + } } } return localIdentities; @@ -61,27 +62,27 @@ /** * ATTN: appends private key! */ - public static boolean saveLocalIdentities(File file, List<LocalIdentity> localIdentities) { - Document doc = XMLTools.createDomDocument(); + public static boolean saveLocalIdentities(final File file, final List<LocalIdentity> localIdentities) { + final Document doc = XMLTools.createDomDocument(); if (doc == null) { logger.severe("Error - saveLocalIdentities: factory couldn't create XML Document."); return false; } - Element rootElement = doc.createElement("FrostLocalIdentities"); + final Element rootElement = doc.createElement("FrostLocalIdentities"); doc.appendChild(rootElement); - Iterator i = localIdentities.iterator(); + final Iterator<LocalIdentity> i = localIdentities.iterator(); while (i.hasNext()) { - LocalIdentity b = (LocalIdentity)i.next(); - Element anAttachment = b.getExportXMLElement(doc); + final LocalIdentity b = i.next(); + final Element anAttachment = b.getExportXMLElement(doc); rootElement.appendChild(anAttachment); } boolean writeOK = false; try { writeOK = XMLTools.writeXmlFile(doc, file.getPath()); - } catch (Throwable ex) { + } catch (final Throwable ex) { logger.log(Level.SEVERE, "Exception while writing localidentities xml:", ex); } if (!writeOK) { Modified: trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java =================================================================== --- trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -74,6 +74,7 @@ if( i != null ) { li.setReceivedMessageCount(i.intValue()); } + li.correctUniqueName(); storageRoot.getLocalIdentities().add( li ); } commit(); @@ -86,6 +87,7 @@ if( i != null ) { li.setReceivedMessageCount(i.intValue()); } + li.correctUniqueName(); storageRoot.getIdentities().add( li ); cnt++; if( cnt%100 == 0 ) { Modified: trunk/frost-wot/source/frost/transferlayer/MessageDownloader.java =================================================================== --- trunk/frost-wot/source/frost/transferlayer/MessageDownloader.java 2007-10-28 15:33:43 UTC (rev 2870) +++ trunk/frost-wot/source/frost/transferlayer/MessageDownloader.java 2007-10-29 07:54:49 UTC (rev 2871) @@ -41,7 +41,7 @@ * @param logInfo info for log output * @return null if unexpected Exception occurred, or results indicating state or error */ - protected static MessageDownloaderResult processDownloadedFile(File tmpFile, FcpResultGet results, String logInfo) { + protected static MessageDownloaderResult processDownloadedFile(final File tmpFile, final FcpResultGet results, final String logInfo) { try { if( FcpHandler.isFreenet05() ) { return processDownloadedFile05(tmpFile, results, logInfo); @@ -51,27 +51,27 @@ logger.severe("Unsupported freenet version, not 0.5 or 0.7"); return null; } - } catch(Throwable t) { + } catch(final Throwable t) { logger.log(Level.SEVERE, "Error processing downloaded message", t); - MessageDownloaderResult mdResult = new MessageDownloaderResult(MessageDownloaderResult.BROKEN_MSG); + final MessageDownloaderResult mdResult = new MessageDownloaderResult(MessageDownloaderResult.BROKEN_MSG); return mdResult; } } - + /** * Tries to download the message, performs all base checkings and decryption. - * + * * @return null if not found, or MessageDownloaderResult if success or error */ public static MessageDownloaderResult downloadMessage( - String downKey, - int targetIndex, - boolean fastDownload, - String logInfo) { - + final String downKey, + final int targetIndex, + final boolean fastDownload, + final String logInfo) { + FcpResultGet results; - File tmpFile = FileAccess.createTempFile("dlMsg_", "-"+targetIndex+".xml.tmp"); - + final File tmpFile = FileAccess.createTempFile("dlMsg_", "-"+targetIndex+".xml.tmp"); + try { results = FcpHandler.inst().getFile( FcpHandler.TYPE_MESSAGE, @@ -81,13 +81,13 @@ false, fastDownload, FcpHandler.MAX_MESSAGE_SIZE_07); - } catch(Throwable t) { + } catch(final Throwable t) { logger.log(Level.SEVERE, "TOFDN: Exception thrown in downloadDate part 1."+logInfo, t); // download failed tmpFile.delete(); return null; } - + if( results == null || results.isSuccess() == false ) { tmpFile.delete(); if(results != null && results.getReturnCode() == 28) { @@ -102,10 +102,10 @@ return null; } } - + return processDownloadedFile(tmpFile, results, logInfo); } - + /** * Process the downloaded file, decrypt, check sign. * @param tmpFile downloaded file @@ -113,15 +113,15 @@ * @param logInfo info for log output * @return null if unexpected Exception occurred, or results indicating state or error */ - protected static MessageDownloaderResult processDownloadedFile05(File tmpFile, FcpResultGet results, String logInfo) { - + protected static MessageDownloaderResult processDownloadedFile05(final File tmpFile, final FcpResultGet results, final String logInfo) { + try { // we downloaded something logger.info("TOFDN: A message was downloaded."+logInfo); - + // either null (unsigned) or signed and maybe encrypted message - byte[] metadata = results.getRawMetadata(); - + final byte[] metadata = results.getRawMetadata(); + if( tmpFile.length() == 0 ) { // Frosts message files do always contain data, so the received content is wrong if( metadata != null && metadata.length > 0 ) { @@ -136,10 +136,10 @@ tmpFile.delete(); return new MessageDownloaderResult(MessageDownloaderResult.BROKEN_MSG); } - + // if no metadata, message wasn't signed if (metadata == null) { - byte[] unzippedXml = FileAccess.readZipFileBinary(tmpFile); + final byte[] unzippedXml = FileAccess.readZipFileBinary(tmpFile); if( unzippedXml == null ) { logger.log(Level.SEVERE, "TOFDN: Unzip of unsigned xml failed."+logInfo); tmpFile.delete(); @@ -147,25 +147,25 @@ } FileAccess.writeFile(unzippedXml, tmpFile); try { - MessageXmlFile currentMsg = new MessageXmlFile(tmpFile); + final MessageXmlFile currentMsg = new MessageXmlFile(tmpFile); currentMsg.setSignatureStatusOLD(); return new MessageDownloaderResult(currentMsg); - } catch (Exception ex) { + } catch (final Exception ex) { logger.log(Level.SEVERE, "TOFDN: Unsigned message is invalid."+logInfo, ex); // file could not be read, mark it invalid not to confuse gui tmpFile.delete(); return new MessageDownloaderResult(MessageDownloaderResult.BROKEN_MSG); } } - + // verify the zipped message MetaData _metaData = null; try { - Document doc = XMLTools.parseXmlContent(metadata, false); + final Document doc = XMLTools.parseXmlContent(metadata, false); if( doc != null ) { // was metadata xml ok? _metaData = MetaData.getInstance( doc.getDocumentElement() ); } - } catch (Throwable t) { + } catch (final Throwable t) { logger.log(Level.SEVERE, "TOFDN: Invalid metadata of signed message"+logInfo, t); _metaData = null; } @@ -173,27 +173,27 @@ // metadata failed, do something logger.log(Level.SEVERE, "TOFDN: Metadata couldn't be read. " + "Offending file saved as badmetadata.xml - send to a dev for analysis."+logInfo); - File badmetadata = new File("badmetadata.xml"); + final File badmetadata = new File("badmetadata.xml"); FileAccess.writeFile(metadata, badmetadata); // don't try this file again tmpFile.delete(); return new MessageDownloaderResult(MessageDownloaderResult.BROKEN_METADATA); } - + if( _metaData.getType() != MetaData.SIGN && _metaData.getType() != MetaData.ENCRYPT ) { logger.severe("TOFDN: Unknown type of metadata."+logInfo); // don't try this file again tmpFile.delete(); return new MessageDownloaderResult(MessageDownloaderResult.BROKEN_METADATA); } - + // now the msg could be signed OR signed and encrypted // first check sign, later decrypt if msg was for me - - SignMetaData metaData = (SignMetaData)_metaData; - + + final SignMetaData metaData = (SignMetaData)_metaData; + //check if we have the owner already on the lists - String _owner = metaData.getPerson().getUniqueName(); + final String _owner = metaData.getPerson().getUniqueName(); Identity owner = Core.getIdentities().getIdentity(_owner); boolean ownerIsNew = false; // if not on any list, use the parsed id and add to our identities list @@ -208,64 +208,64 @@ owner.setCHECK(); ownerIsNew = true; } - + // verify signature - byte[] plaintext = FileAccess.readByteArray(tmpFile); + final byte[] plaintext = FileAccess.readByteArray(tmpFile); boolean sigIsValid = Core.getCrypto().detachedVerify(plaintext, owner.getPublicKey(), metaData.getSig()); - + // now check if msg is encrypted and for me, if yes decrypt the zipped data if (_metaData.getType() == MetaData.ENCRYPT) { - EncryptMetaData encMetaData = (EncryptMetaData)metaData; - + final EncryptMetaData encMetaData = (EncryptMetaData)metaData; + // 1. check if the message is for me if (!Core.getIdentities().isMySelf(encMetaData.getRecipient())) { logger.fine("TOFDN: Encrypted message was not for me."); tmpFile.delete(); return new MessageDownloaderResult(MessageDownloaderResult.MSG_NOT_FOR_ME); } - + // 2. if yes, decrypt the content - LocalIdentity receiverId = Core.getIdentities().getLocalIdentity(encMet... [truncated message content] |