Package org.openxri.xml

Examples of org.openxri.xml.Service


      String serviceText = FileStore.readLine(fileService);

      Document document = this.builder.parse(serviceText);
      Element element = document.getDocumentElement();
      services.add(new Service(element));
    }

    // done

    return(services);
View Full Code Here


    * @throws URISyntaxException
    */
    protected Service getRootAuthority()
        throws URISyntaxException, XMLSecurityException
    {
        Service oAuthority = new Service();
        oAuthority.addURI(new SEPUri(ssRootURI + "?ns=at"));

        // Add encrypted Root URI
        oAuthority.addURI(new SEPUri(ssEncryptedRootURI + "?ns=at"));

        /* there is no more such concept as TrustedURIs
        oAuthority.getTrustedURIs().add(new URI(ssRootURI + "?ns=at"));
        oAuthority.getTrustedURIs().add(new URI(ssEncryptedRootURI + "?ns=at"));
        */
       
        oAuthority.setProviderID(moAuth.getProviderID());

        KeyInfo oKeyInfo = null;
        if (moCertChain != null)
        {
            Document oDoc = new DocumentImpl();
            oKeyInfo = new KeyInfo(oDoc);
            X509Data oData = new X509Data(oDoc);
            oData.addCertificate(moCertChain[0]);
            oKeyInfo.add(oData);
            oAuthority.setKeyInfo(oKeyInfo);
        }

        return oAuthority;

    } // getRootAuthority()
View Full Code Here

  }

  private XRD makeSampleXRD() {

    XRD xrd = new XRD();
    Service defaultService;

    try {

      defaultService = new DefaultService(new URI("http://www.openxri.org"));
      xrd.addService(defaultService);
View Full Code Here

      SEPTemplatesModel importSEPTemplatesModel = new SEPTemplatesModel();

      this.serviceTextArea = new TextArea("service");
      this.serviceTextArea.setOutputMarkupId(true);
      this.templateDropDownChoice = new DropDownChoice("template", new Model(new Service()), importSEPTemplatesModel, importSEPTemplatesModel);
      this.loadTemplateButton = new AjaxSubmitLink("loadTemplateButton", this) {

        private static final long serialVersionUID = -4311234326704642467L;

        @Override
View Full Code Here

    public void testCreateAuthority()
    {
        // Create an authority
        try
        {
            Service oAuth = moAdmin.createAuthority();
            assertNotNull(oAuth);
            assertNotNull(oAuth.getProviderID());
            assertTrue(oAuth.getNumURIs() > 0);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
View Full Code Here

    *
    */
    public void testStore()
    {
        // Keep an authority around
      Service oAuth = null;

        ///
        // List namespaces, none present
        ///
        try
        {
            assertEquals(0, moAdmin.listRootAuthorities().length);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Create a root authority
        ///
        try
        {
            oAuth = moAdmin.createRootAuthority("SomeNS");
            assertNotNull(oAuth);
            assertNotNull(oAuth.getProviderID());
            assertTrue(oAuth.getNumURIs() > 0);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Create a duplicate root authority
        ///
        try
        {
            oAuth = moAdmin.createRootAuthority("SomeNS");
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_DUPNAME, oEx.getExKey());
        }

        ///
        // NEW Create a null-namespace root authority.
        // Passing null via IIOP is a no-no.
        ///
        boolean bIIOPFailure = false;
        try
        {
            moAdmin.createRootAuthority(null);
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_NOTFOUND, oEx.getExKey());
        }
        catch (BAD_PARAM oEx)
        {
            // Expected that
            bIIOPFailure = true;
        }

        ///
        // Find an existing namespace
        ///
        try
        {
          Service oAuth2 = moAdmin.findRootAuthority("SomeNS");

            assertNotNull(oAuth2);
            assertNotNull(oAuth2.getProviderID());
            assertTrue(oAuth.getNumURIs() > 0);
            assertEquals(oAuth.getProviderID(), oAuth2.getProviderID());
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Find a non-existent namespace
        ///
        try
        {
            moAdmin.findRootAuthority("nonexistent");
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_NOTFOUND, oEx.getExKey());
        }

        ///
        // NEW Find a null namespace
        // What should the outcome of this test be?
        ///
        bIIOPFailure = false;
        try
        {
            moAdmin.findRootAuthority(null);
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_NOTFOUND, oEx.getExKey());
        }
        catch (BAD_PARAM oEx)
        {
            // Expected that
            bIIOPFailure = true;
        }

        ///
        // Register a subsegment
        ///
        bIIOPFailure = false;
        try
        {
            Service[] oLocals = new Service[0];
            String[] oInternals = new String[0];
            String[] oExternals = new String[0];
            Service oSubAuth = new Service();
            moAdmin.registerSubsegment(
                oAuth.getProviderID(), ".foo", oLocals, oInternals, oExternals,
                oSubAuth);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }
        catch (BAD_PARAM oEx)
        {
            // Expected that
            bIIOPFailure = true;
        }

        ///
        // Perform an IIOP-safe registration of a subsegment
        ///
        if (bIIOPFailure)
        {
            try
            {
                Service[] oLocals = new Service[0];
                String[] oInternals = new String[0];
                String[] oExternals = new String[0];

                // IIOP-safe authority
                Service oSubAuth = new Service();

                moAdmin.registerSubsegment(
                    oAuth.getProviderID(), ".foo", oLocals, oInternals,
                    oExternals, oSubAuth);
            }
            catch (StoreException oEx)
            {
                oEx.printStackTrace();
                fail(
                    "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                    oEx.getExMessage() + "'.");
            }

        } // if(bIIOPFailure)

        bIIOPFailure = false;

        ///
        // Register a duplicate subsegment
        ///
        try
        {
            Service[] oLocals = new Service[0];
            String[] oInternals = new String[0];
            String[] oExternals = new String[0];

            // IIOP-safe authority
            Service oSubAuth = new Service();

            moAdmin.registerSubsegment(
                oAuth.getProviderID(), ".foo", oLocals, oInternals, oExternals,
                oSubAuth);
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_DUPNAME, oEx.getExKey());
        }

        ///
        // NEW Retrieve a descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth.getProviderID(), ".foo", false)
                       .getDescriptor();
            assertNotNull(sDescriptor);
            assertTrue(sDescriptor.length() > 0);

            // XXX is the value correct?
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Release a subsegment
        ///
        try
        {
            moAdmin.releaseSubsegment(oAuth.getProviderID(), ".foo");
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Release a subsegment
        ///
        try
        {
            moAdmin.releaseSubsegment(oAuth.getProviderID(), ".foo");
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(Util.KEY_NOTFOUND, oEx.getExKey());
        }

        ///
        // NEW Retrieve a deleted descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth.getProviderID(), ".foo", false)
                       .getDescriptor();
            assertNull(sDescriptor);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Register a subsegment
        ///
        try
        {
            Service[] oLocals = new Service[0];
            String[] oInternals = new String[0];
            String[] oExternals = new String[0];

            // IIOP-safe authority
            Service oSubAuth = new Service();

            moAdmin.registerSubsegment(
                oAuth.getProviderID(), ".foo", oLocals, oInternals, oExternals,
                oSubAuth);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // NEW Retrieve a re-registered descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth.getProviderID(), ".foo", false)
                       .getDescriptor();
            assertNotNull(sDescriptor);
            assertTrue(sDescriptor.length() > 0);

            // XXX is the value correct?
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Register a local authority
        ///
        try
        {
            Service[] oLocals = new Service[0];
            String[] oInternals = new String[0];
            String[] oExternals = new String[0];
            Service oSubAuth =
                moAdmin.registerLocalAuthority(
                    oAuth.getProviderID(), ".boo", oLocals, oInternals,
                    oExternals);

            assertNotNull(oSubAuth);
            assertNotNull(oSubAuth.getProviderID());
            assertTrue(oSubAuth.getProviderID() != "");
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Delete a namespace (root authority)
        ///
        try
        {
            moAdmin.deleteRootAuthority("SomeNS");
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Delete an authority
        ///
        try
        {
            moAdmin.deleteAuthority(oAuth.getProviderID());
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Delete an authority
        ///
        try
        {
            moAdmin.deleteAuthority(oAuth.getProviderID());
        }
        catch (StoreException oEx)
        {
            fail("Received unexpected exception " + oEx.getExMessage());
        }

        ///
        // Retrieve the list of namespaces (no leftovers)
        ///
        try
        {
            assertEquals(0, moAdmin.listRootAuthorities().length);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // One last, comprehensive test
        ///
        Service oDefaultAuth = null;
        Service oHostIDAuth = null;
        try
        {
            Service[] oServices = new Service[1];

            // IIOP-safe Service structure
            oServices[0] = new Service();
            oServices[0].setType("xri:@epok/tdx/xrixns");
            oServices[0].setMediaType("text/xml");
            oServices[0].addURI("xri://@!42!3");

            oHostIDAuth = moAdmin.createRootAuthority("hostid");
            oDefaultAuth = moAdmin.createRootAuthority("default");

            Service oNewAuth =
                moAdmin.registerLocalAuthority(
                    oDefaultAuth.getProviderID(), ".email", oServices,
                    new String[0], new String[0]);

            // IIOP-safe Authority
            Service oEmptyAuth = new Service();

            moAdmin.registerSubsegment(
                oNewAuth.getProviderID(), ".chetan", new Service[0],
                new String[0], new String[0], oEmptyAuth);

            moAdmin.releaseSubsegment(oNewAuth.getProviderID(), ".chetan");
            System.out.println("");

            // List namespaces
            String[] oNamespaces = moAdmin.listRootAuthorities();
            for (int x = 0; x < oNamespaces.length; x++)
            {
                System.out.println("Namespace " + x + ": " + oNamespaces[x]);

                // Account for stale namespaces
                try
                {
                  Service oRootAuth =
                        moAdmin.findRootAuthority(oNamespaces[x]);
                    System.out.println("  ID " + oRootAuth.getProviderID());
                }
                catch (StoreException oEx)
                {
                    System.out.println("  No Authority");
                }
            }
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // A little performace test.  One thread.
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oDefaultAuth.getProviderID(), ".email", false)
                       .getDescriptor();

            assertNotNull(sDescriptor);
            assertTrue(sDescriptor.length() > 0);

            int iCount = 1000;
            long lStamp = System.currentTimeMillis();
            for (int x = 0; x < iCount; x++)
            {
                moAdmin.lookup(oDefaultAuth.getProviderID(), ".email", false);
            }
            lStamp = System.currentTimeMillis() - lStamp;

            System.err.println(
                iCount + " descriptor retrievals took " + lStamp + "ms.");
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Multiple threads.
        ///
        Thread[] oThreads = new Thread[10];
        for (int x = 0; x < 10; x++)
        {
            oThreads[x] =
                new Thread(
                    new DescriptorRetriever(
                        moAdmin, oDefaultAuth.getProviderID(), ".email", 1000));
        }

        long lStamp = System.currentTimeMillis();

        for (int x = 0; x < 10; x++)
        {
            oThreads[x].start();
        }

        for (int x = 0; x < 10; x++)
        {
            try
            {
                oThreads[x].join();
            }
            catch (InterruptedException oEx) {}
        }

        lStamp = System.currentTimeMillis() - lStamp;

        System.err.println(
            (10 * 1000) + " descriptor retrievals took " + lStamp + "ms.");

        // clean up namespaces;
        try
        {
            String[] oNamespaces = moAdmin.listRootAuthorities();
            for (int x = 0; x < oNamespaces.length; x++)
            {
                System.out.println(
                    "Deleting Namespace " + x + ": " + oNamespaces[x]);
                Service oCurrentAuth =
                    moAdmin.findRootAuthority(oNamespaces[x]);
                moAdmin.deleteRootAuthority(oNamespaces[x]);
                moAdmin.deleteAuthority(oCurrentAuth.getProviderID());
            }
        }
        catch (StoreException e)
        {
            assertTrue(
View Full Code Here

    log.trace("assemble()");

    if (cached == null) return(null);

    Service service;
    String serviceText = (String) cached;

    try {

      Document document = this.builder.parse(serviceText);
      Element element = document.getDocumentElement();
      service = new Service(element);
    } catch (Exception ex) {

      throw new HibernateException("Cannot assemble service.", ex);
    }
View Full Code Here

    log.trace("disassemble()");

    if (value == null) return(null);

    Service service = (Service) value;
    String serviceText;

    try {

      Document doc = this.builder.newDocument();
      Node element = service.toDOM(doc);
      doc.appendChild(element);
      serviceText = DOMUtils.toString((Element) element, true, true);
    } catch (Exception ex) {

      throw new HibernateException("Cannot disassemble service.", ex);
View Full Code Here

    log.trace("equals()");

    if (x == null || y == null) return(false);

    Service service1 = (Service) x;
    Service service2 = (Service) y;

    boolean result = (service1 == service2)// TODO change this to Service.equals()

    log.trace("Done: " + result);
    return(result)
View Full Code Here

    log.trace("hashCode()");

    if (x == null) return(0);

    Service service = (Service) x;

    return(service.hashCode());
  }
View Full Code Here

TOP

Related Classes of org.openxri.xml.Service

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.