A problem when i integrated openfire with my own AuthProvider and UserProvider

I want to integrate openfire with my own authentication system (AS)and user management system(UMS, basically use openldap).

In AS, user* testuser* has an unique umsId ( Integer ), for example, testuser’s DN is cn=123456, ou=mydepartment, dc=mycompany, dc=com. In UMS, user * testuser* has an unique umsId 123456 and many email address:** testuser@gmail.com, testuser@yahoo.com** . testuser use email and password to login, whatever email he uses, he always login as testuser with unique umsId 123456.

 Now, i implemented my AuthProvider called ASAuthProvider and use LdapUserProvider to load user info from UMS, but when i used them in openfire, there is a problem. If *testuser *enter **testuser@gmail.com** and password to login,  username=**testuser@gmail.com** will be passed into  ASAuthProvider.authenticate(username, password), after authentication success, username=**testuser@gmail.com** will be passed into LdapUserProvider.loadUser(username) to get user info. However, there is no user info about **testuser@gmail.com** in UMS LDAP and only user info related to **umsId 123456**, so *testuser* failed to login.

 So i need to use email like **testuser@gmail.com** to login in ASAuthProvider and get the **umsId 123456 **from the response of AS**, **then, use **123456 **as the username parameter to load user info in LdapUserProvider from UMS. However, the parameter username is passed into ASAuthProvider and LdapUserProvder, and i don't know how to change the value.

 what i need is to use email (**testuser@gmail.com** or **testuser@yahoo.com**) as the value of username to login in ASAuthProvider and use umsId **123456** as the value of username to load user from UMS in LdapUserProvider. How can i do this ?