You won't need to clear security again and you just use the airside skytrain to go to terminal D from where the BA flight leaves.
SAN flights might arrive to D but even if not you should be just about OK, MCT for domestic to international is 40 mins.
There is usually a later AA flight if you miss the BA one.