No, it's not legal. It is an infringement of your constitutional rights.... You should sue the officer, the school, and the government....