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.crypto.x509cert;
 public abstract class GenericRpkiCertificateBuilder {
     private PublicKey publicKey;
     private KeyPair signingKeyPair;
     private BigInteger serial;
     private IpResourceSet resources = new IpResourceSet();
     private EnumSet<IpResourceTypeinheritedResourceTypes = EnumSet.noneOf(IpResourceType.class);
     private X500Principal subject;
     private X500Principal issuer;
     private ValidityPeriod validityPeriod;
     private URI crlUri;
     private String signatureProvider = "SunRsaSign";
     public void withPublicKey(PublicKey publicKey) {
         this. = publicKey;
     public void withSigningKeyPair(KeyPair signingKeyPair) {
         this. = signingKeyPair;
     public void withSerial(BigInteger serial) {
         this. = serial;
     public void withResources(IpResourceSet resources) {
         this. = resources;
     public void withInheritedResourceTypes(EnumSet<IpResourceTyperesourceTypes) {
         this. = EnumSet.copyOf(resourceTypes);
     public void withSubjectDN(X500Principal subject) {
         this. = subject;
     public void withIssuerDN(X500Principal issuer) {
         this. = issuer;
     public void withValidityPeriod(ValidityPeriod validityPeriod) {
         this. = validityPeriod;
     public void withCrlUri(URI crlUri) {
         Validate.notNull(crlUri"CRL Uri can not be null");
         this. = crlUri;
     protected void validateIsRsyncUri(URI crlUri) {
         Validate.isTrue(crlUri.toString().startsWith("rsync:"), "Rsync URI is required, multiple repositories not supported by this builder at this time");
    protected boolean isSelfSigned() {
        return .getPublic().equals();
    public void withParentResourceCertificatePublicationUri(URI parentResourceCertificatePublicationUri) {
        this. = parentResourceCertificatePublicationUri;

Default: SunRsaSign
    public void withSignatureProvider(String signatureProvider) {
        this. = signatureProvider;
        if(!isSelfSigned()) {
            X509CertificateInformationAccessDescriptor[] aiaDescriptors = {
        return builder;
    protected void validateFields() {
        Validate.notNull("Public Key is required");
        Validate.notNull("Signing Key Pair is required");
        Validate.notNull("Serial is required");
        Validate.isTrue(!.isEmpty() || !.isEmpty(), "Resources are required. Inherited resources are allowed but not advised (unless you are building an EE cert for manifests)");
        Validate.notNull("Subject is required");
        Validate.notNull("Issuer is required");
        Validate.notNull("ValidityPeriod is required");
        if (!isSelfSigned()) {
            Validate.notNull("CRL URI is required (except for self-signed (root) certificates)");
            Validate.notNull("Parent Certificate Publication URI is required");
        Validate.notNull("SignatureProvider is required");
New to GrepCode? Check out our FAQ X