def first_realm_successful_strategy(authc_attempt):
authc_token = authc_attempt.authentication_token<EOL>realm_errors = []<EOL>account = None<EOL>for realm in authc_attempt.realms:<EOL><INDENT>if (realm.supports(authc_token)):<EOL><INDENT>try:<EOL><INDENT>account = realm.authenticate_account(authc_token)<EOL><DEDENT>except Exception as ex:<EOL><INDENT>realm_errors.append(ex)<EOL><DEDENT>if (account):<EOL><INDENT>return account<EOL><DEDENT><DEDENT><DEDENT>if (realm_errors):<EOL><INDENT>if (len(realm_errors) == <NUM_LIT:1>):<EOL><INDENT>raise realm_errors[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>raise MultiRealmAuthenticationException(realm_errors)<EOL><DEDENT><DEDENT>return None<EOL>
The FirstRealmSuccessfulStrategy will iterate over the available realms
 and invoke Realm.authenticate_account(authc_token) on each one. The moment
 that a realm returns an Account without raising an Exception, that account
 is returned immediately and all subsequent realms ignored entirely
 (iteration 'short circuits').

 If no realms return an Account:
     * If only one exception was thrown by any consulted Realm, that
       exception is thrown.
     * If more than one Realm threw an exception during consultation, those
       exceptions are bundled together as a
       MultiRealmAuthenticationException and that exception is thrown.
     * If no exceptions were thrown, None is returned, indicating to the
       calling Authenticator that no Account was found (for that token)

:type authc_attempt:  AuthenticationAttempt
:returns:  Account