All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.spongycastle.cert.dane.DANEEntryFactory Maven / Gradle / Ivy

Go to download

Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for the Android platform. Android unfortunately ships with a stripped-down version of Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full, up-to-date version of the Bouncy Castle cryptographic libs.

There is a newer version: 1.54.0.0
Show newest version
package org.spongycastle.cert.dane;

import org.spongycastle.cert.X509CertificateHolder;
import org.spongycastle.operator.DigestCalculator;

/**
 * Factory class for creating DANEEntry objects.
 */
public class DANEEntryFactory
{
    private final DANEEntrySelectorFactory selectorFactory;

    /**
     * Base constructor.
     *
     * @param digestCalculator a calculator for the message digest to filter email addresses currently SHA-224.
     */
    public DANEEntryFactory(DigestCalculator digestCalculator)
    {
        this.selectorFactory = new DANEEntrySelectorFactory(digestCalculator);
    }

    /**
     * Return a DANEEntry for the passed in email address and certificate.
     *
     * @param emailAddress the emails address of interest.
     * @param certificate the certificate to be associated with the email address.
     * @throws DANEException in case of issue generating a matching name.
     */
    public DANEEntry createEntry(String emailAddress, X509CertificateHolder certificate)
        throws DANEException
    {
        DANEEntrySelector entrySelector = selectorFactory.createSelector(emailAddress);
        byte[] flags = new byte[3];

        flags[DANEEntry.CERT_USAGE] = 3;
        flags[DANEEntry.SELECTOR] = 0;
        flags[DANEEntry.MATCHING_TYPE] = 0;

        return new DANEEntry(entrySelector.getDomainName(), flags, certificate);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy