Use the getName() method of Principal rather than relying in toString().