One set of wires in the junction comes from the panel(power), the other set goes to the switch(or should).
With the wires separated as shown in the picture and the breaker off, remove the wire nuts on the black wires.
Turn the breaker on, and with a multimeter see which black has power, should read ~120 volts between the black and ground(or neutral if you want remove that nut also).
The other set will be for the switch.
Once the switch wires are found, place black tape on the white wire.
Nut the white wire with tape to the black power wire, the black switch wire is nutted to the black light wires, the white light wires are nutted to the white(neutral) of the power wire.
All the grounds are connected together and to the box.
Turn on the breaker and light should work with the switch.