Japan has warned ministries, local bodies and companies to tighten cybersecurity after a surge in attacks and data leaks.