APY-13 : Complete the security gateway

Updated and cleanded.