If the ball is on its downward flight towards the goal neither the offense or defense can touch it. If the offense touches it then it is offensive goaltending.
An alley oop is legal when it is a pass not going towards the goal. If the ball was shot towards the hoop and an offensive player caught it and dunked it, it would be goaltending.
Got to admit that I have never seen this one