Java 类org.bouncycastle.asn1.x509.DistributionPoint 实例源码

项目:ipack    文件:PKIXCertPathReviewer.java   
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();

    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
项目:SecuritySample    文件:CRLDistributionPointsImpl.java   
public CRLDistributionPointsImpl(X509Certificate cert) throws CertificateException, IOException {
    URINames = new ArrayList<>();
    byte[] extVal = cert.getExtensionValue(Extension.cRLDistributionPoints.getId());
    if (extVal == null)
        return;
    CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
    DistributionPoint[] points = crlDistPoint.getDistributionPoints();
    for (DistributionPoint p : points) {
        GeneralNames tmp = p.getCRLIssuer();
        if (tmp != null) {
            GeneralName[] crlIssers = tmp.getNames();
            for (int i = 0; i < crlIssers.length; i++) {
                if (crlIssers[i].getTagNo() == GeneralName.uniformResourceIdentifier) {
                    String issuerUrl = crlIssers[i].toString();
                    URINames.add(issuerUrl);
                }
            }
        }
    }
}
项目:Aki-SSL    文件:PKIXCertPathReviewer.java   
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();

    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
项目:CryptMeme    文件:PKIXCertPathReviewer.java   
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();

    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
项目:xipki    文件:CaUtil.java   
public static CRLDistPoint createCrlDistributionPoints(List<String> crlUris, X500Name caSubject,
        X500Name crlSignerSubject) {
    ParamUtil.requireNonEmpty("crlUris", crlUris);
    int size = crlUris.size();
    DistributionPoint[] points = new DistributionPoint[1];

    GeneralName[] names = new GeneralName[size];
    for (int i = 0; i < size; i++) {
        names[i] = new GeneralName(GeneralName.uniformResourceIdentifier, crlUris.get(i));
    }
    // Distribution Point
    GeneralNames gns = new GeneralNames(names);
    DistributionPointName pointName = new DistributionPointName(gns);

    GeneralNames crlIssuer = null;
    if (crlSignerSubject != null && !crlSignerSubject.equals(caSubject)) {
        GeneralName crlIssuerName = new GeneralName(crlSignerSubject);
        crlIssuer = new GeneralNames(crlIssuerName);
    }

    points[0] = new DistributionPoint(pointName, null, crlIssuer);

    return new CRLDistPoint(points);
}
项目:irma_future_id    文件:PKIXCertPathReviewer.java   
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();

    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
项目:bc-java    文件:PKIXCertPathReviewer.java   
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();

    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
项目:ipack    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:signer    文件:BasicCertificate.java   
/**
 * 
 * @return A list of ulrs that inform the location of the certificate revocation lists
 * @throws IOException exception
 */
public List<String> getCRLDistributionPoint() throws IOException {

    List<String> crlUrls = new ArrayList<>();
    ASN1Primitive primitive = getExtensionValue(Extension.cRLDistributionPoints.getId());
    if (primitive == null) {
        return null;
    }
    CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(primitive);
    DistributionPoint[] distributionPoints = crlDistPoint.getDistributionPoints();

    for (DistributionPoint distributionPoint : distributionPoints) {
        DistributionPointName dpn = distributionPoint.getDistributionPoint();
        // Look for URIs in fullName
        if (dpn != null) {
            if (dpn.getType() == DistributionPointName.FULL_NAME) {
                GeneralName[] genNames = GeneralNames.getInstance(dpn.getName()).getNames();
                for (GeneralName genName : genNames) {
                    if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) {
                        String url = DERIA5String.getInstance(genName.getName()).getString();
                        crlUrls.add(url);
                        logger.info("Adicionando a url {}", url);
                    }
                }
            }
        }
    }
    return crlUrls;
}
项目:cert-services    文件:CertificateService.java   
private void addCRLSitributionPoints(String issuerName, X509v3CertificateBuilder v3CertGen) throws CertIOException {
    DistributionPointName distributionPoint = new DistributionPointName(new GeneralNames(new GeneralName(GeneralName.uniformResourceIdentifier, SERVER_BASE_REST_PKI_URL + issuerName + CRL_URL)));

    DistributionPoint[] distPoints = new DistributionPoint[1];
    distPoints[0] = new DistributionPoint(distributionPoint, null, null);

    v3CertGen.addExtension(Extension.cRLDistributionPoints, false, new CRLDistPoint(distPoints));
}
项目:Aki-SSL    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:keystore-explorer    文件:CRLDistributionPoints.java   
@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    Iterator<DistributionPoint> it = distributionPointList.iterator();
    while (it.hasNext()) {
        v.add(it.next().toASN1Primitive());
    }
    return new DERSequence(v);
}
项目:keystore-explorer    文件:X509Ext.java   
private String getFreshestCrlStringValue(byte[] value) throws IOException {
    // @formatter:off

    /*
     * FreshestCRL ::= CRLDistributionPoints
     *
     * CRLDistributionPoints ::= ASN1Sequence SIZE (1..MAX) OF
     * DistributionPoint
     */

    // @formatter:on

    StringBuilder sb = new StringBuilder();

    CRLDistributionPoints freshestCRL = CRLDistributionPoints.getInstance(value);

    int distPoint = 0;

    for (DistributionPoint distributionPoint : freshestCRL.getDistributionPointList()) {
        distPoint++;

        sb.append(MessageFormat.format(res.getString("FreshestCrlDistributionPoint"), distPoint));
        sb.append(NEWLINE);

        sb.append(getDistributionPointString(distributionPoint, INDENT.toString(1)));
    }

    return sb.toString();
}
项目:signer-source    文件:DerEncoder.java   
public static List<String> getCrlDistributionPoints(byte[] crldpExt)
        throws CertificateParsingException, IOException {
    if (crldpExt == null) {
        return new ArrayList<String>();
    }
    ASN1InputStream oAsnInStream = new ASN1InputStream(
            new ByteArrayInputStream(crldpExt));
    DERObject derObjCrlDP = oAsnInStream.readObject();
    DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
    byte[] crldpExtOctets = dosCrlDP.getOctets();
    ASN1InputStream oAsnInStream2 = new ASN1InputStream(
            new ByteArrayInputStream(crldpExtOctets));
    DERObject derObj2 = oAsnInStream2.readObject();
    CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
    List<String> crlUrls = new ArrayList<String>();
    for (DistributionPoint dp : distPoint.getDistributionPoints()) {
        DistributionPointName dpn = dp.getDistributionPoint();
        // Look for URIs in fullName
        if (dpn != null && dpn.getType() == DistributionPointName.FULL_NAME) {
            GeneralName[] genNames = GeneralNames
                    .getInstance(dpn.getName()).getNames();
            // Look for an URI
            for (int j = 0; j < genNames.length; j++) {
                if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                    String url = DERIA5String.getInstance(
                            genNames[j].getName()).getString();
                    crlUrls.add(url);
                }
            }
        }
    }
    return crlUrls;
}
项目:signer-source    文件:DerEncoder.java   
public static List<String> getCrlDistributionPoints(byte[] crldpExt)
        throws CertificateParsingException, IOException {
    if (crldpExt == null) {
        return new ArrayList<String>();
    }
    ASN1InputStream oAsnInStream = new ASN1InputStream(
            new ByteArrayInputStream(crldpExt));
    ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
    DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
    byte[] crldpExtOctets = dosCrlDP.getOctets();
    ASN1InputStream oAsnInStream2 = new ASN1InputStream(
            new ByteArrayInputStream(crldpExtOctets));
    ASN1Primitive derObj2 = oAsnInStream2.readObject();
    CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
    List<String> crlUrls = new ArrayList<String>();
    for (DistributionPoint dp : distPoint.getDistributionPoints()) {
        DistributionPointName dpn = dp.getDistributionPoint();
        // Look for URIs in fullName
        if (dpn != null && dpn.getType() == DistributionPointName.FULL_NAME) {
            GeneralName[] genNames = GeneralNames
                    .getInstance(dpn.getName()).getNames();
            // Look for an URI
            for (int j = 0; j < genNames.length; j++) {
                if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                    String url = DERIA5String.getInstance(
                            genNames[j].getName()).getString();
                    crlUrls.add(url);
                }
            }
        }
    }
    return crlUrls;
}
项目:signer-source    文件:DerEncoder.java   
public static List<String> getCrlDistributionPoints(byte[] crldpExt)
        throws CertificateParsingException, IOException {
    if (crldpExt == null) {
        return new ArrayList<String>();
    }
    ASN1InputStream oAsnInStream = new ASN1InputStream(
            new ByteArrayInputStream(crldpExt));
    ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
    DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
    byte[] crldpExtOctets = dosCrlDP.getOctets();
    ASN1InputStream oAsnInStream2 = new ASN1InputStream(
            new ByteArrayInputStream(crldpExtOctets));
    ASN1Primitive derObj2 = oAsnInStream2.readObject();
    CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
    List<String> crlUrls = new ArrayList<String>();
    for (DistributionPoint dp : distPoint.getDistributionPoints()) {
        DistributionPointName dpn = dp.getDistributionPoint();
        // Look for URIs in fullName
        if (dpn != null && dpn.getType() == DistributionPointName.FULL_NAME) {
            GeneralName[] genNames = GeneralNames
                    .getInstance(dpn.getName()).getNames();
            // Look for an URI
            for (int j = 0; j < genNames.length; j++) {
                if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                    String url = DERIA5String.getInstance(
                            genNames[j].getName()).getString();
                    crlUrls.add(url);
                }
            }
        }
    }
    return crlUrls;
}
项目:dss    文件:DSSASN1Utils.java   
/**
 * Gives back the {@code List} of CRL URI meta-data found within the given X509 certificate.
 *
 * @param certificateToken
 *            the cert token certificate
 * @param checkInTrustAnchors
 *            if true, the method will search in the ServiceSupplyPoint urls
 * @return the {@code List} of CRL URI, or empty list if the extension is not present
 */
public static List<String> getCrlUrls(final CertificateToken certificateToken, boolean checkInTrustAnchors) {
    final List<String> urls = new ArrayList<String>();

    final byte[] crlDistributionPointsBytes = certificateToken.getCertificate().getExtensionValue(Extension.cRLDistributionPoints.getId());
    if (crlDistributionPointsBytes != null) {
        try {
            final ASN1Sequence asn1Sequence = DSSASN1Utils.getAsn1SequenceFromDerOctetString(crlDistributionPointsBytes);
            final CRLDistPoint distPoint = CRLDistPoint.getInstance(asn1Sequence);
            final DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();
            for (final DistributionPoint distributionPoint : distributionPoints) {

                final DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
                if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {
                    continue;
                }
                final GeneralNames generalNames = (GeneralNames) distributionPointName.getName();
                final GeneralName[] names = generalNames.getNames();
                for (final GeneralName name : names) {
                    String location = parseGn(name);
                    if (location != null) {
                        urls.add(location);
                    }
                }
            }
        } catch (Exception e) {
            LOG.error("Unable to parse cRLDistributionPoints", e);
        }
    }

    if (Utils.isCollectionEmpty(urls) && checkInTrustAnchors) {
        return getServiceSupplyPoints(certificateToken, "crl", "certificateRevocationList");
    }
    return urls;
}
项目:ExemplosDemoiselle    文件:TabeliaoCertificate.java   
/**
 * Retorna URL da Lista de Certificados Revogados (CRL). Pode haver mais de uma dependendo do 
 * emissor do certificado<br>
 * Mesmo que a CRL possua mais que uma fonte, retorna apenas a URL.<br>
 * Caso essa informacao nao esteja no certificado, retorna <b>null</b>.<br>
 * 
 * @return String
 * @throws IOException 
 */
public List<String> getCRLDistributionPoint() throws IOException{
    //TODO - Precisa validar este metodo com a RFC

    List<String> lcrS = new ArrayList<String>();
    DERObject derObj = getExtensionValue(X509Extensions.CRLDistributionPoints.getId());
    if(derObj == null) {
        return null;
    }
    CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(derObj);
    DistributionPoint[] dp = crlDistPoint.getDistributionPoints();
    for(int i=0 ; i<dp.length ; i++) {
        DERSequence seq = (DERSequence)new ASN1InputStream(dp[i].getDistributionPoint().getName().getDEREncoded()).readObject();
        DERTaggedObject tag = (DERTaggedObject) seq.getObjectAt(0);
        try{
            ASN1OctetString oct = (DEROctetString)DEROctetString.getInstance(tag);
            lcrS.add( new String(oct.getOctets()));
        }catch (Exception e){
            // N�o � um objeto com informa��o de DistributionPoint
        }
        // codifica��o antiga feita pelo Thiago, pegava apenas a primeira URL.
        //URL da WEB
        //if(tag.getTagNo() == 6) {
        //  DEROctetString oct = (DEROctetString)DEROctetString.getInstance(tag);
        //  return new String(oct.getOctets());
        //}

    }
    return lcrS;
}
项目:CryptMeme    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:oxAuth    文件:CRLCertificateVerifier.java   
public String getCrlUri(X509Certificate certificate) throws IOException {
    ASN1Primitive obj;
    try {
        obj = getExtensionValue(certificate, Extension.cRLDistributionPoints.getId());
    } catch (IOException ex) {
        log.error("Failed to get CRL URL", ex);
        return null;
    }

    if (obj == null) {
        return null;
    }

    CRLDistPoint distPoint = CRLDistPoint.getInstance(obj);

    DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();
    for (DistributionPoint distributionPoint : distributionPoints) {
        DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
        if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {
            continue;
        }

        GeneralNames generalNames = (GeneralNames) distributionPointName.getName();
        GeneralName[] names = generalNames.getNames();
        for (GeneralName name : names) {
            if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {
                continue;
            }

            DERIA5String derStr = DERIA5String.getInstance((ASN1TaggedObject) name.toASN1Primitive(), false);
            return derStr.getString();
        }
    }

    return null;
}
项目:jopenpec    文件:CRLVerifier.java   
/**
 * Extracts all CRL distribution point URLs from the "CRL Distribution Point"
 * extension in a X.509 certificate. If CRL distribution point extension is
 * unavailable, returns an empty list. 
 */
public static List<String> getCrlDistributionPoints(
        X509Certificate cert) throws CertificateParsingException, IOException {
    byte[] crldpExt = cert.getExtensionValue(
            X509Extensions.CRLDistributionPoints.getId());
    ASN1InputStream oAsnInStream = new ASN1InputStream(
            new ByteArrayInputStream(crldpExt));

    ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
    DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
    byte[] crldpExtOctets = dosCrlDP.getOctets();

    ASN1InputStream oAsnInStream2 = new ASN1InputStream(
            new ByteArrayInputStream(crldpExtOctets));

    ASN1Primitive derObj2 = oAsnInStream2.readObject();
    CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
    List<String> crlUrls = new ArrayList<String>();
    for (DistributionPoint dp : distPoint.getDistributionPoints()) {
        System.out.println(dp);
           DistributionPointName dpn = dp.getDistributionPoint();
           // Look for URIs in fullName
           if (dpn != null) {
               if (dpn.getType() == DistributionPointName.FULL_NAME) {
                   GeneralName[] genNames = GeneralNames.getInstance(
                       dpn.getName()).getNames();
                   // Look for an URI
                   for (int j = 0; j < genNames.length; j++) {
                       if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                           String url = DERIA5String.getInstance(
                               genNames[j].getName()).getString();
                           crlUrls.add(url);
                       }
                   }
               }
           }
    }
    return crlUrls;
}
项目:irma_future_id    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:irma_future_id    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:bc-java    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:bc-java    文件:RFC3280CertPathUtilities.java   
protected static ReasonsMask processCRLD(
    X509CRL crl,
    DistributionPoint dp)
    throws AnnotatedException
{
    IssuingDistributionPoint idp = null;
    try
    {
        idp = IssuingDistributionPoint.getInstance(CertPathValidatorUtilities.getExtensionValue(crl,
            RFC3280CertPathUtilities.ISSUING_DISTRIBUTION_POINT));
    }
    catch (Exception e)
    {
        throw new AnnotatedException("Issuing distribution point extension could not be decoded.", e);
    }
    // (d) (1)
    if (idp != null && idp.getOnlySomeReasons() != null && dp.getReasons() != null)
    {
        return new ReasonsMask(dp.getReasons()).intersect(new ReasonsMask(idp.getOnlySomeReasons()));
    }
    // (d) (4)
    if ((idp == null || idp.getOnlySomeReasons() == null) && dp.getReasons() == null)
    {
        return ReasonsMask.allReasons;
    }
    // (d) (2) and (d)(3)
    return (dp.getReasons() == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(dp.getReasons())).intersect(idp == null
        ? ReasonsMask.allReasons
        : new ReasonsMask(idp.getOnlySomeReasons()));

}
项目:ipack    文件:CertPathValidatorUtilities.java   
protected static void addAdditionalStoresFromCRLDistributionPoint(
    CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)
    throws AnnotatedException
{
    if (crldp != null)
    {
        DistributionPoint dps[] = null;
        try
        {
            dps = crldp.getDistributionPoints();
        }
        catch (Exception e)
        {
            throw new AnnotatedException(
                "Distribution points could not be read.", e);
        }
        for (int i = 0; i < dps.length; i++)
        {
            DistributionPointName dpn = dps[i].getDistributionPoint();
            // look for URIs in fullName
            if (dpn != null)
            {
                if (dpn.getType() == DistributionPointName.FULL_NAME)
                {
                    GeneralName[] genNames = GeneralNames.getInstance(
                        dpn.getName()).getNames();
                    // look for an URI
                    for (int j = 0; j < genNames.length; j++)
                    {
                        if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                        {
                            String location = DERIA5String.getInstance(
                                genNames[j].getName()).getString();
                            CertPathValidatorUtilities
                                .addAdditionalStoreFromLocation(location,
                                    pkixParams);
                        }
                    }
                }
            }
        }
    }
}
项目:ipack    文件:CertPathValidatorUtilities.java   
/**
 * Fetches complete CRLs according to RFC 3280.
 *
 * @param dp          The distribution point for which the complete CRL
 * @param cert        The <code>X509Certificate</code> or
 *                    {@link org.bouncycastle.x509.X509AttributeCertificate} for
 *                    which the CRL should be searched.
 * @param currentDate The date for which the delta CRLs must be valid.
 * @param paramsPKIX  The extended PKIX parameters.
 * @return A <code>Set</code> of <code>X509CRL</code>s with complete
 *         CRLs.
 * @throws AnnotatedException if an exception occurs while picking the CRLs
 * or no CRLs are found.
 */
protected static Set getCompleteCRLs(DistributionPoint dp, Object cert,
                                     Date currentDate, ExtendedPKIXParameters paramsPKIX)
    throws AnnotatedException
{
    X509CRLStoreSelector crlselect = new X509CRLStoreSelector();
    try
    {
        Set issuers = new HashSet();
        if (cert instanceof X509AttributeCertificate)
        {
            issuers.add(((X509AttributeCertificate)cert)
                .getIssuer().getPrincipals()[0]);
        }
        else
        {
            issuers.add(getEncodedIssuerPrincipal(cert));
        }
        CertPathValidatorUtilities.getCRLIssuersFromDistributionPoint(dp, issuers, crlselect, paramsPKIX);
    }
    catch (AnnotatedException e)
    {
        throw new AnnotatedException(
            "Could not get issuer information from distribution point.", e);
    }
    if (cert instanceof X509Certificate)
    {
        crlselect.setCertificateChecking((X509Certificate)cert);
    }
    else if (cert instanceof X509AttributeCertificate)
    {
        crlselect.setAttrCertificateChecking((X509AttributeCertificate)cert);
    }


    crlselect.setCompleteCRLEnabled(true);

    Set crls = CRL_UTIL.findCRLs(crlselect, paramsPKIX, currentDate);

    if (crls.isEmpty())
    {
        if (cert instanceof X509AttributeCertificate)
        {
            X509AttributeCertificate aCert = (X509AttributeCertificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + aCert.getIssuer().getPrincipals()[0] + "\"");
        }
        else
        {
            X509Certificate xCert = (X509Certificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + xCert.getIssuerX500Principal() + "\"");
        }
    }
    return crls;
}
项目:ipack    文件:RFC3280CertPathUtilities.java   
/**
 * If the DP includes cRLIssuer, then verify that the issuer field in the
 * complete CRL matches cRLIssuer in the DP and that the complete CRL
 * contains an issuing distribution point extension with the indirectCRL
 * boolean asserted. Otherwise, verify that the CRL issuer matches the
 * certificate issuer.
 *
 * @param dp   The distribution point.
 * @param cert The certificate ot attribute certificate.
 * @param crl  The CRL for <code>cert</code>.
 * @throws AnnotatedException if one of the above conditions does not apply or an error
 *                            occurs.
 */
protected static void processCRLB1(
    DistributionPoint dp,
    Object cert,
    X509CRL crl)
    throws AnnotatedException
{
    ASN1Primitive idp = CertPathValidatorUtilities.getExtensionValue(crl, ISSUING_DISTRIBUTION_POINT);
    boolean isIndirect = false;
    if (idp != null)
    {
        if (IssuingDistributionPoint.getInstance(idp).isIndirectCRL())
        {
            isIndirect = true;
        }
    }
    byte[] issuerBytes = CertPathValidatorUtilities.getIssuerPrincipal(crl).getEncoded();

    boolean matchIssuer = false;
    if (dp.getCRLIssuer() != null)
    {
        GeneralName genNames[] = dp.getCRLIssuer().getNames();
        for (int j = 0; j < genNames.length; j++)
        {
            if (genNames[j].getTagNo() == GeneralName.directoryName)
            {
                try
                {
                    if (Arrays.areEqual(genNames[j].getName().toASN1Primitive().getEncoded(), issuerBytes))
                    {
                        matchIssuer = true;
                    }
                }
                catch (IOException e)
                {
                    throw new AnnotatedException(
                        "CRL issuer information from distribution point cannot be decoded.", e);
                }
            }
        }
        if (matchIssuer && !isIndirect)
        {
            throw new AnnotatedException("Distribution point contains cRLIssuer field but CRL is not indirect.");
        }
        if (!matchIssuer)
        {
            throw new AnnotatedException("CRL issuer of CRL does not match CRL issuer of distribution point.");
        }
    }
    else
    {
        if (CertPathValidatorUtilities.getIssuerPrincipal(crl).equals(
            CertPathValidatorUtilities.getEncodedIssuerPrincipal(cert)))
        {
            matchIssuer = true;
        }
    }
    if (!matchIssuer)
    {
        throw new AnnotatedException("Cannot find matching CRL issuer for certificate.");
    }
}
项目:portecle    文件:X509Ext.java   
/**
 * Get extension value for CRL Distribution Points as a string.
 * 
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
 */
private String getCrlDistributionPointsStringValue(byte[] bValue)
    throws IOException
{
    CRLDistPoint dps = CRLDistPoint.getInstance(bValue);
    DistributionPoint[] points = dps.getDistributionPoints();

    StringBuilder sb = new StringBuilder();
    sb.append("<ul>");

    for (DistributionPoint point : points)
    {
        DistributionPointName dpn;
        if ((dpn = point.getDistributionPoint()) != null)
        {
            sb.append("<li>");
            switch (dpn.getType())
            {
                case DistributionPointName.FULL_NAME:
                    sb.append(RB.getString("CrlDistributionPoint.0.0"));
                    sb.append(": ");
                    sb.append(getGeneralNamesString((GeneralNames) dpn.getName(), LinkClass.CRL));
                    break;
                case DistributionPointName.NAME_RELATIVE_TO_CRL_ISSUER:
                    sb.append(RB.getString("CrlDistributionPoint.0.1"));
                    sb.append(": ");
                    // TODO: need better decode?
                    sb.append(stringify(dpn.getName()));
                    break;
                default:
                    sb.append(RB.getString("UnknownCrlDistributionPointName"));
                    sb.append(": ");
                    sb.append(stringify(dpn.getName()));
                    break;
            }
            sb.append("</li>");
        }

        ReasonFlags flags;
        if ((flags = point.getReasons()) != null)
        {
            sb.append("<li>");
            sb.append(RB.getString("CrlDistributionPoint.1"));
            sb.append(": ");
            // TODO: decode
            sb.append(stringify(flags));
            sb.append("</li>");
        }

        GeneralNames issuer;
        if ((issuer = point.getCRLIssuer()) != null)
        {
            sb.append("<li>");
            sb.append(RB.getString("CrlDistributionPoint.2"));
            sb.append(": ");
            sb.append(getGeneralNamesString(issuer, LinkClass.CRL));
            sb.append("</li>");
        }
    }

    sb.append("</ul>");
    return sb.toString();
}
项目:Aki-SSL    文件:CertPathValidatorUtilities.java   
protected static void addAdditionalStoresFromCRLDistributionPoint(
    CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)
    throws AnnotatedException
{
    if (crldp != null)
    {
        DistributionPoint dps[] = null;
        try
        {
            dps = crldp.getDistributionPoints();
        }
        catch (Exception e)
        {
            throw new AnnotatedException(
                "Distribution points could not be read.", e);
        }
        for (int i = 0; i < dps.length; i++)
        {
            DistributionPointName dpn = dps[i].getDistributionPoint();
            // look for URIs in fullName
            if (dpn != null)
            {
                if (dpn.getType() == DistributionPointName.FULL_NAME)
                {
                    GeneralName[] genNames = GeneralNames.getInstance(
                        dpn.getName()).getNames();
                    // look for an URI
                    for (int j = 0; j < genNames.length; j++)
                    {
                        if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                        {
                            String location = DERIA5String.getInstance(
                                genNames[j].getName()).getString();
                            CertPathValidatorUtilities
                                .addAdditionalStoreFromLocation(location,
                                    pkixParams);
                        }
                    }
                }
            }
        }
    }
}
项目:Aki-SSL    文件:CertPathValidatorUtilities.java   
/**
 * Fetches complete CRLs according to RFC 3280.
 *
 * @param dp          The distribution point for which the complete CRL
 * @param cert        The <code>X509Certificate</code> or
 *                    {@link org.bouncycastle.x509.X509AttributeCertificate} for
 *                    which the CRL should be searched.
 * @param currentDate The date for which the delta CRLs must be valid.
 * @param paramsPKIX  The extended PKIX parameters.
 * @return A <code>Set</code> of <code>X509CRL</code>s with complete
 *         CRLs.
 * @throws AnnotatedException if an exception occurs while picking the CRLs
 * or no CRLs are found.
 */
protected static Set getCompleteCRLs(DistributionPoint dp, Object cert,
                                     Date currentDate, ExtendedPKIXParameters paramsPKIX)
    throws AnnotatedException
{
    X509CRLStoreSelector crlselect = new X509CRLStoreSelector();
    try
    {
        Set issuers = new HashSet();
        if (cert instanceof X509AttributeCertificate)
        {
            issuers.add(((X509AttributeCertificate)cert)
                .getIssuer().getPrincipals()[0]);
        }
        else
        {
            issuers.add(getEncodedIssuerPrincipal(cert));
        }
        CertPathValidatorUtilities.getCRLIssuersFromDistributionPoint(dp, issuers, crlselect, paramsPKIX);
    }
    catch (AnnotatedException e)
    {
        throw new AnnotatedException(
            "Could not get issuer information from distribution point.", e);
    }
    if (cert instanceof X509Certificate)
    {
        crlselect.setCertificateChecking((X509Certificate)cert);
    }
    else if (cert instanceof X509AttributeCertificate)
    {
        crlselect.setAttrCertificateChecking((X509AttributeCertificate)cert);
    }


    crlselect.setCompleteCRLEnabled(true);

    Set crls = CRL_UTIL.findCRLs(crlselect, paramsPKIX, currentDate);

    if (crls.isEmpty())
    {
        if (cert instanceof X509AttributeCertificate)
        {
            X509AttributeCertificate aCert = (X509AttributeCertificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + aCert.getIssuer().getPrincipals()[0] + "\"");
        }
        else
        {
            X509Certificate xCert = (X509Certificate)cert;

            throw new AnnotatedException("No CRLs found for issuer \"" + xCert.getIssuerX500Principal() + "\"");
        }
    }
    return crls;
}
项目:Aki-SSL    文件:CertPathValidatorUtilities.java   
static List<PKIXCRLStore> getAdditionalStoresFromCRLDistributionPoint(CRLDistPoint crldp, Map<GeneralName, PKIXCRLStore> namedCRLStoreMap)
    throws AnnotatedException
{
    if (crldp != null)
    {
        DistributionPoint dps[] = null;
        try
        {
            dps = crldp.getDistributionPoints();
        }
        catch (Exception e)
        {
            throw new AnnotatedException(
                "Distribution points could not be read.", e);
        }
        List<PKIXCRLStore> stores = new ArrayList<PKIXCRLStore>();

        for (int i = 0; i < dps.length; i++)
        {
            DistributionPointName dpn = dps[i].getDistributionPoint();
            // look for URIs in fullName
            if (dpn != null)
            {
                if (dpn.getType() == DistributionPointName.FULL_NAME)
                {
                    GeneralName[] genNames = GeneralNames.getInstance(
                        dpn.getName()).getNames();

                    for (int j = 0; j < genNames.length; j++)
                    {
                        PKIXCRLStore store = namedCRLStoreMap.get(genNames[j]);
                        if (store != null)
                        {
                            stores.add(store);
                        }
                    }
                }
            }
        }

        return stores;
    }
    else
    {
        return Collections.EMPTY_LIST;
    }
}
项目:Aki-SSL    文件:CertPathValidatorUtilities.java   
/**
 * Fetches complete CRLs according to RFC 3280.
 *
 * @param dp          The distribution point for which the complete CRL
 * @param cert        The <code>X509Certificate</code> for
 *                    which the CRL should be searched.
 * @param currentDate The date for which the delta CRLs must be valid.
 * @param paramsPKIX  The extended PKIX parameters.
 * @return A <code>Set</code> of <code>X509CRL</code>s with complete
 *         CRLs.
 * @throws AnnotatedException if an exception occurs while picking the CRLs
 * or no CRLs are found.
 */
protected static Set getCompleteCRLs(DistributionPoint dp, Object cert,
                                     Date currentDate, PKIXExtendedParameters paramsPKIX)
    throws AnnotatedException
{
    X509CRLSelector baseCrlSelect = new X509CRLSelector();

    try
    {
        Set issuers = new HashSet();

        issuers.add(PrincipalUtils.getEncodedIssuerPrincipal(cert));

        CertPathValidatorUtilities.getCRLIssuersFromDistributionPoint(dp, issuers, baseCrlSelect);
    }
    catch (AnnotatedException e)
    {
        throw new AnnotatedException(
            "Could not get issuer information from distribution point.", e);
    }

    if (cert instanceof X509Certificate)
    {
        baseCrlSelect.setCertificateChecking((X509Certificate)cert);
    }

    PKIXCRLStoreSelector crlSelect = new PKIXCRLStoreSelector.Builder(baseCrlSelect).setCompleteCRLEnabled(true).build();

    Date validityDate = currentDate;

    if (paramsPKIX.getDate() != null)
    {
        validityDate = paramsPKIX.getDate();
    }

    Set crls = CRL_UTIL.findCRLs(crlSelect, validityDate, paramsPKIX.getCertStores(), paramsPKIX.getCRLStores());

    checkCRLsNotEmpty(crls, cert);

    return crls;
}
项目:keystone4j    文件:CRLVerifier.java   
/**
 * Extracts all CRL distribution point URLs from the
 * "CRL Distribution Point" extension in a X.509 certificate. If CRL
 * distribution point extension is unavailable, returns an empty list.
 */
public static List<String> getCrlDistributionPoints(X509Certificate cert) throws CertificateParsingException,
        IOException {
    byte[] crldpExt = cert.getExtensionValue(X509Extension.cRLDistributionPoints.getId());
    if (crldpExt == null) {
        return new ArrayList<String>();
    }
    ASN1InputStream oAsnInStream = null;
    ASN1InputStream oAsnInStream2 = null;
    try {
        oAsnInStream = new ASN1InputStream(new ByteArrayInputStream(crldpExt));
        DERObject derObjCrlDP = oAsnInStream.readObject();
        DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
        byte[] crldpExtOctets = dosCrlDP.getOctets();
        oAsnInStream2 = new ASN1InputStream(new ByteArrayInputStream(crldpExtOctets));
        DERObject derObj2 = oAsnInStream2.readObject();
        CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
        List<String> crlUrls = new ArrayList<String>();
        for (DistributionPoint dp : distPoint.getDistributionPoints()) {
            DistributionPointName dpn = dp.getDistributionPoint();
            // Look for URIs in fullName
            if (dpn != null && dpn.getType() == DistributionPointName.FULL_NAME) {
                GeneralName[] genNames = GeneralNames.getInstance(dpn.getName()).getNames();
                // Look for an URI
                for (int j = 0; j < genNames.length; j++) {
                    if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                        String url = DERIA5String.getInstance(genNames[j].getName()).getString();
                        crlUrls.add(url);
                    }
                }
            }
        }
        return crlUrls;
    } finally {
        if (oAsnInStream != null) {
            oAsnInStream.close();
        }

        if (oAsnInStream2 != null) {
            oAsnInStream2.close();
        }
    }
}
项目:keystore-explorer    文件:CRLDistributionPoints.java   
private CRLDistributionPoints(ASN1Sequence seq) {
    distributionPointList = new ArrayList<DistributionPoint>();
    for (int i = 0; i != seq.size(); i++) {
        distributionPointList.add(DistributionPoint.getInstance(seq.getObjectAt(i)));
    }
}
项目:keystore-explorer    文件:CRLDistributionPoints.java   
/**
 * Returns the distribution points making up the sequence.
 */
public List<DistributionPoint> getDistributionPointList() {
    return distributionPointList;
}
项目:keystore-explorer    文件:X509Ext.java   
private String getDistributionPointString(DistributionPoint distributionPoint, String baseIndent)
        throws IOException {
    // @formatter:off

    /*
     * DistributionPoint ::= ASN1Sequence {
     *      distributionPoint [0] DistributionPointName OPTIONAL,
     *      reasons [1] ReasonFlags OPTIONAL,
     *      cRLIssuer [2] GeneralNames OPTIONAL
     * }
     *
     * GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
     */

    // @formatter:on

    StringBuilder sb = new StringBuilder();

    DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
    ReasonFlags reasons = distributionPoint.getReasons();
    GeneralNames crlIssuer = distributionPoint.getCRLIssuer();

    if (distributionPointName != null) { // Optional
        sb.append(getDistributionPointNameString(distributionPointName, baseIndent));
    }

    if (reasons != null) { // Optional
        sb.append(baseIndent);
        sb.append(res.getString("DistributionPointReasons"));
        sb.append(NEWLINE);

        String[] reasonFlags = getReasonFlagsStrings(reasons);

        for (String reasonFlag : reasonFlags) {
            sb.append(baseIndent);
            sb.append(INDENT);
            sb.append(reasonFlag);
            sb.append(NEWLINE);
        }
    }

    if (crlIssuer != null) { // Optional
        sb.append(baseIndent);
        sb.append(res.getString("DistributionPointCrlIssuer"));
        sb.append(NEWLINE);

        for (GeneralName generalName : crlIssuer.getNames()) {
            sb.append(baseIndent);
            sb.append(INDENT);
            sb.append(GeneralNameUtil.toString(generalName));
            sb.append(NEWLINE);
        }
    }

    return sb.toString();
}
项目:pdfbox-signer    文件:CRLDistributionPointsExtractor.java   
/**
 * Extracts all CRL distribution point URLs from the
 * "CRL Distribution Point" extension in a X.509 certificate. If CRL
 * distribution point extension is unavailable, returns an empty list.
 */
public static List<String> getCrlDistributionPoints(X509Certificate cert) {

    ASN1InputStream oAsnInStream = null;
    ASN1InputStream oAsnInStream2 = null;
    try {
        byte[] crldpExt = cert.getExtensionValue(Extension.cRLDistributionPoints.getId());
        if (crldpExt == null) {
            List<String> emptyList = new ArrayList<String>();
            return emptyList;
        }
        oAsnInStream = new ASN1InputStream(new ByteArrayInputStream(crldpExt));
        ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
        DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
        byte[] crldpExtOctets = dosCrlDP.getOctets();
        oAsnInStream2 = new ASN1InputStream(new ByteArrayInputStream(crldpExtOctets));
        ASN1Primitive derObj2 = oAsnInStream2.readObject();
        CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
        List<String> crlUrls = new ArrayList<String>();
        for (DistributionPoint dp : distPoint.getDistributionPoints()) {
            DistributionPointName dpn = dp.getDistributionPoint();
            // Look for URIs in fullName
            if (dpn != null) {
                if (dpn.getType() == DistributionPointName.FULL_NAME) {
                    GeneralName[] genNames = GeneralNames.getInstance(dpn.getName()).getNames();
                    // Look for an URI
                    for (int j = 0; j < genNames.length; j++) {
                        if (genNames[j].getTagNo() == GeneralName.uniformResourceIdentifier) {
                            String url = DERIA5String.getInstance(genNames[j].getName()).getString();
                            crlUrls.add(url);
                        }
                    }
                }
            }
        }
        return crlUrls;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    } finally {
        org.apache.commons.io.IOUtils.closeQuietly(oAsnInStream);
        org.apache.commons.io.IOUtils.closeQuietly(oAsnInStream2);
    }
}
项目:java-certificate-authority    文件:CrlDistPointExtension.java   
CrlDistPointExtension(final DistributionPoint... points) {
  super(Extension.cRLDistributionPoints, false, new CRLDistPoint(points));
}
项目:java-certificate-authority    文件:CrlDistPointExtension.java   
public static CrlDistPointExtension create(final DistributionPointName distributionPoint,
    final ReasonFlags reasons,
    final GeneralNames cRLIssuer) {
  final DistributionPoint p = new DistributionPoint(distributionPoint, reasons, cRLIssuer);
  return create(p);
}