Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
The BSD License Copyright (c) 2010-2012 RIPE NCC All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the RIPE NCC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 package net.ripe.rpki.commons.provisioning.cms;
 
 import org.junit.Test;
 
 
 import static net.ripe.rpki.commons.crypto.x509cert.X509CertificateBuilderHelper.*;
 import static net.ripe.rpki.commons.provisioning.ProvisioningObjectMother.*;
 import static org.bouncycastle.cms.CMSSignedGenerator.*;
 import static org.junit.Assert.*;
 
 
     private ProvisioningCmsObject cmsObject;
     private long signingTime;
 
     @Before
     public void setUp() throws Exception {
         ResourceClassListQueryPayload payload = payloadBuilder.build();
 
          = new ProvisioningCmsObjectBuilder();
 
         .withCrl();
         .withPayloadContent(payload);
 
          = new DateTime().getMillis() / 1000 * 1000; // truncate milliseconds
         DateTimeUtils.setCurrentMillisFixed();
         DateTimeUtils.setCurrentMillisSystem();
 
    }
        builder.withCrl();
        builder.withPayloadContent(payload);
    }
    @Test(expected = IllegalArgumentException.class)
    public void shouldForceCertificate() throws CMSException {
        .withCmsCertificate(null);
    }
    @Test(expected = IllegalArgumentException.class)
    public void shouldForceCrl() throws CMSException {
        .withCrl(null);
    }
    @Test
    public void shouldNotForceIdentityCertificate() throws CMSException {
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.1
    @Test
    public void shouldCmsObjectHaveCorrectVersionNumber() throws Exception {
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.2
    @Test
    public void shouldCmsObjectHaveCorrectDigestAlgorithm() throws Exception {
        ContentInfo info = ContentInfo.getInstance(in.readObject());
        SignedData signedData = SignedData.getInstance(info.getContent());
        ASN1Set digestAlgorithms = signedData.getDigestAlgorithms();
        ASN1Encodable asn1Object = digestAlgorithms.getObjectAt(0);
        AlgorithmIdentifier algorithmId = AlgorithmIdentifier.getInstance(asn1Object.toASN1Primitive());
        assertEquals(algorithmId.getAlgorithm().getId());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.3.1
    @Test
    public void shouldCmsObjectHaveCorrectContentType() throws Exception {
        assertEquals(new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.1.28"), .getSignedContent().getContentType());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.4
    @Test
        Collection<? extends X509CertificateHoldercertificates = getCertificates();
        assertNotNull(certificates);
        assertEquals("size", 1, certificates.size());
        X509CertificateHolder holder = certificates.iterator().next();
    }
    @SuppressWarnings("unchecked")
            CertStoreException {
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.5
    @Test
    public void shouldCmsObjectHaveEmbeddedCrl() throws Exception {
        @SuppressWarnings("unchecked")
        assertNotNull(crls);
        assertFalse(crls.isEmpty());
        assertEquals(new JcaX509CRLHolder(), crls.iterator().next());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6
    @Test
    public void shouldCmsObjectHaveOnlyOneSigner() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        assertNotNull(signers);
        assertEquals(1, signers.size());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.1
    @Test
    public void shouldCmsObjectSignerVersionBeCorrect() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertEquals(3, signer.getVersion());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.2
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.2
    @Test
    public void shouldCmsObjectHaveSubjectKeyIdentifierOnly() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertNull(signer.getSID().getIssuer());
        assertNull(signer.getSID().getSerialNumber());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.3
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertEquals(signer.getDigestAlgOID());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.4
    @Test
    public void shouldCmsObjectHaveSignedAttributes() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertNotNull(signer.getSignedAttributes());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.4.1
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        AttributeTable attributeTable = signer.getSignedAttributes();
        Attribute contentType = attributeTable.get(.);
        assertNotNull(contentType);
        assertEquals(1, contentType.getAttrValues().size());
        assertEquals(new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.1.28"), contentType.getAttrValues().getObjectAt(0));
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.4.2
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        AttributeTable attributeTable = signer.getSignedAttributes();
        Attribute messageDigest = attributeTable.get(.);
        assertNotNull(messageDigest);
        assertEquals(1, messageDigest.getAttrValues().size());
        assertNotNull(messageDigest.getAttrValues().getObjectAt(0));
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.4.3
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        AttributeTable attributeTable = signer.getSignedAttributes();
        Attribute signingTimeAttr = attributeTable.get(.);
        assertNotNull(signingTimeAttr);
        assertEquals(1, signingTimeAttr.getAttrValues().size());
        DERUTCTime signingTime = (DERUTCTimesigningTimeAttr.getAttrValues().getObjectAt(0);
        assertEquals(this.signingTime.getDate().getTime());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.4.4
    @Test
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        AttributeTable attributeTable = signer.getSignedAttributes();
        Attribute contentType = attributeTable.get(new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.2.46"));
        assertNull(contentType);
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.5 http://tools.ietf.org/html/draft-huston-sidr-rpki-algs-00#section-2
    @Test
    public void shouldCmsObjectHaveRSASignatureAlgorithm() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.6
    @Test
    public void shouldCmsObjectHaveValidSignature() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertNotNull(signer.getSignature());
    }

    
http://tools.ietf.org/html/draft-ietf-sidr-rescerts-provisioning-09#section-3.1.1.6.7
    @Test
    public void shouldCmsObjectHaveNoUnsignedAttribute() throws Exception {
        Collection<?> signers = .getSignerInfos().getSigners();
        SignerInformation signer = (SignerInformationsigners.iterator().next();
        assertNull(signer.getUnsignedAttributes());
    }
New to GrepCode? Check out our FAQ X