<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure(user, action, subject):
 """ Similar to ``can`` but will raise a AccessDenied Exception if does not have access"""

    ability = Ability(user, get_authorization_method())
    if ability.cannot(action, subject):
        raise AccessDenied()