Asterisk as a dialer


First of all I wanted to know if something like this would be possible:

A user dials to an asterisk server (Let’s call ir Asterisk A). The asterisk servers asks the user to dial a password. If the password is correct the Asterisk server asks the user to dial a phone number. Asterisk detects the phone number format and uses a SIP Trunk to another Asterisk Server (Let’s call it Asterisk B). Asterisk B dials the number the user has dialed in Asterisk A through the FXO port… Comunication would be established between the user and the dialed phone number.

If this is posible how do you get it to work?

Thank you.

See the Newbie: Making Mobile to Mobile calls through Asterisk thread.