Package org.candlepin.model

Examples of org.candlepin.model.EntitlementCertificate


        Product prod = new Product("id" + TestUtil.randomInt(), "test");
        this.productCurator.create(prod);
        Pool p = this.createPoolAndSub(owner, prod, 10L, new Date(),
            new Date(new Date().getTime() + 100000L));

        EntitlementCertificate toReturn = new EntitlementCertificate();
        toReturn.setKeyAsBytes("key".getBytes());
        toReturn.setCertAsBytes("cert".getBytes());
        toReturn.setSerial(serial);
        Entitlement e = this.createEntitlement(owner, c, p, toReturn);
        this.entitlementCurator.create(e);
        return toReturn;
    }
View Full Code Here


        X509Certificate x509Cert = createX509Certificate(entitlement,
            product, products, BigInteger.valueOf(serial.getId()), keyPair,
            !thisIsUeberCert);

        EntitlementCertificate cert = new EntitlementCertificate();
        cert.setSerial(serial);
        cert.setKeyAsBytes(pki.getPemEncoded(keyPair.getPrivate()));

        products.add(product);
        Map<String, EnvironmentContent> promotedContent = getPromotedContent(entitlement);
        String contentPrefix = getContentPrefix(entitlement, !thisIsUeberCert);

        String pem = new String(this.pki.getPemEncoded(x509Cert));

        if (shouldGenerateV3(entitlement)) {
            byte[] payloadBytes = v3extensionUtil.createEntitlementDataPayload(products,
                entitlement, contentPrefix, promotedContent);
            String payload = "-----BEGIN ENTITLEMENT DATA-----\n";
            payload += Util.toBase64(payloadBytes);
            payload += "-----END ENTITLEMENT DATA-----\n";

            byte[] bytes = pki.getSHA256WithRSAHash(new ByteArrayInputStream(payloadBytes));
            String signature = "-----BEGIN RSA SIGNATURE-----\n";
            signature += Util.toBase64(bytes);
            signature += "-----END RSA SIGNATURE-----\n";

            pem += payload + signature;
        }

        cert.setCert(pem);

        cert.setEntitlement(entitlement);

        if (log.isDebugEnabled()) {
            log.debug("Generated cert serial number: " + serial.getId());
            log.debug("Key: " + cert.getKey());
            log.debug("Cert: " + cert.getCert());
        }

        entitlement.getCertificates().add(cert);
        entCertCurator.create(cert);
        return cert;
View Full Code Here

TOP

Related Classes of org.candlepin.model.EntitlementCertificate

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.