⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x509crlobject.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }        return entrySet;    }    public X509CRLEntry getRevokedCertificate(BigInteger serialNumber)    {        Enumeration certs = c.getRevokedCertificateEnumeration();        X500Principal previousCertificateIssuer = getIssuerX500Principal();        while (certs.hasMoreElements())        {            TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();            X509CRLEntryObject crlEntry = new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);            if (serialNumber.equals(entry.getUserCertificate().getValue()))            {                return crlEntry;            }            previousCertificateIssuer = crlEntry.getCertificateIssuer();        }        return null;    }    public Set getRevokedCertificates()    {        Set entrySet = loadCRLEntries();        if (!entrySet.isEmpty())        {            return Collections.unmodifiableSet(entrySet);        }        return null;    }    public byte[] getTBSCertList()        throws CRLException    {        try        {            return c.getTBSCertList().getEncoded("DER");        }        catch (IOException e)        {            throw new CRLException(e.toString());        }    }    public byte[] getSignature()    {        return c.getSignature().getBytes();    }    public String getSigAlgName()    {        return sigAlgName;    }    public String getSigAlgOID()    {        return c.getSignatureAlgorithm().getObjectId().getId();    }    public byte[] getSigAlgParams()    {        if (sigAlgParams != null)        {            byte[] tmp = new byte[sigAlgParams.length];                        System.arraycopy(sigAlgParams, 0, tmp, 0, tmp.length);                        return tmp;        }                return null;    }    /**     * Returns a string representation of this CRL.     *     * @return a string representation of this CRL.     */    public String toString()    {        StringBuffer buf = new StringBuffer();        String nl = System.getProperty("line.separator");        buf.append("              Version: ").append(this.getVersion()).append(            nl);        buf.append("             IssuerDN: ").append(this.getIssuerDN())            .append(nl);        buf.append("          This update: ").append(this.getThisUpdate())            .append(nl);        buf.append("          Next update: ").append(this.getNextUpdate())            .append(nl);        buf.append("  Signature Algorithm: ").append(this.getSigAlgName())            .append(nl);        byte[] sig = this.getSignature();        buf.append("            Signature: ").append(            new String(Hex.encode(sig, 0, 20))).append(nl);        for (int i = 20; i < sig.length; i += 20)        {            if (i < sig.length - 20)            {                buf.append("                       ").append(                    new String(Hex.encode(sig, i, 20))).append(nl);            }            else            {                buf.append("                       ").append(                    new String(Hex.encode(sig, i, sig.length - i))).append(nl);            }        }        X509Extensions extensions = c.getTBSCertList().getExtensions();        if (extensions != null)        {            Enumeration e = extensions.oids();            if (e.hasMoreElements())            {                buf.append("           Extensions: ").append(nl);            }            while (e.hasMoreElements())            {                DERObjectIdentifier oid = (DERObjectIdentifier) e.nextElement();                X509Extension ext = extensions.getExtension(oid);                if (ext.getValue() != null)                {                    byte[] octs = ext.getValue().getOctets();                    ASN1InputStream dIn = new ASN1InputStream(octs);                    buf.append("                       critical(").append(                        ext.isCritical()).append(") ");                    try                    {                        if (oid.equals(X509Extensions.CRLNumber))                        {                            buf.append(                                new CRLNumber(DERInteger.getInstance(                                    dIn.readObject()).getPositiveValue()))                                .append(nl);                        }                        else if (oid.equals(X509Extensions.DeltaCRLIndicator))                        {                            buf.append(                                "Base CRL: "                                    + new CRLNumber(DERInteger.getInstance(                                        dIn.readObject()).getPositiveValue()))                                .append(nl);                        }                        else if (oid                            .equals(X509Extensions.IssuingDistributionPoint))                        {                            buf.append(                                new IssuingDistributionPoint((ASN1Sequence) dIn                                    .readObject())).append(nl);                        }                        else if (oid                            .equals(X509Extensions.CRLDistributionPoints))                        {                            buf.append(                                new CRLDistPoint((ASN1Sequence) dIn                                    .readObject())).append(nl);                        }                        else if (oid.equals(X509Extensions.FreshestCRL))                        {                            buf.append(                                new CRLDistPoint((ASN1Sequence) dIn                                    .readObject())).append(nl);                        }                        else                        {                            buf.append(oid.getId());                            buf.append(" value = ").append(                                ASN1Dump.dumpAsString(dIn.readObject()))                                .append(nl);                        }                    }                    catch (Exception ex)                    {                        buf.append(oid.getId());                        buf.append(" value = ").append("*****").append(nl);                    }                }                else                {                    buf.append(nl);                }            }        }        Set set = getRevokedCertificates();        if (set != null)        {            Iterator it = set.iterator();            while (it.hasNext())            {                buf.append(it.next());                buf.append(nl);            }        }        return buf.toString();    }    /**     * Checks whether the given certificate is on this CRL.     *     * @param cert the certificate to check for.     * @return true if the given certificate is on this CRL,     * false otherwise.     */    public boolean isRevoked(Certificate cert)    {        if (!cert.getType().equals("X.509"))        {            throw new RuntimeException("X.509 CRL used with non X.509 Cert");        }        TBSCertList.CRLEntry[] certs = c.getRevokedCertificates();        if (certs != null)        {            BigInteger serial = ((X509Certificate)cert).getSerialNumber();            for (int i = 0; i < certs.length; i++)            {                if (certs[i].getUserCertificate().getValue().equals(serial))                {                    return true;                }            }        }        return false;    }    private boolean isIndirectCRL()        throws CRLException    {        byte[] idp = getExtensionValue(X509Extensions.IssuingDistributionPoint.getId());        boolean isIndirect = false;        try        {            if (idp != null)            {                isIndirect = IssuingDistributionPoint.getInstance(                        X509ExtensionUtil.fromExtensionValue(idp))                        .isIndirectCRL();            }        }        catch (Exception e)        {            throw new ExtCRLException(                    "Exception reading IssuingDistributionPoint", e);        }        return isIndirect;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -