<< Previous | Home | Next >>

MobileKnox: Your Mobile Password Safe

Do you also tend to forget your passwords?

Though there are some great ideas around to provide a global single sign-on infrastructure for web applications like OpenID today's reality is different:

  • usually one account per web site - hopefully with different passwords
  • IMAP accounts for email
  • accounts for instant messaging networks (MSN, ICQ, Jabber)
  • accounts for your workstations at work, at home and for your notebook
  • PINs for your various credit and debit cards
  • account numbers and PINs for online and telephone banking
  • access codes for door locks and physical access control
  • and you probably can think of a lot more...

MobileKnox aims to make your life a bit easier by providing a secure store for your account data on your mobile phone.

If you are like me your mobile will always be with you. That means you will always have access to your credentials whether you are at work, at home or on the road.

MobileKnox runs on most Java-enabled mobiles and PDAs and is accompanied with a small desktop application that runs on all major platforms (Windows, Mac, Linux) to synchronize passwords with your device.

References

Tips for Honest Programming

Keep your code moral

Chalain blogged about Dishonest Programming and provides a few tips on how to write moral code by being honest with yourself, with the compiler, and with your coworkers.

I think the first ones are most important:

  • Name functions for what they really do.
    Make sure your functions do what the name implies. Review your code to identify large parts that are doing different things like checking for preconditions or handling errors and extract them.
  • Let your yea mean yea and your nil mean nil.
    If you write a function called createLink() it should create a link or clearly indicate failure (e.g. by throwing an exception). Side effects that are not reflected by the name should be well documented.

Few code is ever written to be dishonest but as new features are added and bugs get fixed in a hurry it is easy to become immoral.

References

Tags :

Sin-Yaw Wang: A Theory in Compensation

Learning new skills pays off

Sin-Yaw Wang put up a nice Theory in Compensation:

Your earned pay reflects the improvements of your skills. Companies do this in a zig-zag way: sometime over-paying and sometime under. The gap between these two lines cannot be too wide for too long. Either you will find a new job that pays your market rate, or the company will fire you for not giving your money's worth.

He concludes:

Ask first, when you are thinking of a new job, if you will be learning new skills. Don't ask if it pays better. You compensation will keep up with your skills, sooner or later. If you are not learning new skills, then you are simply being harvested.

Well said. I guess many companies out there just find it easier to pay more than to make sure their employees gain a real chance to develop their skills.
My experience is that even if they deploy formal processes for career planning, they often miss the point in what really matters to increase the value of their employees.

References

Deleted a File by Accident?

Reverting Subversion Commits

You have deleted a file or directory and commited your change by accident? Subversion lets you undo your change quite easily.

Use svn merge -c -<revision> <URL> in your working directory. If you have local changes that you want to commit later do a fresh checkout of <URL> to a temporary directory and run svn merge there. After running svn merge you must commit your working directory for the undo to become effective.

As this completely reverses your change the same procedure can be used to recover a deleted directory or to undo other unwanted changes.

For more information see the undo section in Version Control with Subversion.

Tags :

From Layers to Bus

The Way from Classical Middleware Applications to SOA

The Layered Scenario

A classical layered middleware application landscape might look like this:

A few frontend applications connected to a middleware application that connects to the backend systems. Frontend application means anything an end user interacts with. This includes web applications, interactive voice response systems as well as special devices like ATMs. The middleware applications expose business services to the frontends using a unified data model and hiding the backend calls from the frontends. Additional business logic that is missing in the backend systems is also implemented in the middleware. Finally backend applications do the central data processing, implement compliance requirements and provide a single point of truth regarding the business data. While the middleware layer is often developed inhouse, the backend applications are mainly (customized) products.

Communication takes place according to the layered structure of the landscape. Frontends talk to the middleware and the middleware talks to the backends. There are no direct calls of frontends to the backends, all backend services are wrapped (and mapped) by middleware services. Backends do not consume enhanced services of the middleware, communication between backend systems is usally implemented by batch jobs.

The Bus Scenario

On the way to SOA the connectivity and mapping features of classical middleware applications are moved into an off-the-shelf Infrastructue: the Service Bus. The goal is to replace implementation by configuration. So the backend and frontend adapter layers of the old landscape are no longer needed. The Service Bus takes over and is able to communicate with the frotend and backend applications while still ensuring appropiate encapsulation by mapping to a common vocabulary.

The Service Bus itself does not add any new services like the old middleware applications did. Therefore we will need a place for these added-value services. As you can see in the above picture the place for these features is a new Custom Services box at the level of the backend systems, now referred to as Service Producers.

As the bus architecture does not by itself enforce a caller-callee relationship Custom Services can use the backends and can be used by the frontends. In addition Custom Services now can also be used by the backends as they see fit. Finally there is no longer a need to wrap backend services by self-built services as the frontends are now able to talk "directly" to the backends while still maintaining encapsulation through the use of the mapping features of the bus infrastructure.

Consequences

The most obvious consequence is that you have to remove the frontend and backend adapters from the middleware application block. Transport Adapters are now either part of the service bus itself or the service bus provides a common transports that your applications must be enabled to connect to.

Besides transport adapters you will also need a common Enterprise Vocabulary, i.e. a data model that is understood by your services. To make the services understand this vocabulary you can either add mapping to the service bus so that (legacy) applications can still use their own vocabulary or you enable the applications to provide their services using the new vocabulary natively. Depending on the applications you have in place the one or the other option is more compelling. Often you will use a mixed approach.

Finally an important concequence is the need for more explicit Governance. While the layered scenario inherently restricts allowed dependencies the bus scenario offers much more freedom. You may want to prohibit cyclic dependencies between service blocks and make sure that service level agreements can be met (i.e. higher quality services do not depend on lower quality services). Governance is also required to define responsibilites of the now mostly equal service blocks and to evolve the common enterprise vocabulary.

Profiling PHP Applications

Using the Xdebug Extension for PHP

Ever wondered where your PHP applications spend their time?

For simple PHP scripts you can easily do basic profiling by modifying your script, take the time at critical points and log the data to a file.
As applications become more complex or make use of third party frameworks like the Zend Framework this approach does no longer work well without introducing a lot of tracing code.

We wanted to gain performance insights of a newly developed application based on Zend Framework to spot areas worth receiving some fine tuning. We did not want to modify the application for that purpose so I had a look at the options available for PHP. I finally gave Xdebug a try. Xdebug is a debugger and profiler for PHP that works as an extension that you register in your php.ini:

zend_extension="/usr/local/lib/php5/modules/xdebug.so"
xdebug.profiler_enable = 1

Restart Apache and access a few pages of your application. Look at the /tmp directory on your webserver and watch for cachegrind.out files. These files contain the profiling information that we are interested in. Copy the files to your workstation for further inspection.

To analyze the profiling data you can use KCachegrind that allows you to identify the performance hogs visually:

or inspect the trace as a list:

The combination of Xdebug and KCachegrind allows you to collect and analyze profiling information from your PHP applications while they are running in their real environment without changing a single line of code.

References

Spring MVC: Null or an Empty String?

Wondered why Spring MVC converts an empty field to an empy string instead of null?

Spring MVC converts your empty fields to an empty string instead of null by default. This is often not what you want when you persist your entities. The reason for this behavior is that Spring MVC uses Java's default property editor for strings when binding the request to your domain object.

A better alternative is to use the StringTrimmerEditor that removes surrounding white space from the field values and optionally converts an empty value to null instead of an empty string.

Just override the initBinder method of your SimpleFormController:


protected void initBinder(HttpServletRequest request, 
  ServletRequestDataBinder binder) throws Exception
{
  // bind empty strings as null
  binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
}

References

Tags :

Adding Presence to Your Website

Showing Jabber status messages

You might have noticed the small green, yellow or gray icon next to my name in the about section on the right. It shows my XMPP status and my status message. This is done by including a small JavaScript snippet in the template of my blog:


<script type="text/javascript" 
  src="/js/presence.js?uid=stefan.reuter&nick=Stefan%20Reuter">
</script>

The presence.js script is in fact a PHP script that retrieves the XMPP presence from the presence plugin of my Openfire server:


<?php
ini_set('display_errors', false);

$uid = $_GET['uid'];
if (! preg_match('/^[A-Za-z0-9_\.-]+$/', $uid))
{
        echo "document.write('Invalid uid parameter.');";
        die;
}
if (isset($_GET['nick']))
{
        $nick = $_GET['nick'];
}
else
{
        $nick = $uid;
}
if (! preg_match('/^[A-Za-z0-9_\. -]+$/', $nick))
{
        echo "document.write('Invalid nick parameter.');";
        die;
}
$imgtag = "<img src=\"/status/".$uid."\"/>";
$url = "http://openfire:9090/plugins/presence/status?jid="
        .$uid."@reucon.com&type=text";
$text = rtrim(implode(file($url, FILE_SKIP_EMPTY_LINES)));
$text = str_replace("\n","",nl2br(htmlspecialchars($text)));
?>
document.write('<table class="xmpp-status"><tbody>');
document.write('<tr valign="center">');
document.write('<td><?php print $imgtag; ?></td>');
document.write('<td><?php print $nick; ?></td>');
document.write('</tr>');
<?php if ($text != 'null') { ?>
document.write('<tr>');
document.write('<td> </td>');
document.write('<td><?php print $text; ?></td>');
document.write('</tr>');
<?php } ?>
document.write('</tbody></table>');

References

Extracting Jira Worklogs from Subversion

Time tracking through Subversion Commit Messages

We are using Atlassian's Jira for issue and time tracking.
Time tracking discipline has been varying mainly because it interrupts your flow if you have to leave the IDE to log work done. As we already include the corresponding Jira issue key in all our Subversion commit messages the natural idea was to just add the time spent to the commit message.

The worklog above is created from the first line of this commit message:

[BAS-70] Added README file (20m)
[BAS-61] Removed old stuff and did so
 much that it doesn't fit on a line (1w2d4h)

svn-worklog.rb is the Ruby script I wrote to extract worklog information from commit messages and attach them to the associated Jira issue. It is called from the post-commit hook.

Read more...

Using Kernel-based Virtualization

KVM on Ubuntu Gutsy Gibbon 7.10

Recently I stumbled upon KVM (for Kernel-based Virtual Machine) which allows you to leverage the virtualization features built into modern processors.

This blog entry got me started. I am running Ubuntu Gutsy Gibbon 7.10 on an AMD Athlon(tm) 64 X2 Dual Core Processor so I installed qemu and kvm, loaded the kernel module and created a disk image for my virtual machine:

sudo apt-get install qemu kvm
sudo modprobe kvm-amd
qemu-img create node1.img -f qcow2 6G

Next I added myself to the kvm group to access /dev/kvm. As an alternative you can temporarily loosen the permissions (sudo chmod 666 /dev/kvm) but don't forget to fix that later on.
I grabbed the iso image of the server edition of Ubuntu 7.10 and was ready to boot the vm and start the installation:

kvm -m 750 -cdrom ubuntu-7.10-server-amd64.iso -boot d -std-vga node1.img

Wow! That was easy:

I installed Ubuntu just like on every other computer. Once the installation was done the automatic reboot failed as expected and I closed the qemu window and started it again (this time with only 500MB of RAM which is still plenty):

kvm -no-acpi -m 500 node1.img

I booted a fully running Ubuntu system - even networking automagically worked.

This looks like a great alternative to the bloated VMware server especially as it is extremly easy to just copy or move the virtual machines if you want to play with clustering for example.

Read more here and here (yes, you can also run Windows this way). Cool stuff!