rearranged if branches to better readability
minor optimization
translateSsoToken() throws exception, so we can handle errors in context