No, it is not legal. Unfortunately, there  is no good way to get your property: you could try asking the local police to help you, but they are typically reluctant to get involved in cases like this. If the police don't help, your recourse would be to sue your employer (such as in small claims court, as your own attorney or "pro se") for the value of the withheld belongings; the suit be settle or resolved by them returning them to you.