If you want to know the current username in your application, simply call:
getApplication().getUserName();
The method returns the same as:
getApplication().getConnection().getUserName();
If getApplication() return type is an IApplication, use this:
((ProjX)getApplication()).getUserName();
The above code is client-side code. If you need the username server side, simply call:
SessionContext.getCurrentSession().getUserName();