You can use a AAA vServer for the authentication with an authentication profile. Setup authentication policies and profiles for each domain and then set the authentication with domain A priority 100 and domain B priority 110. Then use the Authentication profile on the Gateway.