Package org.xmlBlaster.protocol.corba.authenticateIdl

Examples of org.xmlBlaster.protocol.corba.authenticateIdl.AuthServer


                  throw new Exception("Can't resolve CORBA NameService");
               }

               NameComponent [] nameNode = new NameComponent[] { new NameComponent(clusterId, clusterKind) };

               AuthServer authServerFirst = null;
               String tmpId = "";           // for logging only
               String tmpServerName = "";   // for logging only
               String firstServerName = ""; // for logging only
               int countServerFound = 0;    // for logging only
               String serverNameList = ""// for logging only
View Full Code Here


         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Please pass a valid QoS for connect()");

      this.ME = "CorbaConnection";
      if (log.isLoggable(Level.FINER)) log.finer("connect(xmlBlaster="+this.xmlBlaster+") ...");
      try {
         AuthServer remoteAuthServer = getAuthenticationService(this.clientAddress);
         if (log.isLoggable(Level.FINE)) log.fine("Got authServer handle, trying connect ...");
         return remoteAuthServer.connect(connectQos);
      }
      catch(XmlBlasterException e) {
         throw e;
      }
      catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
View Full Code Here

   {
      glob = new Global(args);

      orb = org.omg.CORBA.ORB.init(args,null);
      try {
         AuthServer authServer;
         ME = glob.getProperty().get("loginName", ME);
         String loginName = ME;

         String fileName = glob.getProperty().get("dispatch/connection/plugin/ior/iorFile", (String)null); // a file with the IOR string
         String authServerIOR = glob.getProperty().get("dispatch/connection/plugin/ior/iorString", (String)null); // the IOR string

         if (fileName != null) authServerIOR = FileLocator.readAsciiFile(fileName);

         if (authServerIOR != null) {
            authServer = AuthServerHelper.narrow(orb.string_to_object(authServerIOR));
         }
         else {
            // asking Name Service CORBA compliant:
            NamingContext nc = NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
            NameComponent [] name = new NameComponent[1];
            name[0] = new NameComponent();
            name[0].id = "xmlBlaster-Authenticate";
            name[0].kind = "MOM";
            if (nc == null) {
               System.out.println("\nSorry, please pass the server IOR string to the client, e.g.:\n"
                           + "Start the server:\n"
                           + "   jaco org.xmlBlaster.Main -dispatch/connection/plugin/ior/iorFile /tmp/NS_Ref\n"
                           + "Start this client:\n"
                           + "   jaco javaclients.corba.ClientRawSecurity -dispatch/connection/plugin/ior/iorFile /tmp/NS_Ref\n");
               usage();
               log.severe("Read xmlBlaster/INSTALL for help");
               System.exit(1);
            }
            authServer = AuthServerHelper.narrow(nc.resolve(name));
         }

         StopWatch stop = new StopWatch();

         //---------- Building a Callback server ----------------------
         // Getting the default POA implementation "RootPOA"
         org.omg.PortableServer.POA rootPOA =
            org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

         // Intialize my Callback interface:
         BlasterCallbackPOATie callbackTie = new BlasterCallbackPOATie(new RawCallback(glob, ME));
         BlasterCallback callback = BlasterCallbackHelper.narrow(rootPOA.servant_to_reference( callbackTie ));

         rootPOA.the_POAManager().activate();

         //----------- Login to the server (the new way) ---------
         try {
            String passwd = "some";

            // The xmlBlaster server takes this IOR string and uses it to connect
            // to our client-side callback interface to deliver updates back
            String callbackIOR = orb.object_to_string(callback);

            // Create a XML based qos (quality of service) which hold the IOR (the CORBA
            // address of our callback server)
            String qos = "<qos>\n" +
                         "   <securityService type=\"simple\" version=\"1.0\">\n" +
                         "      <user>" + loginName + "</user>\n" +
                         "      <passwd>" + passwd + "</passwd>\n" +
                         "   </securityService>\n" +
                         "   <callback type='IOR'>\n" +
                         callbackIOR + "\n" +
                         "   </callback>\n" +
                         "</qos>\n";

            String retXml = authServer.connect(qos);

            // Parse the returned string, it contains the server IOR
            ConnectReturnQos returnQos = new ConnectReturnQos(glob, retXml);

            log.info("Login (Connect) done.");
            log.info("Used QoS=\n" + qos);
            log.info("Returned QoS=\n" + returnQos.toXml());

            // Get the CORBA handle of xmlBlaster ...
            String xmlBlasterIOR = returnQos.getServerRef().getAddress();
            xmlBlaster = ServerHelper.narrow(orb.string_to_object(xmlBlasterIOR));

         } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
            log.warning("XmlBlasterException: " + e.getMessage());
         }


         //----------- Subscribe to messages with XPATH -------
         {
            log.fine("Subscribing using XPath syntax ...");
            String xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                           "<key oid='' queryType='XPATH'>\n" +
                           "/xmlBlaster/key/AGENT" +
                           "</key>";
            stop.restart();
            try {
               xmlBlaster.subscribe(xmlKey, "<qos></qos>");
            } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
            log.info("Subscribe done, there should be no Callback" + stop.nice());
         }


         delay(2000); // Wait some time ...


         //----------- Construct a message and publish it ---------
         {
            String xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                            "<key oid='' contentMime='text/xml'>\n" +
                            "  <AGENT id='192.168.124.10' subId='1' type='generic'>" +
                            "    <DRIVER id='FileProof' pollingFreq='10'>" +
                            "    </DRIVER>"+
                            "  </AGENT>" +
                            "</key>";
            String content = "Yeahh, i'm the new content";
            MessageUnit msgUnit = new MessageUnit(xmlKey, content.getBytes(), "<qos></qos>");
            log.info("Publishing ...");
            stop.restart();
            try {
               String publishOid = xmlBlaster.publish(msgUnit);
               log.fine("Returned oid=" + publishOid);
            } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
            log.info("Publishing done, there should be a callback now" + stop.nice());
         }

         delay(1000); // Wait some time ...

         // orb.run(); // Usually your client won't exit after this, uncomment the run() method

         ask("logout()");

         //----------- Logout --------------------------------------
         log.info("Logout ...");
         try {
            authServer.logout(xmlBlaster);
            authServer._release();
            xmlBlaster._release();
         } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
            log.warning("XmlBlasterException: " + e.getMessage());
         }
View Full Code Here

      System.out.println("   -dispatch/connection/plugin/ior/iorFile    The raw IOR string from a file.");
      Global glob = new Global(args);

      orb = org.omg.CORBA.ORB.init(this.args,null);
      try {
         AuthServer authServer;
         ME = glob.getProperty().get("loginName", ME);
         String loginName = ME;

         String fileName = glob.getProperty().get("dispatch/connection/plugin/ior/iorFile", (String)null); // a file with the IOR string
         String authServerIOR = glob.getProperty().get("dispatch/connection/plugin/ior/iorString", (String)null); // the IOR string "IOR:00405..."

         if (fileName != null) authServerIOR = FileLocator.readAsciiFile(fileName);

         if (authServerIOR != null) {
            authServer = AuthServerHelper.narrow(orb.string_to_object(authServerIOR));
         }
         else {
            // asking Name Service CORBA compliant:
            NamingContext nc = NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
            NameComponent [] name = new NameComponent[1];
            name[0] = new NameComponent();
            name[0].id = "xmlBlaster-Authenticate";
            name[0].kind = "MOM";
            if (nc == null) {
               System.out.println("\nSorry, please pass the server IOR string to the client, e.g.:\n"
                           + "Start the server:\n"
                           + "   jaco org.xmlBlaster.Main -dispatch/connection/plugin/ior/iorFile /tmp/NS_Ref\n"
                           + "Start this client:\n"
                           + "   jaco javaclients.corba.ClientRaw -dispatch/connection/plugin/ior/iorFile /tmp/NS_Ref\n");
               usage();
               System.err.println(ME + ": Read xmlBlaster/INSTALL for help");
               System.exit(1);
            }
            authServer = AuthServerHelper.narrow(nc.resolve(name));
         }

         StopWatch stop = new StopWatch();

         //---------- Building a Callback server ----------------------
         // Getting the default POA implementation "RootPOA"
         org.omg.PortableServer.POA rootPOA =
            org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

         // Intialize my Callback interface:
         BlasterCallbackPOATie callbackTie = new BlasterCallbackPOATie(new RawCallback(args, ME));
         BlasterCallback callback = BlasterCallbackHelper.narrow(rootPOA.servant_to_reference( callbackTie ));

         rootPOA.the_POAManager().activate();

         //----------- Login to the server -----------------------
         try {
            String passwd = "some";

            // Create a XML based qos (quality of service) which hold the IOR (the CORBA
            // address of our callback server)
            String qos = "<qos><callback type='IOR'>";
            qos += orb.object_to_string(callback);
            qos += "</callback></qos>";

            // The xmlBlaster server takes this IOR string and uses it to connect
            // to our client-side callback interface to deliver updates back

            xmlBlaster = authServer.login(loginName, passwd, qos);
            log.info("Login done");
         } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
            log.warning("XmlBlasterException: " + e.getMessage());
         }


         //----------- Subscribe to messages with XPATH -------
         {
            log.fine("Subscribing using XPath syntax ...");
            String xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                           "<key oid='' queryType='XPATH'>\n" +
                           "/xmlBlaster/key/AGENT" +
                           "</key>";
            stop.restart();
            try {
               xmlBlaster.subscribe(xmlKey, "<qos></qos>");
            } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
            log.info("Subscribe done, there should be no Callback" + stop.nice());
         }


         delay(2000); // Wait some time ...


         //----------- Construct a message and publish it ---------
         {
            String xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                            "<key oid='' contentMime='text/xml'>\n" +
                            "  <AGENT id='192.168.124.10' subId='1' type='generic'>" +
                            "    <DRIVER id='FileProof' pollingFreq='10'>" +
                            "    </DRIVER>"+
                            "  </AGENT>" +
                            "</key>";
            String content = "Yeahh, i'm the new content";
            MessageUnit msgUnit = new MessageUnit(xmlKey, content.getBytes(), "<qos></qos>");
            log.info("Publishing ...");
            stop.restart();
            try {
               String publishOid = xmlBlaster.publish(msgUnit);
               log.fine("Returned oid=" + publishOid);
            } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
            log.info("Publishing done, there should be a callback now" + stop.nice());
         }

         delay(1000); // Wait some time ...

         // orb.run(); // Usually your client won't exit after this, uncomment the run() method

         ask("logout()");

         //----------- Logout --------------------------------------
         log.info("Logout ...");
         try {
            authServer.logout(xmlBlaster);
         } catch(org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException e) {
            log.warning("XmlBlasterException: " + e.getMessage());
         }

         //----------- Shutdown my callback server -----------------
View Full Code Here

TOP

Related Classes of org.xmlBlaster.protocol.corba.authenticateIdl.AuthServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.