IMAP Folder structures - jakarta-mail

I have to implement an client application that need to sync IMAP messages. But currently IMAP server that store messages are not ready yet and i need to finish my task. So i am using to Gmail for testing my implementation of retrieving IMAP messages.
I simulate what the spec said for the folder structures in Gmail. Creating folder and subfolders.
/Default
/Default/User1/Session1
/Default/User1/Session1/File1
/Default/User1/Session2
/Default/User2/Session1
/Default/User3
Then i use java mail to list out the folders under default.
store.getFolder("Default").list("*");
I loop the folder to print out the folder count and folder name. The returned folder includes all the subfolders of each User like above.
I would like to know is this the way that IMAP server return for the folder list query? all the subfolders under it?

If you use list(*"), yes. If you only want one level use list("%"). This is well explained in the javadocs.

Related

Cannot get Sent or Drafts folder with JavaMail

I'm using JavaMail to get a list of ALL the folders in an IMAPStore:
store.getDefaultFolder().list("*")
This usually works fine with accounts at Gmail, Yahoo etc. However, for some IMAP providers the list method returns only one folder, namely the inbox. Yet, when using the same account via Thunderbird I can also access the account's Sent and Drafts folders. Does anybody have an idea what I'm doing wrong in getting the folders?
PS: Also directly checking for folders like "Sent", "Sent items","Drafts" etc. via
store.getFolder(foldername).exists()
always returns false.
Supplement: These are the properties I use to create the Session (javax.mail.Session) which I get the store from:
props.put("mail.store.protocol","imaps");
props.put("mail.imaps.host","imap.testhost.com");
props.put("mail.imaps.port","993");
props.put("mail.imaps.auth","true");
props.put("mail.imaps.ssl.trust","*");
props.put("mail.imaps.partialfetch","false");

Camel FTP endpoint move to a folder based on date

I have a camel route consuming from an FTP server and storing any files it consumes to a directory with move=.dealtWith. However, the number of files in this .dealtWith directory can quickly become unmanageable for users to view, so I would like to move the file to a .dealtWith/{the_date} directory. Is there a way to specify this functionality in camel without bringing the route down?
Use Camel Simple Expression Language
ftp:url?move=.dealtWith/${date:now:yyyy-MM-dd}/${header.CamelFileName}

nginX custom HTTP authorization , using scripts to decide

i want to protect some files in a folder by requiring passwords for download
however list of users that are allowed to download are on a mysql table with their passwords in md5 format (which means i cannot generate a htpasswd file)
to make it harder i also need to allow some users to download some files and others to download other files without being able to move files (separating files in multiple folders)
so i what i need is some kind of auth api , when there is a request nginx askes a Script (lets say a php script) with parameters of username/password/ip/filename and depending on script's response allow or disallow the download
is this possible?
what i've done so far:
1.looking in the 3rd party modules list http://wiki.nginx.org/3rdPartyModules
where i found a module with PAM but my server is windows
2.googling lots of terms without any results
3.looking at the module development tutorials http://www.evanmiller.org/nginx-modules-guide.html
i'm not really good at C so a pre made module for windows that bounces the request to a script (without proxy-ing the download through it) is the best if not some pointers to how should i make a module that meets my requirements is appreciated .
You can use the http_auth_request module.
p.s. Do you actually know that nginx for windows is not production ready?

only logged in users can play audio from our server

We have made a silverlight application where users can preview audio files from their browser from the telerik radmediaplayer control.
The files are on a webserver and anyone who sniffs the trafic can download the file.
We would like to prevent non-logged-in users from accessing/downloading these files.
Besides providing the application with some sort of temporary valid url and implementing a custom httphandler... what are our options?
It's not too big of a problem if our customers can download the files, we just don't want the rest of the world to also have access.
Any ideas would be more than welcome!
[Update]
The only thing I can come up with is:
host the files in a non-public folder
if a user requests to prelisten a file, copy it to a public folder under a new name ([guid].mp3) and return it's url
every x minutes clean the public folder.
Don't let the web server serve up the files straight out of a directory. Put part of your application in front, and left one of your server-side scripts serve up these files. Keep the raw audio files out of the web root.
For instance, your client-side application would access files like so:
http://someserver/yourscript?audio_asset_id=12345
The code at yourscript would verify the session data, ensuring that a user is logged in, would then go figure out the real path to asset ID 12345, and echo its contents to the client. Don't forget to include the proper Content-Type header as well.
Once the accessing of these assets is under your control, you can implement whatever security measures you like. If your sessions area already pretty well safe-guarded, this should be fine. I would also recommend implementing sane quotas. If you get 100 requests on an asset using the same session ID from multiple IP addresses... something isn't right.

Change owner of file uploaded in server

I have trying to overwrite or perform some file operation to the files uploaded in a webserver.
Previously I have uploaded the files from joomla extension. It defined its owner as 99. Without changing its owner it my login name i am unable to perform file operation using ftp and cpanel.
what can be done?
You could enable the FTP layer of Joomla.
It does depend a bit on how your hosting sets permissions (whether they use ACL's, etc), but the FTP layer of Joomla is designed to get around exactly this issue.
Documentation for this feature is here:
http://help.joomla.org/content/view/1941/302/1/2/

Resources