It is possible to do what you want, as shown below:
Web browser <--- Internet ---> Firewall <---> Web dispatcher <---> SAP NW Gateway <---> Active Directory
For above you need to buy a product from a SAP partner.
If you want to use AS JAVA with SAP SSO product, then you need to buy SAP SSO product from SAP.
Thanks
Tim