當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。