Package org.candlepin.model

Examples of org.candlepin.model.CertificateSerial


        when(kpc.getConsumerKeyPair(consumer)).thenReturn(kp);
        when(csc.create(any(CertificateSerial.class))).thenAnswer(
            new Answer<CertificateSerial>() {
                public CertificateSerial answer(InvocationOnMock invocation) {
                    Object[] args = invocation.getArguments();
                    CertificateSerial cs = (CertificateSerial) args[0];
                    cs.setId(42L);
                    return cs;
                }
            });

        when(pki.getPemEncoded(any(X509Certificate.class))).thenReturn(
View Full Code Here


        return createSubCert(key, cert, new Date());
    }

    protected SubscriptionsCertificate createSubCert(String key, String cert, Date dt) {
        SubscriptionsCertificate sc = new SubscriptionsCertificate();
        CertificateSerial ser = new CertificateSerial(dt);
        certSerialCurator.create(ser);
        sc.setCert(cert);
        sc.setKey(key);
        sc.setSerial(ser);
        return sc;
View Full Code Here

        log.debug("   consumer: " + entitlement.getConsumer().getUuid());
        log.debug("   product: " + product.getId());
        log.debug("   end date: " + entitlement.getEndDate());

        EntitlementCertificate cert = new EntitlementCertificate();
        CertificateSerial serial = new CertificateSerial(entitlement.getEndDate());
        serialCurator.create(serial);

        cert.setSerial(serial);
        cert.setKeyAsBytes(("---- STUB KEY -----" + Math.random())
            .getBytes());
        cert.setCertAsBytes(("---- STUB CERT -----" + Math.random())
            .getBytes());
        cert.setEntitlement(entitlement);
        entitlement.getCertificates().add(cert);

        log.debug("Generated cert: " + serial.getId());
        log.debug("Key: " + cert.getKey());
        log.debug("Cert: " + cert.getCert());
        entCertCurator.create(cert);

        return cert;
View Full Code Here

        when(mockedPKI.getPemEncoded(any(X509Certificate.class))).thenReturn(
            "".getBytes());
        when(mockedPKI.getPemEncoded(any(Key.class))).thenReturn("".getBytes());

        CertificateSerial serial = mock(CertificateSerial.class);
        when(serial.getId()).thenReturn(1L);
        when(serialCurator.create(any(CertificateSerial.class))).thenReturn(serial);

        EntitlementCertificate cert =
            certServiceAdapter.generateEntitlementCert(entitlement, subscription,
                product);
View Full Code Here

         * certificate. Presumably this is to prevent potential conflicts with
         * a serial that came from somewhere else. This is consistent with
         * importing entitlement certs (as subscription certs).
         */
        if (idcert != null) {
            CertificateSerial cs = new CertificateSerial();
            cs.setCollected(idcert.getSerial().isCollected());
            cs.setExpiration(idcert.getSerial().getExpiration());
            cs.setUpdated(idcert.getSerial().getUpdated());
            cs.setCreated(idcert.getSerial().getCreated());
            serialCurator.create(cs);

            idcert.setId(null);
            idcert.setSerial(cs);
            idCertCurator.create(idcert);
View Full Code Here

        // subscriptions have one cert
        int entcnt = 0;
        for (EntitlementCertificate cert : certs) {
            entcnt++;
            CertificateSerial cs = new CertificateSerial();
            cs.setCollected(cert.getSerial().isCollected());
            cs.setExpiration(cert.getSerial().getExpiration());
            cs.setUpdated(cert.getSerial().getUpdated());
            cs.setCreated(cert.getSerial().getCreated());
            csCurator.create(cs);
            SubscriptionsCertificate sc = new SubscriptionsCertificate();
            sc.setKey(cert.getKey());
            sc.setCertAsBytes(cert.getCertAsBytes());
            sc.setSerial(cs);
View Full Code Here

        return this.new CertSerialBuilder();
    }

    @Test
    public void testSerialCreation() {
        CertificateSerial serial = new CertificateSerial(new Date());
        serial = certSerialCurator.create(serial);
        assertNotNull(serial);
        assertNotNull(serial.getId());
    }
View Full Code Here

     */
    private Set<Date> extractExpiredDates(List<CertificateSerial> lcs) {
        Set<Date> dates = newSet();
        for (Iterator<CertificateSerial> iterator = lcs.iterator(); iterator
            .hasNext();) {
            CertificateSerial certificateSerial = iterator.next();
            dates.add(certificateSerial.getExpiration());
        }
        return dates;
    }
View Full Code Here

        assertEquals(3, this.certSerialCurator.deleteExpiredSerials());
    }

    @Test
    public void testListBySerialIds() {
        CertificateSerial serial = createCS().withExpDate("03/10/2010")
            .collected(false).revoked(false).save();
        CertificateSerial serial1 = createCS().withExpDate("03/10/2012")
            .collected(true).revoked(true).save();

        String[] ids = new String[2];
        ids[0] = String.valueOf(serial.getSerial());
        ids[1] = String.valueOf(serial1.getSerial());

        List<CertificateSerial> serials = certSerialCurator.listBySerialIds(ids);
        assertEquals(2, serials.size());

        // verify
        Map<BigInteger, CertificateSerial> values =
            new HashMap<BigInteger, CertificateSerial>();

        for (CertificateSerial s : serials) {
            values.put(s.getSerial(), s);
        }

        assertNotNull(values.get(serial.getSerial()));
        assertNotNull(values.get(serial1.getSerial()));
    }
View Full Code Here

            this.revoked = re;
            return this;
        }

        public CertificateSerial save() {
            CertificateSerial serial = new CertificateSerial(dt);
            serial.setCollected(collected);
            serial = certSerialCurator.create(serial);
            if (!this.revoked) {
                serial = createEntitlementCertificate(serial).getSerial();
            }
            return serial;
View Full Code Here

TOP

Related Classes of org.candlepin.model.CertificateSerial

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.