The good news is that I got the combo working. The fix I made worked once I recompiled and redeployed the claros-base.jar file and restarted the server.
However, the bad news is that, despite Intouch2 looking quite nice (looks a lot like Mac’s Mail.app), the responsiveness feels like every click and key press is traveling through a mile of mayonnaise.
Not sure what that’s all about.
I’m trying to get the Claros Intouch2 web application working within a Glassfish 3 application server. The installation was pretty straightforward. After following the directions closely, I was able to access the login screen within about 15 minutes.
However, that’s where my problems began and I have been stuck. No matter what I input for a username and password, I get this:

No, my login information is not, in fact, invalid. I can login via telnet to the imap port fine. The problem appears to be this (from intouch2/WEB-INF/log/application_log.html):
Connection could not be established.Can't load NTLM authenticator
I’m not using NTLM, but apparently not even being able to load the authenticator is reason enough to fail. I did some research and found similar problems for people who have switched from Glassfish 2 to Glassfish 3 (not for intouch2, but other Javamail applications) and it appears, by default, the JavaMail version (1.4.3) in Glassfish 3 defaults to enabling NTLM authentication.
I found some forum posts where you can set an application property:
mail.imap.auth.ntlm.disable = true
which should disable NTLM, but I can’t seem to find where to set it for intouch to pick it up. It’s not picked up when I set it as a server-wide property, nor as a web-container property. The last thing I need to try is actually modifying the source code. I think if I set this property in org.claros.commons.mail.protocols.ImapProtocolImpl.java as such (see line 3):
if (handler == null || handler.getStore() == null || !handler.getStore().isConnected()) {
Properties props = new Properties();
props.setProperty("mail.imap.auth.ntlm.disable", "true");
// props.setProperty("mail.imap.separatestoreconnection", "true");
// props.setProperty("mail.imap.connectionpoolsize", "0");
// props.setProperty("mail.imap.connectionpooltimeout", "100");
// props.setProperty("mail.debug", "true");
Session session = Session.getDefaultInstance(props);
log.debug("session instance initiated");
handler = new ConnectionMetaHandler();
handler.setStore(session.getStore(profile.getProtocol()));
log.debug("session store set. protocol is: " + profile.getProtocol());
handler.getStore().connect(profile.getFetchServer(), profile.getIFetchPort(), auth.getUsername(), auth.getPassword());
this may work, but I haven’t set up the environment to get it to compile yet.
I sent an email to support@claros.org, so far, nothing. This project doesn’t appear to have been update in a while, so I’m not sure it’s even active anymore — which is a shame. I’ve been using Squirrelmail for a while and while it works, it’s not as pretty looking as Intouch2 — and I like the fact that it’s a Java webapp as opposed to PHP as Java is a little more my thing.
At any rate, I’m gonna continue banging away.
I decided to take a run at using Scala in a practical application — by rewriting a quick script that I had originally done in Perl to use Scala instead.
Basically, all this script is supposed to do is read to text files, extract a piece of data from each line using a regex, and then look to see which data was in one file, but not the other. Simple. I found some decent examples when Googling, but have run into a snag which bugs me.
I particularly like the way Scala allows you to apply a regex to a string and have matches assigned to variables. Here is what I was doing:
def loadTapefileInfo(lines: Iterator[String]): Unit = {
val GridDirEntry = """.*(B2D[0-9]+\.bkf)\s+([0-9]+)\n""".r
// val GridDirEntry = """(.*)""".r
lines.foreach { line =>
try {
val GridDirEntry(filename, filesize) = line
println("Filename: " + filename + " :: Filesize = " + filesize)
} catch {
println("NOMATCH: " + line)
}
}
}
In my Perl script the logic looked like this:
while(my $line = <BAD_FILE>) {
$line =~ /.*(B2D.*\.bkf)\s+?([0-9]+)/;
my $tapefile = $1;
my $filesize = $2;
# print ("Adding Tapefile=$tapefile with size=$filesize\n");
if( $tapefile ne "" ) {
$newFiles->{ $tapefile } = { "filename" => $tapefile,
"filesize" => $filesize };
} else {
# print "OOPS: [$tapefile]\n";
}
}
When Perl doesn’t match, I just skip the line. When Scala doesn’t match, though, I get a runtime error (MatchError) and the program halts. Does this mean I can’t use this form of assignment via a RegEx object unless I am 100% sure that there will be a match? How else am I supposed to do this in Scala? Do I have to revert to using Java’s regex matching?
I’d considered trying to catch the MatchError, but apparently that’s bad form as the MatchError isn’t really an exception but an “unrecoverable error”. I’m not sure why not matching is considered an unrecoverable error. I’m still digging, but unless I’m misusing this method of pattern matching with respect to how it was intended, I can’t think of why this should be doable.
UPDATE:
I fixed it. So it appears that yes, I cannot use the assignment method of matching a regex unless I KNOW that there will be a match. I changed my code to use regular matching syntax:
def loadTapefileInfo(lines: Iterator[String]): Unit = {
val GridDirEntry = """.*(B2D[0-9]+\.bkf)\s+([0-9]+)\n""".r
// val GridDirEntry = """(.*)""".r
lines.foreach { line =>
line match {
case GridDirEntry(filename, filesize) =>
println("Filename: " + filename + " :: Filesize: " + filesize)
case entry =>
println("Unrecognized line: " + entry)
}
and everything seems to be working.
Thanks to the info I found here.
I am looking for a decent Windows E-Mail client that I like that handles IMAP well. So far, I haven’t found one.
I haven’t used POP in years, mostly because I have several email accounts that I access from many different devices and the last thing I want is to have mail messages scattered all over the place on different devices. Back before IMAP, there was the POP option “Leave Messages On Server” but that wasn’t exactly ideal either — and if you forgot to set it or couldn’t figure out how to on whatever client you were using, you were in for a nightmare when you downloaded messages to one machine and you could only view them on that machine.
When I discovered IMAP and the beauty of server stored email, I made the switch for good. It took an awfully long time, it seemed, for choice in IMAP clients to show up, but even now, years later, I struggle with almost every Windows-based IMAP client I’ve tried, for one reason or another.
The most obvious choice for Windows-based email is Outlook. As far as email clients go, in general, Outlook isn’t bad, but it suffers from what I think most MS software suffers from — a clunky UI. There’s too many damned UI elements.
At any rate, Outlook’s IMAP support annoys the shit out of me. I particularly don’t like the way it handles deleted messages. Messages marked for deletion in IMAP remain in the folder they’re in until they are purged. Once they are purged they’re gone for good.
For whatever reason, Microsoft engineers felt that rather than move the message, now marked for deletion, to the Trash folder and getting it out of the Inbox, that they would leave it in the Inbox with a line through it. It is the ugliest thing I’ve ever seen.
This is a prime example of what I think is a cardinal sin in application design. The user should not be forced to deal with the eccentricities of the underlying architecture — in this case, the IMAP protocol itself’s delete/purge mechanism.
User: “Why do you put a line through it? Why don’t you just delete the message when I press delete?”
Engineer: “Because in IMAP, message deletion is a two-step process. The first time you delete the message it is marked for deletion. Then you have to purge it.”
User: “So I have to delete it twice?”
Engineer: “Yes.”
User: “Why do I have to delete it twice?”
Engineer: “Because that’s how the IMAP protocol works.”
User: “What’s the IMAP protocol?”
Replace user with “ur mom” and you get the point. The thing I find really odd is that the delete/purge mechanism for IMAP is directly analogous to the recycle bin used for files in Windows. First you move the file to the recycle bin, then at some point later, you can empty the recycle bin. If you accidentally move a file to the recycle bin, you can always go back and get it later. As near as I can tell, that’s pretty much what IMAP is doing with the purge/delete mechanism, yet MS chose not to implement it this way. Seemingly every other email client ever invented does, but most of those suck for other reasons.
If Outlook’s default handling of purged/deleted messages that doesn’t appeal to you (and I can’t imagine why it ever would) you can change the purge options in Outlook, but again, Microsoft leaves me scratching my head as to what they were thinking. The purge option in Outlook will automatically purge the deleted items in a folder when you switch to another folder. That means if you delete a bunch of emails in your Inbox and want to see a nice, clean Inbox, you need to click another folder and then click back to the Inbox. I’d swear they do that to make people hate IMAP.
I was trying to figure out how to connect to my company’s VPN through an OS X command line, but wasn’t having much luck figuring out what OS X was doing under the covers when it connects to a VPN. I know it uses pppd, but as is the case with a lot of what Apple does in OS X (and in general) they do it in a way that’s quite differently than anyone else.
I was thinking that I’d be able to open “Internet Connect” and point it at a profile or something, but it wasn’t that easy. Firstly, because it appears that Snow Leopard did away with the Internet Connect application and stuck it underneath Network Preferences.
I wanted to do the whole thing in a bash script, but I’m not above (or below as the case may be) using Applescript if that was the only way to get it done — and in this case, it was definitely the easiest.
tell application "System Events" Connect service "<connection name>" of current location of network preferences end tell delay 10
Wow. That was simple. Aside from the oddness of telling System Events that I wanted to connect, it couldn’t have been much easier.
Why the 10 second delay? Well therein lies the entire reason I wanted to script this to begin with. When I connect to my company’s VPN, I get a secondary default route and a local route. However, the machines I want to access at work are on a different subnet than the local one I’m handed by the VPN. So to work around this (rather than making my work network my default route for all traffic when I’m connected, which albeit an option, is not an attractive option) was to create a static route to the subnet I needed to reach.
I created a quick script to add the route for me:
#!/bin/bash route add -net 172.21 `ifconfig ppp0 | grep inet | cut -d ' ' -f 2`
Yeah, I could have just run that script manually after connecting to the VPN through the UI, but where’s the challenge in that? Fewer clicks makes me happy.
So the net result is the following top-level script which combines the first and second:
#!/bin/bash osascript /Users/ehansen/bin/applescript/ConnectVPN.applescript && \ route add -net 172.21 `ifconfig ppp0 | grep inet | cut -d ' ' -f 2`
