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


Java TrustManager.flashTrustManager方法代碼示例

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


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

示例1: installCertificate

import com.sun.spot.peripheral.TrustManager; //導入方法依賴的package包/類
private void installCertificate(String certificateName) {
	    TrustManager trustManager = TrustManager.getTrustManager();
		if(trustManager.getCertStore().getCertByNickname(certificateName) == null) {
//		    try {
//                trustManager.getCertStore().addCert(certificateName, "", null);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
			try {
				InputStream is = StartApplication.class.getResourceAsStream("/" + certificateName + ".cer");
				byte[] buffer = new byte[4096];
				int byteCount = is.read(buffer);
				X509Certificate certificate = X509Certificate.generateCertificate(buffer, 0, byteCount);
				trustManager.getCertStore().addCert(certificateName, "", certificate);
				System.out.println("Installed certificate " + certificateName + " with fingerprint " + Utils.hexEncode(certificate.getFingerprint()));
				trustManager.flashTrustManager();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:22,代碼來源:StartApplication.java


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