當前位置: 首頁>>代碼示例>>Java>>正文


Java CertificateParsingException類代碼示例

本文整理匯總了Java中java.security.cert.CertificateParsingException的典型用法代碼示例。如果您正苦於以下問題:Java CertificateParsingException類的具體用法?Java CertificateParsingException怎麽用?Java CertificateParsingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CertificateParsingException類屬於java.security.cert包,在下文中一共展示了CertificateParsingException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildCertAppliesToString

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
public static String buildCertAppliesToString(X509Certificate cert) {
    List<String> elements = new ArrayList<>();
    try {
        Collection<List<?>> altNames = cert.getSubjectAlternativeNames();
        if (altNames != null) {
            for (List<?> altName : altNames) {
                Integer altNameType = (Integer) altName.get(0);
                if (altNameType != 2 && altNameType != 7) // dns or ip
                    continue;
                elements.add((String) altName.get(1));
            }
        }
    } catch (CertificateParsingException ignored) {
    }

    if (elements.size() == 0)
        return "none";
    return TextUtils.join(",", elements.toArray());
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:20,代碼來源:ServerCertificateManager.java

示例2: resolvePrincipalInternal

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
/**
 * Retrieves Subject Alternative Name UPN extension as a principal id String.
 *
 * @param certificate X.509 certificate credential.
 *
 * @return Resolved principal ID or null if no SAN UPN extension is available in provided certificate.
 *
 * @see AbstractX509PrincipalResolver#resolvePrincipalInternal(java.security.cert.X509Certificate)
 * @see java.security.cert.X509Certificate#getSubjectAlternativeNames()
 */
@Override
protected String resolvePrincipalInternal(final X509Certificate certificate) {
    logger.debug("Resolving principal from Subject Alternative Name UPN for {}", certificate);
    try {
        final Collection<List<?>> subjectAltNames = certificate.getSubjectAlternativeNames();
        if (subjectAltNames != null) {
            for (final List<?> sanItem : subjectAltNames) {
                final ASN1Sequence seq = getAltnameSequence(sanItem);
                final String upnString = getUPNStringFromSequence(seq);
                if (upnString != null) {
                    return upnString;
                }
            }
        }
    } catch (final CertificateParsingException e) {
        logger.error("Error is encountered while trying to retrieve subject alternative names collection from certificate", e);
        logger.debug("Returning null principal id...");
        return null;
    }
    logger.debug("Returning null principal id...");
    return null;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:33,代碼來源:X509SubjectAlternativeNameUPNPrincipalResolver.java

示例3: resolvePrincipalInternal

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
/**
 * Retrieves Subject Alternative Name UPN extension as a principal id String.
 *
 * @param certificate X.509 certificate credential.
 * @return Resolved principal ID or null if no SAN UPN extension is available in provided certificate.
 * @see AbstractX509PrincipalResolver#resolvePrincipalInternal(java.security.cert.X509Certificate)
 * @see java.security.cert.X509Certificate#getSubjectAlternativeNames()
 */
@Override
protected String resolvePrincipalInternal(final X509Certificate certificate) {
    LOGGER.debug("Resolving principal from Subject Alternative Name UPN for [{}]", certificate);
    try {
        final Collection<List<?>> subjectAltNames = certificate.getSubjectAlternativeNames();
        if (subjectAltNames != null) {
            for (final List<?> sanItem : subjectAltNames) {
                final ASN1Sequence seq = getAltnameSequence(sanItem);
                final String upnString = getUPNStringFromSequence(seq);
                if (upnString != null) {
                    return upnString;
                }
            }
        }
    } catch (final CertificateParsingException e) {
        LOGGER.error("Error is encountered while trying to retrieve subject alternative names collection from certificate", e);
        LOGGER.debug("Returning null principal...");
        return null;
    }
    LOGGER.debug("Returning null principal id...");
    return null;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:31,代碼來源:X509SubjectAlternativeNameUPNPrincipalResolver.java

示例4: AttributeCertificateHolder

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
public AttributeCertificateHolder(X509Certificate cert)
    throws CertificateParsingException
{
    X509Principal name;

    try
    {
        name = PrincipalUtil.getIssuerX509Principal(cert);
    }
    catch (Exception e)
    {
        throw new CertificateParsingException(e.getMessage());
    }

    holder = new Holder(new IssuerSerial(generateGeneralNames(name),
        new ASN1Integer(cert.getSerialNumber())));
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:18,代碼來源:AttributeCertificateHolder.java

示例5: generateJcaObject

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature)
    throws CertificateEncodingException
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(tbsCert);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));

    try
    {
        return new X509CertificateObject(Certificate.getInstance(new DERSequence(v)));
    }
    catch (CertificateParsingException e)
    {
        throw new ExtCertificateEncodingException("exception producing certificate object", e);
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:19,代碼來源:X509V1CertificateGenerator.java

示例6: copyAndAddExtension

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
/**
 * add a given extension field for the standard extensions tag (tag 3)
 * copying the extension value from another certificate.
 * @throws CertificateParsingException if the extension cannot be extracted.
 */
public void copyAndAddExtension(
    String          oid,
    boolean         critical,
    X509Certificate cert) 
    throws CertificateParsingException
{
    byte[] extValue = cert.getExtensionValue(oid);
    
    if (extValue == null)
    {
        throw new CertificateParsingException("extension " + oid + " not present");
    }
    
    try
    {
        ASN1Encodable value = X509ExtensionUtil.fromExtensionValue(extValue);

        this.addExtension(oid, critical, value);
    }
    catch (IOException e)
    {
        throw new CertificateParsingException(e.toString());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:30,代碼來源:X509V3CertificateGenerator.java

示例7: addAdditionalStoresFromAltNames

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
protected static void addAdditionalStoresFromAltNames(
    X509Certificate cert,
    ExtendedPKIXParameters pkixParams)
    throws CertificateParsingException
{
    // if in the IssuerAltName extension an URI
    // is given, add an additinal X.509 store
    if (cert.getIssuerAlternativeNames() != null)
    {
        Iterator it = cert.getIssuerAlternativeNames().iterator();
        while (it.hasNext())
        {
            // look for URI
            List list = (List)it.next();
            if (list.get(0).equals(Integers.valueOf(GeneralName.uniformResourceIdentifier)))
            {
                // found
                String temp = (String)list.get(1);
                CertPathValidatorUtilities.addAdditionalStoreFromLocation(temp, pkixParams);
            }
        }
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:24,代碼來源:CertPathValidatorUtilities.java

示例8: readDERCertificate

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private Certificate readDERCertificate(
    InputStream in)
    throws IOException, CertificateParsingException
{
    ASN1InputStream dIn = new ASN1InputStream(in);
    ASN1Sequence seq = (ASN1Sequence)dIn.readObject();

    if (seq.size() > 1
            && seq.getObjectAt(0) instanceof DERObjectIdentifier)
    {
        if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
        {
            sData = new SignedData(ASN1Sequence.getInstance(
                            (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();

            return getCertificate();
        }
    }

    return new X509CertificateObject(
                        org.bouncycastle.asn1.x509.Certificate.getInstance(seq));
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:23,代碼來源:X509CertParser.java

示例9: getCertificate

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private Certificate getCertificate()
    throws CertificateParsingException
{
    if (sData != null)
    {
        while (sDataObjectCount < sData.size())
        {
            Object obj = sData.getObjectAt(sDataObjectCount++);

            if (obj instanceof ASN1Sequence)
            {
               return new X509CertificateObject(
                                org.bouncycastle.asn1.x509.Certificate.getInstance(obj));
            }
        }
    }

    return null;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:20,代碼來源:X509CertParser.java

示例10: readDERCertificate

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private java.security.cert.Certificate readDERCertificate(
    ASN1InputStream dIn)
    throws IOException, CertificateParsingException
{
    ASN1Sequence seq = (ASN1Sequence)dIn.readObject();

    if (seq.size() > 1
            && seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
    {
        if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
        {
            sData = SignedData.getInstance(ASN1Sequence.getInstance(
                (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();

            return getCertificate();
        }
    }

    return new X509CertificateObject(
                        Certificate.getInstance(seq));
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:22,代碼來源:CertificateFactory.java

示例11: getCertificate

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private java.security.cert.Certificate getCertificate()
    throws CertificateParsingException
{
    if (sData != null)
    {
        while (sDataObjectCount < sData.size())
        {
            Object obj = sData.getObjectAt(sDataObjectCount++);

            if (obj instanceof ASN1Sequence)
            {
               return new X509CertificateObject(
                                Certificate.getInstance(obj));
            }
        }
    }

    return null;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:20,代碼來源:CertificateFactory.java

示例12: generateSignedCertificate

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private X509Certificate generateSignedCertificate(
        PKCS10CertificationRequest csr) throws NoSuchAlgorithmException,
        NoSuchProviderException, InvalidKeyException,
        CertificateParsingException, CertificateEncodingException,
        SignatureException {

    X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
    certGen.setSerialNumber(BigInteger.valueOf(System.currentTimeMillis()));
    certGen.setIssuerDN(rootCert.getSubjectX500Principal());
    Calendar c = Calendar.getInstance();
    certGen.setNotBefore(c.getTime());
    c.add(Calendar.YEAR, 1);
    certGen.setNotAfter(c.getTime());
    certGen.setSubjectDN(csr.getCertificationRequestInfo().getSubject());
    certGen.setPublicKey(csr.getPublicKey("BC"));
    certGen.setSignatureAlgorithm(ALGORITHM_SHA256_RSA);
    certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false,
            new AuthorityKeyIdentifierStructure(rootCert.getPublicKey()));
    certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false,
            new SubjectKeyIdentifierStructure(csr.getPublicKey("BC")));
    certGen.addExtension(X509Extensions.BasicConstraints, true,
            new BasicConstraints(false));
    certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(
            KeyUsage.digitalSignature | KeyUsage.keyEncipherment));

    X509Certificate issuedCert = certGen.generate(rootPrivateKeyEntry
            .getPrivateKey());
    return issuedCert;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:30,代碼來源:CertificateHandler.java

示例13: processResponse

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
/**
 * Process response data and, if applicable, HTTPS information. The {@link org.symphonyoss.symphony.jcurl.JCurl.Response} object returned can be printed
 * out with response.print().
 *
 * @param con a {@link java.net.HttpURLConnection} object.
 * @return a {@link org.symphonyoss.symphony.jcurl.JCurl.Response} object.
 * @throws java.io.IOException if any.
 * @throws java.security.cert.CertificateParsingException if any.
 */
public Response processResponse(HttpURLConnection con) throws IOException, CertificateParsingException {
  Response response = new Response();

  long startTime = System.nanoTime();
  con.connect();
  long endTime = System.nanoTime();

  response.timeTaken = endTime - startTime;

  processResponseHeaders(con, response);
  processResponseCode(con, response);
  processResponseCertificates(con, response);
  processResponseOutput(con, response);
  processResponseTags(response);

  return response;
}
 
開發者ID:symphonyoss,項目名稱:JCurl,代碼行數:27,代碼來源:JCurl.java

示例14: getSubjectAltName

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private static Object getSubjectAltName(X509Certificate cert, int type) {
    Collection<List<?>> subjectAltNames;

    try {
        subjectAltNames = cert.getSubjectAlternativeNames();
    } catch (CertificateParsingException cpe) {
        if (debug != null && Debug.isOn("handshake")) {
            System.out.println(
                    "Attempt to obtain subjectAltNames extension failed!");
        }
        return null;
    }

    if (subjectAltNames != null) {
        for (List<?> subjectAltName : subjectAltNames) {
            int subjectAltNameType = (Integer)subjectAltName.get(0);
            if (subjectAltNameType == type) {
                return subjectAltName.get(1);
            }
        }
    }

    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:ClientHandshaker.java

示例15: getSubjectAltNames

import java.security.cert.CertificateParsingException; //導入依賴的package包/類
private static List<String> getSubjectAltNames(X509Certificate certificate, int type) {
    List<String> result = new ArrayList();
    try {
        Collection<?> subjectAltNames = certificate.getSubjectAlternativeNames();
        if (subjectAltNames == null) {
            return Collections.emptyList();
        }
        Iterator it = subjectAltNames.iterator();
        while (it.hasNext()) {
            List<?> entry = (List) it.next();
            if (entry != null && entry.size() >= 2) {
                Integer altNameType = (Integer) entry.get(0);
                if (altNameType != null && altNameType.intValue() == type) {
                    String altName = (String) entry.get(1);
                    if (altName != null) {
                        result.add(altName);
                    }
                }
            }
        }
        return result;
    } catch (CertificateParsingException e) {
        return Collections.emptyList();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:26,代碼來源:OkHostnameVerifier.java


注:本文中的java.security.cert.CertificateParsingException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。