本文整理匯總了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();
}
}
}