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


Java CertificateException.printStackTrace方法代碼示例

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


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

示例1: v

import java.security.cert.CertificateException; //導入方法依賴的package包/類
public static String v(Context context) {
    PackageInfo packageInfo;
    String str = null;
    try {
        packageInfo = context.getPackageManager().getPackageInfo(u(context), 64);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        Object obj = str;
    }
    InputStream byteArrayInputStream = new ByteArrayInputStream(packageInfo.signatures[0].toByteArray());
    try {
        CertificateFactory instance = CertificateFactory.getInstance("X509");
    } catch (CertificateException e2) {
        e2.printStackTrace();
        obj = str;
    }
    try {
        X509Certificate x509Certificate = (X509Certificate) instance.generateCertificate(byteArrayInputStream);
    } catch (CertificateException e22) {
        e22.printStackTrace();
        obj = str;
    }
    try {
        str = a(MessageDigest.getInstance(CommonUtils.MD5_INSTANCE).digest(x509Certificate.getEncoded()));
    } catch (NoSuchAlgorithmException e3) {
        e3.printStackTrace();
    } catch (CertificateEncodingException e4) {
        e4.printStackTrace();
    }
    return str;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:32,代碼來源:bt.java

示例2: w

import java.security.cert.CertificateException; //導入方法依賴的package包/類
public static String w(Context context) {
    PackageInfo packageInfo;
    String str = null;
    try {
        packageInfo = context.getPackageManager().getPackageInfo(v(context), 64);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        Object obj = str;
    }
    InputStream byteArrayInputStream = new ByteArrayInputStream(packageInfo.signatures[0].toByteArray());
    try {
        CertificateFactory instance = CertificateFactory.getInstance("X509");
    } catch (CertificateException e2) {
        e2.printStackTrace();
        obj = str;
    }
    try {
        X509Certificate x509Certificate = (X509Certificate) instance.generateCertificate(byteArrayInputStream);
    } catch (CertificateException e22) {
        e22.printStackTrace();
        obj = str;
    }
    try {
        str = a(MessageDigest.getInstance(Coder.KEY_MD5).digest(x509Certificate.getEncoded()));
    } catch (NoSuchAlgorithmException e3) {
        e3.printStackTrace();
    } catch (CertificateEncodingException e4) {
        e4.printStackTrace();
    }
    return str;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:32,代碼來源:bt.java

示例3: getKeystoreOfCA

import java.security.cert.CertificateException; //導入方法依賴的package包/類
public static KeyStore getKeystoreOfCA(InputStream cert) {
    CertificateException e1;
    KeyStore keyStore;
    Throwable th;
    InputStream caInput = null;
    Certificate ca = null;
    try {
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        InputStream caInput2 = new BufferedInputStream(cert);
        try {
            ca = cf.generateCertificate(caInput2);
            if (caInput2 != null) {
                try {
                    caInput2.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    caInput = caInput2;
                }
            }
            caInput = caInput2;
        } catch (CertificateException e2) {
            e1 = e2;
            caInput = caInput2;
            try {
                e1.printStackTrace();
                if (caInput != null) {
                    try {
                        caInput.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                }
                keyStore = null;
                keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
                keyStore.load(null, null);
                keyStore.setCertificateEntry("ca", ca);
                return keyStore;
            } catch (Throwable th2) {
                th = th2;
                if (caInput != null) {
                    try {
                        caInput.close();
                    } catch (IOException e32) {
                        e32.printStackTrace();
                    }
                }
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            caInput = caInput2;
            if (caInput != null) {
                caInput.close();
            }
            throw th;
        }
    } catch (CertificateException e4) {
        e1 = e4;
        e1.printStackTrace();
        if (caInput != null) {
            caInput.close();
        }
        keyStore = null;
        keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
        keyStore.load(null, null);
        keyStore.setCertificateEntry("ca", ca);
        return keyStore;
    }
    keyStore = null;
    try {
        keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
        keyStore.load(null, null);
        keyStore.setCertificateEntry("ca", ca);
        return keyStore;
    } catch (Exception e5) {
        e5.printStackTrace();
        return keyStore;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:80,代碼來源:MySSLSocketFactory.java

示例4: main

import java.security.cert.CertificateException; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:46,代碼來源:BadFooter.java


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