当前位置: 首页>>代码示例>>Java>>正文


Java CertificateException.getMessage方法代码示例

本文整理汇总了Java中java.security.cert.CertificateException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CertificateException.getMessage方法的具体用法?Java CertificateException.getMessage怎么用?Java CertificateException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.CertificateException的用法示例。


在下文中一共展示了CertificateException.getMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetchCertificateChain

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private X509Certificate[] fetchCertificateChain(Context context, String alias)
        throws KeyChainException, InterruptedException, MessagingException {

    X509Certificate[] chain = KeyChain.getCertificateChain(context, alias);
    if (chain == null || chain.length == 0) {
        throw new MessagingException("No certificate chain found for: " + alias);
    }
    try {
        for (X509Certificate certificate : chain) {
            certificate.checkValidity();
        }
    } catch (CertificateException e) {
        throw new CertificateValidationException(e.getMessage(), Reason.Expired, alias);
    }

    return chain;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:18,代码来源:KeyChainKeyManager.java

示例2: readCertificateList

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private List<Certificate> readCertificateList(BufferedSource source) throws IOException {
  int length = readInt(source);
  if (length == -1) return Collections.emptyList(); // OkHttp v1.2 used -1 to indicate null.

  try {
    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
    List<Certificate> result = new ArrayList<>(length);
    for (int i = 0; i < length; i++) {
      String line = source.readUtf8LineStrict();
      Buffer bytes = new Buffer();
      bytes.write(ByteString.decodeBase64(line));
      result.add(certificateFactory.generateCertificate(bytes.inputStream()));
    }
    return result;
  } catch (CertificateException e) {
    throw new IOException(e.getMessage());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Cache.java

示例3: readCertificateList

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private List<Certificate> readCertificateList(BufferedSource source) throws IOException {
    int length = Cache.readInt(source);
    if (length == -1) {
        return Collections.emptyList();
    }
    try {
        CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
        List<Certificate> result = new ArrayList(length);
        for (int i = 0; i < length; i++) {
            String line = source.readUtf8LineStrict();
            Buffer bytes = new Buffer();
            bytes.write(ByteString.decodeBase64(line));
            result.add(certificateFactory.generateCertificate(bytes.inputStream()));
        }
        return result;
    } catch (CertificateException e) {
        throw new IOException(e.getMessage());
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:Cache.java

示例4: readCertArray

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private Certificate[] readCertArray(StrictLineReader reader) throws IOException {
  int length = reader.readInt();
  if (length == -1) {
    return null;
  }
  try {
    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
    Certificate[] result = new Certificate[length];
    for (int i = 0; i < result.length; i++) {
      String line = reader.readLine();
      byte[] bytes = Base64.decode(line.getBytes("US-ASCII"));
      result[i] = certificateFactory.generateCertificate(new ByteArrayInputStream(bytes));
    }
    return result;
  } catch (CertificateException e) {
    throw new IOException(e.getMessage());
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:19,代码来源:HttpResponseCache.java

示例5: getMessage

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private String getMessage(CertificateException e) {
        String msg = e.getLocalizedMessage();
if (msg == null)
msg = e.getMessage();
if (msg == null)
msg = e.toString();
return msg;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:9,代码来源:DecoratedTrustManager.java

示例6: getCertificate

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private X509Cert getCertificate(P11ObjectIdentifier certId) throws P11TokenException {
    P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, certId);
    byte[] resp = module.send(P11ProxyConstants.ACTION_GET_CERT,
            new Asn1P11EntityIdentifier(entityId));
    if (resp == null) {
        return null;
    }

    try {
        return new X509Cert(X509Util.parseCert(resp), resp);
    } catch (CertificateException ex) {
        throw new P11TokenException("could not parse certificate:" + ex.getMessage(), ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:15,代码来源:ProxyP11Slot.java

示例7: parseCert

import java.security.cert.CertificateException; //导入方法依赖的package包/类
private static X509Cert parseCert(X509PublicKeyCertificate p11Cert) throws P11TokenException {
    try {
        byte[] encoded = p11Cert.getValue().getByteArrayValue();
        return new X509Cert(X509Util.parseCert(encoded), encoded);
    } catch (CertificateException ex) {
        throw new P11TokenException("could not parse certificate: " + ex.getMessage(), ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:9,代码来源:IaikP11Slot.java

示例8: parseX509Certificate

import java.security.cert.CertificateException; //导入方法依赖的package包/类
public static X509Certificate parseX509Certificate(String certificateValue) {
  logger.debug("Parsing X509 certificate");
  String certificateString = BEGIN_CERT + "\n" + certificateValue + "\n" + END_CERT;
  try {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certificateString.getBytes()));
  } catch (CertificateException e) {
    logger.error("Failed to parse X509 certificate from " + certificateString + ". Error " + e.getMessage());
    throw new TechnicalErrorException("Failed to parse X509 certificate from " + certificateString + ". Error " + e.getMessage(), e);
  }
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:12,代码来源:CertificateParser.java

示例9: verify

import java.security.cert.CertificateException; //导入方法依赖的package包/类
/**
 * check whether a certificate conforms to these NameConstraints.
 * This involves verifying that the subject name and subjectAltName
 * extension (critical or noncritical) is consistent with the permitted
 * subtrees state variables.  Also verify that the subject name and
 * subjectAltName extension (critical or noncritical) is consistent with
 * the excluded subtrees state variables.
 *
 * @param cert X509Certificate to be verified
 * @returns true if certificate verifies successfully
 * @throws IOException on error
 */
public boolean verify(X509Certificate cert) throws IOException {

    if (cert == null) {
        throw new IOException("Certificate is null");
    }

    // Calculate hasMin and hasMax booleans (if necessary)
    if (!minMaxValid) {
        calcMinMax();
    }

    if (hasMin) {
        throw new IOException("Non-zero minimum BaseDistance in"
                            + " name constraints not supported");
    }

    if (hasMax) {
        throw new IOException("Maximum BaseDistance in"
                            + " name constraints not supported");
    }

    X500Principal subjectPrincipal = cert.getSubjectX500Principal();
    X500Name subject = X500Name.asX500Name(subjectPrincipal);

    if (subject.isEmpty() == false) {
        if (verify(subject) == false) {
            return false;
        }
    }

    GeneralNames altNames = null;
    // extract altNames
    try {
        // extract extensions, if any, from certInfo
        // following returns null if certificate contains no extensions
        X509CertImpl certImpl = X509CertImpl.toImpl(cert);
        SubjectAlternativeNameExtension altNameExt =
            certImpl.getSubjectAlternativeNameExtension();
        if (altNameExt != null) {
            // extract altNames from extension; this call does not
            // return an IOException on null altnames
            altNames = altNameExt.get(
                    SubjectAlternativeNameExtension.SUBJECT_NAME);
        }
    } catch (CertificateException ce) {
        throw new IOException("Unable to extract extensions from " +
                    "certificate: " + ce.getMessage());
    }

    // If there are no subjectAlternativeNames, perform the special-case
    // check where if the subjectName contains any EMAILADDRESS
    // attributes, they must be checked against RFC822 constraints.
    // If that passes, we're fine.
    if (altNames == null) {
        return verifyRFC822SpecialCase(subject);
    }

    // verify each subjectAltName
    for (int i = 0; i < altNames.size(); i++) {
        GeneralNameInterface altGNI = altNames.get(i).getName();
        if (!verify(altGNI)) {
            return false;
        }
    }

    // All tests passed.
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:81,代码来源:NameConstraintsExtension.java

示例10: verify

import java.security.cert.CertificateException; //导入方法依赖的package包/类
/**
 * check whether a certificate conforms to these NameConstraints.
 * This involves verifying that the subject name and subjectAltName
 * extension (critical or noncritical) is consistent with the permitted
 * subtrees state variables.  Also verify that the subject name and
 * subjectAltName extension (critical or noncritical) is consistent with
 * the excluded subtrees state variables.
 *
 * @param cert X509Certificate to be verified
 * @return true if certificate verifies successfully
 * @throws IOException on error
 */
public boolean verify(X509Certificate cert) throws IOException {

    if (cert == null) {
        throw new IOException("Certificate is null");
    }

    // Calculate hasMin and hasMax booleans (if necessary)
    if (!minMaxValid) {
        calcMinMax();
    }

    if (hasMin) {
        throw new IOException("Non-zero minimum BaseDistance in"
                            + " name constraints not supported");
    }

    if (hasMax) {
        throw new IOException("Maximum BaseDistance in"
                            + " name constraints not supported");
    }

    X500Principal subjectPrincipal = cert.getSubjectX500Principal();
    X500Name subject = X500Name.asX500Name(subjectPrincipal);

    if (subject.isEmpty() == false) {
        if (verify(subject) == false) {
            return false;
        }
    }

    GeneralNames altNames = null;
    // extract altNames
    try {
        // extract extensions, if any, from certInfo
        // following returns null if certificate contains no extensions
        X509CertImpl certImpl = X509CertImpl.toImpl(cert);
        SubjectAlternativeNameExtension altNameExt =
            certImpl.getSubjectAlternativeNameExtension();
        if (altNameExt != null) {
            // extract altNames from extension; this call does not
            // return an IOException on null altnames
            altNames = altNameExt.get(
                    SubjectAlternativeNameExtension.SUBJECT_NAME);
        }
    } catch (CertificateException ce) {
        throw new IOException("Unable to extract extensions from " +
                    "certificate: " + ce.getMessage());
    }

    // If there are no subjectAlternativeNames, perform the special-case
    // check where if the subjectName contains any EMAILADDRESS
    // attributes, they must be checked against RFC822 constraints.
    // If that passes, we're fine.
    if (altNames == null) {
        return verifyRFC822SpecialCase(subject);
    }

    // verify each subjectAltName
    for (int i = 0; i < altNames.size(); i++) {
        GeneralNameInterface altGNI = altNames.get(i).getName();
        if (!verify(altGNI)) {
            return false;
        }
    }

    // All tests passed.
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:81,代码来源:NameConstraintsExtension.java


注:本文中的java.security.cert.CertificateException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。