Package org.ejbca.core.model.ca.publisher

Examples of org.ejbca.core.model.ca.publisher.PublisherQueueData


        publisherQueueSession.addQueueData(12345, PublisherConst.PUBLISH_TYPE_CERT, "TestPublishQueueProcessService12345", null,
                PublisherConst.STATUS_PENDING);
        Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(12345);
        assertEquals(1, c.size());
        Iterator<PublisherQueueData> i = c.iterator();
        PublisherQueueData d = i.next();
        assertEquals(0, d.getTryCounter());

        // Create a new PublisherQueueProcess service
        ServiceConfiguration config = new ServiceConfiguration();
        config.setActive(true);
        config.setDescription("This is a description");
        // No mailsending for this Junit test service
        config.setActionClassPath(NoAction.class.getName());
        config.setActionProperties(null);
        config.setIntervalClassPath(PeriodicalInterval.class.getName());
        Properties intervalprop = new Properties();
        // Run the service every 3:rd second
        intervalprop.setProperty(PeriodicalInterval.PROP_VALUE, "3");
        intervalprop.setProperty(PeriodicalInterval.PROP_UNIT, PeriodicalInterval.UNIT_SECONDS);
        config.setIntervalProperties(intervalprop);
        config.setWorkerClassPath(PublishQueueProcessWorker.class.getName());
        Properties workerprop = new Properties();
        workerprop.setProperty(PublishQueueProcessWorker.PROP_PUBLISHER_IDS, "12345");
        config.setWorkerProperties(workerprop);

        serviceSession.addService(admin, "TestPublishQueueProcessService12345", config);
        serviceSession.activateServiceTimer(admin, "TestPublishQueueProcessService12345");

        // The service will run...
        Thread.sleep(5000);

        // Now the publisher 12345 will not have existed so we should have
        // updated the publish entry's tryCounter
        c = publisherQueueSession.getEntriesByFingerprint("TestPublishQueueProcessService12345");
        assertEquals(1, c.size());
        i = c.iterator();
        d = i.next();
        assertEquals("Service should have run at least one time and updated trycounter.", 1, d.getTryCounter());
        assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
    }
View Full Code Here


        publisherQueueSession.addQueueData(publisherId, PublisherConst.PUBLISH_TYPE_CERT, CertTools.getFingerprintAsString(testcert), null,
                PublisherConst.STATUS_PENDING);
        Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(publisherId);
        assertEquals(1, c.size());
        Iterator<PublisherQueueData> i = c.iterator();
        PublisherQueueData d = i.next();
        assertEquals(0, d.getTryCounter());

        // Create a new PublisherQueueProcess service
        ServiceConfiguration config = new ServiceConfiguration();
        config.setActive(true);
        config.setDescription("This is a description");
        // No mailsending for this Junit test service
        config.setActionClassPath(NoAction.class.getName());
        config.setActionProperties(null);
        config.setIntervalClassPath(PeriodicalInterval.class.getName());
        Properties intervalprop = new Properties();
        // Run the service every 3:rd second
        intervalprop.setProperty(PeriodicalInterval.PROP_VALUE, "3");
        intervalprop.setProperty(PeriodicalInterval.PROP_UNIT, PeriodicalInterval.UNIT_SECONDS);
        config.setIntervalProperties(intervalprop);
        config.setWorkerClassPath(PublishQueueProcessWorker.class.getName());
        Properties workerprop = new Properties();
        workerprop.setProperty(PublishQueueProcessWorker.PROP_PUBLISHER_IDS, String.valueOf(publisherId));
        config.setWorkerProperties(workerprop);

        serviceSession.addService(admin, "TestPublishQueueProcessService", config);
        serviceSession.activateServiceTimer(admin, "TestPublishQueueProcessService");

        // Let the service run and publish the entry
        Thread.sleep(5000);
        // Now the entry should be published
        // Now the publisher will not have existed so we should have updated the
        // publish entry's tryCounter
        c = publisherQueueSession.getEntriesByFingerprint(CertTools.getFingerprintAsString(testcert));
        assertEquals(1, c.size());
        i = c.iterator();
        d = i.next();
        assertEquals(0, d.getTryCounter());
        assertEquals(PublisherConst.STATUS_SUCCESS, d.getPublishStatus());
    }
View Full Code Here

     */
    public void test99CleanUp() throws Exception {
        Collection<PublisherQueueData> c = publisherQueueSession.getEntriesByFingerprint("TestPublishQueueProcessService12345");
        Iterator<PublisherQueueData> i = c.iterator();
        while (i.hasNext()) {
            PublisherQueueData d = i.next();
            try {
                publisherQueueSession.removeQueueData(d.getPk());
            } catch (Exception pee) {
            }
        }
        c = publisherQueueSession.getEntriesByFingerprint(CertTools.getFingerprintAsString(testcert));
        i = c.iterator();
        while (i.hasNext()) {
            PublisherQueueData d = i.next();
            publisherQueueSession.removeQueueData(d.getPk());

        }

        serviceSession.removeService(admin, "TestPublishQueueProcessService12345");
        serviceSession.removeService(admin, "TestPublishQueueProcessService");
View Full Code Here

      Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(12345);
      assertEquals(0, c.size());
      c = publisherQueueSession.getPendingEntriesForPublisher(123456);
      assertEquals(1, c.size());
      Iterator<PublisherQueueData> i = c.iterator();
      PublisherQueueData d = i.next();
      assertEquals("XX", d.getFingerprint());
      Date lastUpdate1 = d.getLastUpdate();
      assertNotNull(lastUpdate1);
      assertNotNull(d.getTimeCreated());
      assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
      assertEquals(0,d.getTryCounter());
      assertNull(d.getVolatileData());
     
      String xxpk = d.getPk(); // Keep for later so we can set to success
     
      PublisherQueueVolatileData vd = new PublisherQueueVolatileData();
      vd.setUsername("foo");
      vd.setPassword("bar");
      ExtendedInformation ei = new ExtendedInformation();
      ei.setSubjectDirectoryAttributes("directoryAttr");
      vd.setExtendedInformation(ei);
      publisherQueueSession.addQueueData(123456, PublisherConst.PUBLISH_TYPE_CRL, "YY", vd, PublisherConst.STATUS_PENDING);
     
      c = publisherQueueSession.getPendingEntriesForPublisher(123456);
      assertEquals(2, c.size());
      boolean testedXX = false;
      boolean testedYY = false;
      i = c.iterator();
      while (i.hasNext()) {
          d = i.next();
          if (d.getFingerprint().equals("XX")) {
            assertEquals(PublisherConst.PUBLISH_TYPE_CERT, d.getPublishType());
              assertNotNull(d.getLastUpdate());
              assertNotNull(d.getTimeCreated());
              assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
              assertEquals(0,d.getTryCounter());
              testedXX = true;
          }
          if (d.getFingerprint().equals("YY")) {
            assertEquals(PublisherConst.PUBLISH_TYPE_CRL, d.getPublishType());
              assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
              assertEquals(0,d.getTryCounter());
              PublisherQueueVolatileData v = d.getVolatileData();
              assertEquals("bar", v.getPassword());
              assertEquals("foo", v.getUsername());
              ExtendedInformation e = v.getExtendedInformation();
              assertNotNull(e);
              assertEquals("directoryAttr", e.getSubjectDirectoryAttributes());
              testedYY = true;
          }
      }
      assertTrue(testedXX);
      assertTrue(testedYY);
     
      publisherQueueSession.updateData(xxpk, PublisherConst.STATUS_SUCCESS, 4);
      c = publisherQueueSession.getEntriesByFingerprint("XX");
      assertEquals(1, c.size());
      i = c.iterator();
      d = i.next();
      assertEquals("XX", d.getFingerprint());
      Date lastUpdate2 = d.getLastUpdate();
      assertTrue(lastUpdate2.after(lastUpdate1));
      assertNotNull(d.getTimeCreated());
      assertEquals(PublisherConst.STATUS_SUCCESS, d.getPublishStatus());
      assertEquals(4,d.getTryCounter());     
    }
View Full Code Here

       
        // Now this certificate fingerprint should be in the queue
      Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(id);
      assertEquals(1, c.size());
      Iterator<PublisherQueueData> i = c.iterator();
      PublisherQueueData d = i.next();
      assertEquals(CertTools.getFingerprintAsString(cert), d.getFingerprint());
      log.trace("<test02ExternalOCSPPublisherFail");
    }
View Full Code Here

       
        // Now this certificate fingerprint should be in the queue
      Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(id);
      assertEquals(1, c.size());
      Iterator<PublisherQueueData> i = c.iterator();
      PublisherQueueData d = i.next();
      assertEquals(CertTools.getFingerprintAsString(cert), d.getFingerprint());
      log.trace("<test04ExternalOCSPPublisherOnlyUseQueue");
    }
View Full Code Here

   
    public void test99CleanUp() throws Exception {
      Collection<PublisherQueueData> c = publisherQueueSession.getEntriesByFingerprint("XX");
      Iterator<PublisherQueueData> i = c.iterator();
      while (i.hasNext()) {
        PublisherQueueData d = i.next();
        publisherQueueSession.removeQueueData(d.getPk());
      }   
      c = publisherQueueSession.getEntriesByFingerprint("YY");
      i = c.iterator();
      while (i.hasNext()) {
        PublisherQueueData d = i.next();
        publisherQueueSession.removeQueueData(d.getPk());
      }   
      c = publisherQueueSession.getEntriesByFingerprint(CertTools.getFingerprintAsString(testcert));
      i = c.iterator();
      while (i.hasNext()) {
        PublisherQueueData d = i.next();
        publisherQueueSession.removeQueueData(d.getPk());
      }   

      try {
        publisherSession.removePublisher(admin, "TESTEXTOCSPQUEUE");           
      } catch (Exception pee) {}
View Full Code Here

      }
      Collection<PublisherQueueData> ret = new ArrayList<PublisherQueueData>();
      Iterator<org.ejbca.core.ejb.ca.publisher.PublisherQueueData> iter = datas.iterator();
      while (iter.hasNext()) {
        org.ejbca.core.ejb.ca.publisher.PublisherQueueData d = iter.next();
        PublisherQueueData pqd = new PublisherQueueData(d.getPk(), new Date(d.getTimeCreated()), new Date(d.getLastUpdate()), d.getPublishStatus(), d.getTryCounter(), d.getPublishType(), d.getFingerprint(), d.getPublisherId(), d.getPublisherQueueVolatileData());
        ret.add(pqd);
      }     
    log.trace("<getPendingEntriesForPublisher()");
      return ret;
    }
View Full Code Here

      Collection<PublisherQueueData> ret = new ArrayList<PublisherQueueData>()
        //TODO: This code has been modified from JDBC to JPA fetching, which might negatively affect performance. Investigate.
        List<org.ejbca.core.ejb.ca.publisher.PublisherQueueData> publisherQueueDataList = org.ejbca.core.ejb.ca.publisher.PublisherQueueData
                .findDataByPublisherIdAndStatus(entityManager, publisherId, PublisherConst.STATUS_PENDING, limit);
        for (org.ejbca.core.ejb.ca.publisher.PublisherQueueData publisherQueueData : publisherQueueDataList) {
            PublisherQueueData pqd = new PublisherQueueData(publisherQueueData.getPk(), new Date(publisherQueueData.getTimeCreated()), new Date(
                    publisherQueueData.getLastUpdate()), PublisherConst.STATUS_PENDING, publisherQueueData.getTryCounter(),
                    publisherQueueData.getPublishType(), publisherQueueData.getFingerprint(), publisherId, publisherQueueData.getPublisherQueueVolatileData());
            ret.add(pqd);
            if (log.isDebugEnabled()) {
                log.debug("Return pending record with pk " + publisherQueueData.getPk() + ", and timeCreated "
View Full Code Here

      log.debug("No publisher queue entries found for fingerprint "+fingerprint);
    } else {
        Iterator<org.ejbca.core.ejb.ca.publisher.PublisherQueueData> iter = datas.iterator();
        while (iter.hasNext()) {
          org.ejbca.core.ejb.ca.publisher.PublisherQueueData d = iter.next();
          PublisherQueueData pqd = new PublisherQueueData(d.getPk(), new Date(d.getTimeCreated()), new Date(d.getLastUpdate()), d.getPublishStatus(), d.getTryCounter(), d.getPublishType(), d.getFingerprint(), d.getPublisherId(), d.getPublisherQueueVolatileData());
          ret.add(pqd);
        }     
    }
    log.trace("<getEntriesByFingerprint()");
      return ret;
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.publisher.PublisherQueueData

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.