Posts

Showing posts with the label Security

Check If A File Exists Locally Using JavaScript Only

Answer : Your question is ambiguous, so there are multiple possible answers depending on what you're really trying to achieve. If you're developping as I'm guessing a desktop application using Titanium, then you can use the FileSystem module's getFile to get the file object, then check if it exists using the exists method. Here's an example taken from the Appcelerator website: var homeDir = Titanium.Filesystem.getUserDirectory(); var mySampleFile = Titanium.Filesystem.getFile(homeDir, 'sample.txt'); if (mySampleFile.exists()) { alert('A file called sample.txt already exists in your home directory.'); ... } Check the getFile method reference documentation And the exists method reference documentation For those who thought that he was asking about an usual Web development situation, then thse are the two answers I'd have given: 1) you want to check if a server-side file exists. In this case you can use an ajax request try...

Android Java.security.cert.CertPathValidatorException: Trust Anchor For Certification Path Not Found

Answer : I am answering to this to give an idea about the scenario and solution as per the android developer site for others benefit. I have solved this using custom trust manager. The problem was with the server certificate, it misses intermediate certificate authority. However with the first flow certificate path is completed somehow and result was successful certificate path validation. There is a solution for this in android developer site. it suggest to use custom trust manager that trusts this server certificate or it suggest to server to include the intermediate CA in the server chain. custom trust manager. source: https://developer.android.com/training/articles/security-ssl.html#UnknownCa // Load CAs from an InputStream // (could be from a resource or ByteArrayInputStream or ...) CertificateFactory cf = CertificateFactory.getInstance("X.509"); // From https://www.washington.edu/itconnect/security/ca/load-der.crt InputStream caInput = new BufferedInputStream...