Example - public registry

/*SIMPLE MQePublicRegistry shareCertificate FRAGMENT */
   try {
   String EntityName = "Bruce";
   String EntityPIN = "12345678";
   Object KeyRingPassword = "It_is_a_secret";
   Object CertReqPIN = "12345678";
   Object CAIPAddrPort = "9.20.X.YYY:8082";
/*instantiate and activate PublicReg */
   MQePublicRegistry pubreg = new MQePublicRegistry();
   pubreg.activate("MQeNode_PublicRegistry",".\\");
/* auto-register Bruce1,Bruce2...Bruce8 */
/* ... note that the mini-certificate issuance service must */
/* have been configured to allow the auto-registration    */
   for (int i = 1; i < 9; i++)
   {
   EntityName = "Bruce"+(new Integer(i)).toString();
   MQePrivateRegistry preg = new MQePrivateRegistry();
/* activate() will initiate auto-registration */
   preg.activate(EntityName, ".\\MQeNode_PrivateRegistry",
     EntityPIN, KeyRingPassword, CertReqPIN, CAIPAddrPort);
/* save MiniCert from PrivReg in PubReg*/
    pubreg.putCertificate(EntityName, 
       preg.getCertificate(EntityName ));
/*before share of MiniCert */
   pubreg.shareCertificate(EntityName,
     preg.getCertificate(EntityName ),"9.20.X.YYY:8082");
   preg.close();
   }
   pubreg.close();
   }
   catch (Exception e)
   {
   e.printStackTrace();
   }
   
Note:
  1. It is not possible to activate a registry instance more than once, hence the example above demonstrates the recommended practice of accessing a private registry by creating a new instance of MQePrivateRegistry, activating the instance, performing the required operations and closing the instance.
  2. If you want to share certificates using a public registry on the home-server, the public registry must be called MQeNode_PublicRegistry.

Parent topic: Public registry service