Extracted trimming to common method

Also added accessors for getting trimmed versions of user name and password.