An authentication and authorization mechanism for secure gateway authentication and authorization for applications