< prev index next >

jdk/test/sun/security/tools/keytool/KeyToolTest.java

Print this page




1744         testFail("", "-list -protected -storepass password " +
1745                 "-keystore x.jks -storetype JKS");
1746         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1747         //   6. keytool -keypasswd -protected -keypass password
1748         // Check error (password can not be specified with -protected)
1749         testFail("", "-keypasswd -protected -keypass password " +
1750                 "-keystore x.jks -storetype JKS");
1751         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1752         //   7. keytool -keypasswd -protected -new password
1753         // Check error (password can not be specified with -protected)
1754         testFail("", "-keypasswd -protected -new password " +
1755                 "-keystore x.jks -storetype JKS");
1756         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1757         remove("x.jks");
1758     }
1759 
1760     void i18nPKCS11Test() throws Exception {
1761         //PKCS#11 tests
1762 
1763         //   1. sccs edit cert8.db key3.db
1764         //Runtime.getRuntime().exec("/usr/ccs/bin/sccs edit cert8.db key3.db");
1765         testOK("", p11Arg + ("-storepass test12 -genkey -alias genkey" +
1766                 " -dname cn=genkey -keysize 512 -keyalg rsa"));
1767         testOK("", p11Arg + "-storepass test12 -list");
1768         testOK("", p11Arg + "-storepass test12 -list -alias genkey");
1769         testOK("", p11Arg +
1770                 "-storepass test12 -certreq -alias genkey -file genkey.certreq");
1771         testOK("", p11Arg +
1772                 "-storepass test12 -export -alias genkey -file genkey.cert");
1773         testOK("", "-printcert -file genkey.cert");
1774         testOK("", p11Arg +
1775                 "-storepass test12 -selfcert -alias genkey -dname cn=selfCert");
1776         testOK("", p11Arg +
1777                 "-storepass test12 -list -alias genkey -v");
1778         assertTrue(out.indexOf("Owner: CN=selfCert") != -1);
1779         //(check that cert subject DN is [cn=selfCert])
1780         testOK("", p11Arg + "-storepass test12 -delete -alias genkey");
1781         testOK("", p11Arg + "-storepass test12 -list");
1782         assertTrue(out.indexOf("Your keystore contains 0 entries") != -1);
1783         //(check for empty database listing)
1784         //Runtime.getRuntime().exec("/usr/ccs/bin/sccs unedit cert8.db key3.db");
1785         remove("genkey.cert");
1786         remove("genkey.certreq");
1787         //  12. sccs unedit cert8.db key3.db
1788     }
1789 
1790     // tesing new option -srcProviderName
1791     void sszzTest() throws Exception {
1792         testAnyway("", NSS_P11_ARG+"-delete -alias nss -storepass test12");
1793         testAnyway("", NZZ_P11_ARG+"-delete -alias nss -storepass test12");
1794         testOK("", NSS_P11_ARG+"-genkeypair -dname CN=NSS " +
1795                 "-alias nss -storepass test12");
1796         testOK("", NSS_SRC_P11_ARG + NZZ_P11_ARG +
1797                 "-importkeystore -srcstorepass test12 -deststorepass test12");
1798         testAnyway("", NSS_P11_ARG+"-delete -alias nss -storepass test12");
1799         testAnyway("", NZZ_P11_ARG+"-delete -alias nss -storepass test12");
1800     }
1801 
1802     public static void main(String[] args) throws Exception {
1803         Locale reservedLocale = Locale.getDefault();
1804         try {




1744         testFail("", "-list -protected -storepass password " +
1745                 "-keystore x.jks -storetype JKS");
1746         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1747         //   6. keytool -keypasswd -protected -keypass password
1748         // Check error (password can not be specified with -protected)
1749         testFail("", "-keypasswd -protected -keypass password " +
1750                 "-keystore x.jks -storetype JKS");
1751         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1752         //   7. keytool -keypasswd -protected -new password
1753         // Check error (password can not be specified with -protected)
1754         testFail("", "-keypasswd -protected -new password " +
1755                 "-keystore x.jks -storetype JKS");
1756         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
1757         remove("x.jks");
1758     }
1759 
1760     void i18nPKCS11Test() throws Exception {
1761         //PKCS#11 tests
1762 
1763         //   1. sccs edit cert8.db key3.db
1764         //Runtime.getRuntime().exec("/usr/bin/sccs edit cert8.db key3.db");
1765         testOK("", p11Arg + ("-storepass test12 -genkey -alias genkey" +
1766                 " -dname cn=genkey -keysize 512 -keyalg rsa"));
1767         testOK("", p11Arg + "-storepass test12 -list");
1768         testOK("", p11Arg + "-storepass test12 -list -alias genkey");
1769         testOK("", p11Arg +
1770                 "-storepass test12 -certreq -alias genkey -file genkey.certreq");
1771         testOK("", p11Arg +
1772                 "-storepass test12 -export -alias genkey -file genkey.cert");
1773         testOK("", "-printcert -file genkey.cert");
1774         testOK("", p11Arg +
1775                 "-storepass test12 -selfcert -alias genkey -dname cn=selfCert");
1776         testOK("", p11Arg +
1777                 "-storepass test12 -list -alias genkey -v");
1778         assertTrue(out.indexOf("Owner: CN=selfCert") != -1);
1779         //(check that cert subject DN is [cn=selfCert])
1780         testOK("", p11Arg + "-storepass test12 -delete -alias genkey");
1781         testOK("", p11Arg + "-storepass test12 -list");
1782         assertTrue(out.indexOf("Your keystore contains 0 entries") != -1);
1783         //(check for empty database listing)
1784         //Runtime.getRuntime().exec("/usr/bin/sccs unedit cert8.db key3.db");
1785         remove("genkey.cert");
1786         remove("genkey.certreq");
1787         //  12. sccs unedit cert8.db key3.db
1788     }
1789 
1790     // tesing new option -srcProviderName
1791     void sszzTest() throws Exception {
1792         testAnyway("", NSS_P11_ARG+"-delete -alias nss -storepass test12");
1793         testAnyway("", NZZ_P11_ARG+"-delete -alias nss -storepass test12");
1794         testOK("", NSS_P11_ARG+"-genkeypair -dname CN=NSS " +
1795                 "-alias nss -storepass test12");
1796         testOK("", NSS_SRC_P11_ARG + NZZ_P11_ARG +
1797                 "-importkeystore -srcstorepass test12 -deststorepass test12");
1798         testAnyway("", NSS_P11_ARG+"-delete -alias nss -storepass test12");
1799         testAnyway("", NZZ_P11_ARG+"-delete -alias nss -storepass test12");
1800     }
1801 
1802     public static void main(String[] args) throws Exception {
1803         Locale reservedLocale = Locale.getDefault();
1804         try {


< prev index next >