Castling is permitted provided all of the following conditions are met:
Neither the king nor the rook has previously moved.
There are no pieces between the king and the rook.
The king is not currently in check.
The king does not pass through or finish on a square that is attacked by an enemy piece.