Doc bug: setEntry(String, KeyStore.Entry, char[]) does not exist

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 6
    • Affects Version/s: 6
    • Component/s: security-libs
    • None
    • beta
    • x86
    • windows_xp
    • Verified

      This is from Keystore javadoc:
      ----------------
       Before a keystore can be accessed, it must be loaded.

          KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());

          // get user password and file input stream
          char[] password = getPassword();
          java.io.FileInputStream fis =
              new java.io.FileInputStream("keyStoreName");
          ks.load(fis, password);
          fis.close();
       

      To create an empty keystore using the above load method, pass null as the InputStream argument.

      Once the keystore has been loaded, it is possible to read existing entries from the keystore, or to write new entries into the keystore:

          // get my private key
          KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
              ks.getEntry("privateKeyAlias", password);
          PrivateKey myPrivateKey = pkEntry.getPrivateKey();

          // save my secret key
          javax.crypto.SecretKey mySecretKey;
          KeyStore.SecretKeyEntry skEntry =
              new KeyStore.SecretKeyEntry(mySecretKey);
          ks.setEntry("secretKeyAlias", skEntry, password);

          // store away the keystore
          java.io.FileOutputStream fos =
              new java.io.FileOutputStream("newKeyStoreName");
          ks.store(fos, password);
          fos.close();
      -----------------

      In the example code, there is a call to setEntry(String, KeyStore.Entry, char[]), which does not exist.

            Assignee:
            Weijun Wang
            Reporter:
            Bill Situ
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: