import
java.security.*;
import
java.security.cert.*;
import
java.util.*;
import
java.io.*;
public
class
GFG {
public
static
void
main(String[] argv)
{
try
{
Enumeration<String> e =
null
;
KeyStore sr = KeyStore.getInstance(
"JKS"
);
char
[] pass = (
"123456"
).toCharArray();
InputStream is
=
new
FileInputStream(
"f:/java/private key.store"
);
sr.load(is, pass);
e = sr.aliases();
System.out.println(
"List of all the alias"
+
" present before deletion"
);
while
(e.hasMoreElements()) {
System.out.print(e.nextElement() +
" "
);
System.out.println();
}
sr.deleteEntry(
"htttp"
);
e = sr.aliases();
System.out.println(
"\nList of all the alias"
+
" present after deletion"
);
while
(e.hasMoreElements()) {
System.out.print(e.nextElement() +
" "
);
System.out.println();
}
}
catch
(NoSuchAlgorithmException e) {
System.out.println(
"Exception thrown : "
+ e);
}
catch
(NullPointerException e) {
System.out.println(
"Exception thrown : "
+ e);
}
catch
(KeyStoreException e) {
System.out.println(
"Exception thrown : "
+ e);
}
catch
(FileNotFoundException e) {
System.out.println(
"Exception thrown : "
+ e);
}
catch
(IOException e) {
System.out.println(
"Exception thrown : "
+ e);
}
catch
(CertificateException e) {
System.out.println(
"Exception thrown : "
+ e);
}
}
}