There are two parts to it. First you need to programmatically figure out the list of permissions asscociated with the Team Site, that you are mentioning. After figuring out the permission-levels, you need to write the logic for authorizing the user to access the application in the OnLoad method of your application page.
The following article checks the permission level of a user, on the OnLoad method.
http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2008/10/15/secure-a-sharepoint-application-page.aspxThis would give you some pointer on how and where to add your authorization logic to your application page
Sundar Narasiman