refactored TrustedServer - core authentication logic