Package org.candlepin.model

Examples of org.candlepin.model.IdentityCertificate


        ConsumerDto consumer = mock(ConsumerDto.class);
        when(owner.getUpstreamUuid()).thenReturn("another-test-uuid");
        when(consumer.getUuid()).thenReturn("test-uuid");
        when(consumer.getOwner()).thenReturn(owner);

        IdentityCertificate idCert = new IdentityCertificate();
        idCert.setSerial(new CertificateSerial());

        importer.store(owner, consumer,
            new ConflictOverrides(Importer.Conflict.DISTRIBUTOR_CONFLICT), idCert);

        // now verify that the owner has the upstream consumer set
View Full Code Here


        EventSink sink = Mockito.mock(EventSinkImpl.class);

        Consumer consumer = createConsumer();
        consumer.setIdCert(createIdCert());
        IdentityCertificate ic = consumer.getIdCert();
        assertNotNull(ic);

        when(mockedConsumerCurator.verifyAndLookupConsumer(consumer.getUuid())).thenReturn(
            consumer);
        when(mockedIdSvc.regenerateIdentityCert(consumer)).thenReturn(
            createIdCert());

        ConsumerResource cr = new ConsumerResource(mockedConsumerCurator, null,
            null, null, null, mockedIdSvc, null, null, sink, eventFactory, null, null,
            null, null, null, null, mockedOwnerCurator, null, null, null, null,
            null, null, new CandlepinCommonTestConfig(), null, null, null, consumerBindUtil);

        Consumer fooc = cr.regenerateIdentityCertificates(consumer.getUuid());

        assertNotNull(fooc);
        IdentityCertificate ic1 = fooc.getIdCert();
        assertNotNull(ic1);
        assertFalse(ic.equals(ic1));
    }
View Full Code Here

            "priv".getBytes());
        when(idcur.create(any(IdentityCertificate.class))).thenAnswer(
            new Answer<IdentityCertificate>() {
                public IdentityCertificate answer(InvocationOnMock invocation) {
                    Object[] args = invocation.getArguments();
                    IdentityCertificate ic = (IdentityCertificate) args[0];
                    ic.setId("42");
                    return ic;
                }
            });

        IdentityCertificate ic = dicsa.generateIdentityCert(consumer);

        assertNotNull(ic);
        assertEquals("priv", ic.getKey());
        assertEquals("x509cert", ic.getCert());
        assertNotNull(ic.getCertAsBytes());
        assertNotNull(ic.getKeyAsBytes());
        verify(consumer).setIdCert(ic);
        verify(csc).create(any(CertificateSerial.class));
    }
View Full Code Here

    }

    @Test
    public void testReturnExisting() throws GeneralSecurityException, IOException {
        Consumer consumer = mock(Consumer.class);
        IdentityCertificate mockic = mock(IdentityCertificate.class);

        when(consumer.getIdCert()).thenReturn(mockic);
        when(idcur.find(mockic.getId())).thenReturn(mockic);
        when(idcur.find(consumer.getId())).thenReturn(mockic);

        IdentityCertificate ic = dicsa.generateIdentityCert(consumer);

        assertNotNull(ic);
        assertEquals(ic, mockic);
    }
View Full Code Here

    }

    @Test
    public void testRegenerateCallsDeletes() throws GeneralSecurityException, IOException {
        Consumer consumer = mock(Consumer.class);
        IdentityCertificate mockic = mock(IdentityCertificate.class);
        when(consumer.getIdCert()).thenReturn(mockic);
        when(mockic.getId()).thenReturn("43");
        when(idcur.find(mockic.getId())).thenReturn(mockic);


        KeyPair kp = createKeyPair();
        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(
            "x509cert".getBytes());
        when(pki.getPemEncoded(any(PrivateKey.class))).thenReturn(
            "priv".getBytes());
        when(idcur.create(any(IdentityCertificate.class))).thenAnswer(
            new Answer<IdentityCertificate>() {
                public IdentityCertificate answer(InvocationOnMock invocation) {
                    Object[] args = invocation.getArguments();
                    IdentityCertificate ic = (IdentityCertificate) args[0];
                    ic.setId("42");
                    return ic;
                }
            });

        IdentityCertificate ic = dicsa.regenerateIdentityCert(consumer);

        verify(consumer).setIdCert(null);
        verify(idcur).delete(mockic);
        assertNotSame(ic, mockic);
        assertEquals("priv", ic.getKey());
        assertEquals("x509cert", ic.getCert());
        assertNotNull(ic.getCertAsBytes());
        assertNotNull(ic.getKeyAsBytes());
        verify(consumer).setIdCert(ic);
        verify(csc).create(any(CertificateSerial.class));

    }
View Full Code Here

            "priv".getBytes());
        when(idcur.create(any(IdentityCertificate.class))).thenAnswer(
            new Answer<IdentityCertificate>() {
                public IdentityCertificate answer(InvocationOnMock invocation) {
                    Object[] args = invocation.getArguments();
                    IdentityCertificate ic = (IdentityCertificate) args[0];
                    ic.setId("42");
                    return ic;
                }
            });

        IdentityCertificate ic = dicsa.regenerateIdentityCert(consumer);

        assertNotNull(ic);
        verify(consumer, never()).setIdCert(null);
        verify(idcur, never()).delete(any(IdentityCertificate.class));
        assertEquals("priv", ic.getKey());
        assertEquals("x509cert", ic.getCert());
        assertNotNull(ic.getCertAsBytes());
        assertNotNull(ic.getKeyAsBytes());
        verify(consumer).setIdCert(ic);
        verify(csc).create(any(CertificateSerial.class));

    }
View Full Code Here

        when(complianceRules.getStatus(any(Consumer.class), any(Date.class),
                any(Boolean.class), any(Boolean.class)))
            .thenReturn(new ComplianceStatus(new Date()));

        when(idCertService.regenerateIdentityCert(any(Consumer.class)))
            .thenReturn(new IdentityCertificate());

        when(consumerEventBuilder.setNewEntity(any(Consumer.class)))
            .thenReturn(consumerEventBuilder);
        when(consumerEventBuilder.setOldEntity(any(Consumer.class)))
            .thenReturn(consumerEventBuilder);
View Full Code Here

            }
        });
        when(consumerTypeCurator.lookupByLabel(system.getLabel())).thenReturn(system);
        when(userService.findByLogin(USER)).thenReturn(user);
        when(idCertService.generateIdentityCert(any(Consumer.class)))
                .thenReturn(new IdentityCertificate());
        when(ownerCurator.lookupByKey(owner.getKey())).thenReturn(owner);
        when(complianceRules.getStatus(any(Consumer.class),
                any(Date.class), any(Boolean.class), any(Boolean.class)))
                .thenReturn(new ComplianceStatus(new Date()));
    }
View Full Code Here

    public Consumer getConsumer(
        @PathParam("consumer_uuid") @Verify(Consumer.class) String uuid) {
        Consumer consumer = consumerCurator.verifyAndLookupConsumer(uuid);

        if (consumer != null) {
            IdentityCertificate idcert = consumer.getIdCert();
            Date expire = idcert.getSerial().getExpiration();
            int days = config.getInt(ConfigProperties.IDENTITY_CERT_EXPIRY_THRESHOLD, 90);
            Date futureExpire = Util.addDaysToDt(days);
            // if expiration is within 90 days, regenerate it
            if (log.isDebugEnabled()) {
                log.debug("Threshold [" + days + "] expires on [" + expire +
View Full Code Here

        consumerBindUtil.validateServiceLevel(owner, consumer.getServiceLevel());

        try {
            consumer = consumerCurator.create(consumer);
            IdentityCertificate idCert = generateIdCert(consumer, false);
            consumer.setIdCert(idCert);

            sink.emitConsumerCreated(consumer);

            if (keys.size() > 0) {
View Full Code Here

TOP

Related Classes of org.candlepin.model.IdentityCertificate

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.