Extract UserID from Portal for use in external application

Let's say, a User authenticated himself to the Portal (Rel. 7), what is the easiest recommended way to EXTRACT USERID from the Portal and post this parameter (hidden) to an external web application (Java)?