本文整理汇总了Java中java.security.KeyStoreException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStoreException.printStackTrace方法的具体用法?Java KeyStoreException.printStackTrace怎么用?Java KeyStoreException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.KeyStoreException
的用法示例。
在下文中一共展示了KeyStoreException.printStackTrace方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import java.security.KeyStoreException; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtKeystoreState = (TextView) findViewById(R.id.txtLabelKeyStore);
try {
secureUserStore = new SecureUserStore(this);
SyncManager.setUserStore(secureUserStore);
if (secureUserStore.isKeystoreUnlocked()) {
buildSyncConf();
keystoreUnlockedMessage();
} else {
secureUserStore.unlockKeystore();
}
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例2: carregarCertificados
import java.security.KeyStoreException; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
public void carregarCertificados() {
try {
this.getCertificadoKeyStore();
} catch (KeyStoreException e) {
e.printStackTrace();
}
System.clearProperty("javax.net.ssl.keyStore");
System.clearProperty("javax.net.ssl.keyStorePassword");
System.clearProperty("javax.net.ssl.trustStore");
if (this.getTipoCertificado().equals(TipoCertificado.A1)) {
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("javax.net.ssl.keyStore", this.getCaminhoParaCertificado());
System.setProperty("javax.net.ssl.keyStorePassword", this.getSenhaCertificado());
} else if (this.getTipoCertificado().equals(TipoCertificado.A3_CARD)) {
System.setProperty("javax.net.ssl.keyStore", "NONE");
System.setProperty("javax.net.ssl.keyStoreType", "PKCS11");
System.setProperty("javax.net.ssl.keyStoreProvider", "SunPKCS11-SmartCard");
} else if (this.getTipoCertificado().equals(TipoCertificado.A3_TOKEN)) {
System.setProperty("javax.net.ssl.keyStore", "NONE");
System.setProperty("javax.net.ssl.keyStoreType", "PKCS11");
System.setProperty("javax.net.ssl.keyStoreProvider", "SunPKCS11-eToken");
}
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", this.getCaminhoParaCadeiaCertificado());
}
示例3: TrustStoreController
import java.security.KeyStoreException; //导入方法依赖的package包/类
/**
* This Initializes the TrustStoreController.
*/
public TrustStoreController(Dialog ownerDialog, File trustStoreFile, String trustStorePassword, boolean edit) {
this.ownerDialog = ownerDialog;
try {
trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
if (trustStoreFile != null && trustStorePassword != null) {
if(edit){
openTrustStore(trustStoreFile, trustStorePassword);
} else {
createTrustStore(trustStoreFile, trustStorePassword);
}
}
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例4: getTrustedCertificatesList
import java.security.KeyStoreException; //导入方法依赖的package包/类
/**
* Get TrustedCertificates list .
* @return the trusted certificates list
*/
public Enumeration<String> getTrustedCertificatesList() {
CertificateProperties certificateProperties = null;
try {
// --- Creates a FileInputStream from the TrustStore -----
certificateProperties = new CertificateProperties();
// --- Get All TrustStore's Certificates Alias -----------
Enumeration<String> enumeration = trustStore.aliases();
while (enumeration.hasMoreElements()) {
String alias = enumeration.nextElement();
Certificate cert = trustStore.getCertificate(alias);
certificateProperties.parseFromCertificate((X509Certificate) cert);
certificateProperties.setAlias(alias);
addTableModelRow(certificateProperties);
}
return trustStore.aliases();
} catch (KeyStoreException e) {
e.printStackTrace();
}
return null;
}
示例5: onResume
import java.security.KeyStoreException; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
try {
// We return to the app after the KeyStore is unlocked or not.
if (secureUserStore.isKeystoreUnlocked()) {
buildSyncConf();
keystoreUnlockedMessage();
} else {
keystoreLockedMessage();
}
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例6: onKsPassChange
import java.security.KeyStoreException; //导入方法依赖的package包/类
@FXML
protected void onKsPassChange() {
String pass = key_store_pass.getText();
File kfile = new File(key_store_path.getText());
if(!kfile.isFile()) return;
KeyStore ks = null;
try {
ks = KeyStore.getInstance(KeyStore.getDefaultType());
if(parseKsFile(ks, kfile, pass)) {
// read keystore file
Enumeration<String> aliases = ks.aliases();
ArrayList<String> rel = new ArrayList<>();
while(aliases.hasMoreElements()) {
String alia = aliases.nextElement();
rel.add(alia);
}
if(rel.isEmpty()) return;
ObservableList<String> olist = FXCollections.observableArrayList(rel);
key_alias.setItems(olist);
key_alias.setValue(rel.get(0));
} else {
key_alias.setItems(null);
}
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例7: changeAlias
import java.security.KeyStoreException; //导入方法依赖的package包/类
/**
* Change a certificate alias.
* @param oldAlias the old alias
* @param newAlias the new alias
*/
public void changeAlias(String oldAlias, String newAlias) {
System.out.println("change alias from " + oldAlias + " to " + newAlias);
try {
if (trustStore.isCertificateEntry(oldAlias)) {
System.out.println("isCertificateEntry");
}
Certificate cert = trustStore.getCertificate(oldAlias);
trustStore.deleteEntry(oldAlias);
trustStore.setCertificateEntry(newAlias, cert);
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例8: deleteCertificateFromTrustStore
import java.security.KeyStoreException; //导入方法依赖的package包/类
/**
* This method allows the user to delete certificate from TrustStore.
* @param certificateAliasToDelete the certificate alias to delete
*/
public void deleteCertificateFromTrustStore(String certificateAliasToDelete) {
try {
// ---- Delete the certificate from the TrustStore -------------
trustStore.deleteEntry(certificateAliasToDelete);
saveTrustStore();
} catch (KeyStoreException e) {
e.printStackTrace();
}
}
示例9: getCertificate
import java.security.KeyStoreException; //导入方法依赖的package包/类
/**
* Gets the certificate with the specified alias.
* @param alias the alias
* @return the certificate
*/
public X509Certificate getCertificate(String alias) {
Certificate cert = null;
try {
cert = trustStore.getCertificate(alias);
} catch (KeyStoreException e) {
e.printStackTrace();
}
return (X509Certificate) cert;
}
示例10: main
import java.security.KeyStoreException; //导入方法依赖的package包/类
public static void main(String[] args) throws CertificateException,
UnrecoverableKeyException, KeyStoreException,
NoSuchProviderException, NoSuchAlgorithmException, IOException {
WriteP12Test jstest = new WriteP12Test();
out.println("test WriteP12CertChain");
/*
* WriteP12CertChain: This test creates a p12 keystore contains one
* entry with private key and a certificate chains contains three
* certificates in the order of user->lead->ca. This case expects to
* pass.
*/
jstest.test(new Certificate[] { jstest.testerCert, jstest.testLeadCert,
jstest.caCert }, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1",
"pass", "pass");
/*
* WriteP12CertChainBad: same as WriteP12CertChain but chains order is
* user-ca-lead, the order is wrong so expects to fail.
*/
out.println("test WriteP12CertChainBad");
try {
jstest.test(new Certificate[] { jstest.testerCert, jstest.caCert,
jstest.testLeadCert }, IN_KEYSTORE_ENDUSER,
"pkcs12testenduser1", "pass", "pass");
throw new RuntimeException(
" Certificate chain is not valid, test should not pass."
+ " Test failed.");
} catch (KeyStoreException e) {
e.printStackTrace();
out.println(" Certificate chain is not valid,exception is"
+ " expected. Test passed.");
}
/*
* WriteP12PrivateKey:This test creates a p12 contains a self-signed
* cert and private key,expects no exception
*/
out.println("test WriteP12PrivateKey");
jstest.test(null, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1", "pass",
"pass");
/*
* WriteP12TwoEntry: This test creates a p12 keystore with different
* storepass and keypass, and contains two entries.
*/
out.println("test WriteP12TwoEntry");
jstest.testTwoEntry(IN_KEYSTORE_ENDUSER, IN_KEYSTORE_CA,
"pkcs12testenduser1", "pass", "pass");
/*
* WriteP12TwoPass: This test creates a p12 keystore with different
* storepass and keypass, and contains one entry with private key and a
* certificate
*/
out.println("test WriteP12TwoPass");
jstest.test(null, IN_KEYSTORE_CA, "pkcs12testCA", "storepass",
"keypass");
}