Greetings,
Actually, there is no scheme to provide security for the judges, but some judges write to the State and seek security for them based upon the representation it is provided by the State, but when you study the working pattern of this security it would require great consideration.
Normally a gunman would accompany the Principal District Judge and the security had never been given to any Additional District Judge, because the Principal District Judge alone is empowered to write to the State. Now let us see the work style. If the Judge would goes by train for duty to Head Quarters the Judge would go by First class compartment while the security man is not entitled to avail first class and hence travels in sleeper coach. Hence this security is only name sake and so far there has been no instance of any attack over the judge and there is also no instance of security man opening fire over anyone in the past.
Moreover, we need to realise that post giving their judgements, judges are in a delicate position, wherein their safety is a matter of concern. For example, in cases like The Ayodhya Verdict, highest level of security was given to the judges. Apart from this, to answer your implication that the relations of police officials having better relations with judicial officials should not be a bothering matter, as the social relations of judicial officials hold no merit in their judgements.
Hope this helps you.
Regards