code: public void addIdentity(Node privateKey, String passphrase) throws IOException, JSchException {
          Identity identity;
          Throwable te;
          Class<?> clz;
          Method m;
          byte[] bytes;
  
          bytes = privateKey.readBytes();
          // CAUTION: I cannot use
          //   jsch.addIdentity("foo", null, null, null);
          // because in jsch 1.48, there's no way to obtain the resulting identity and the identity.setPassphrase
          // result.
          try {
              clz = Class.forName("com.jcraft.jsch.IdentityFile");
              m = clz.getDeclaredMethod("newInstance", String.class, byte[].class, byte[].class, JSch.class);
              m.setAccessible(true);
              identity = (Identity) m.invoke(null, privateKey.toString(), Arrays.copyOf(bytes, bytes.length), null, jsch);
          } catch (InvocationTargetException e) {
              te = e.getTargetException();
              if (te instanceof JSchException) {
                  throw (JSchException) te;
              } else if (te instanceof IOException) {
                  throw (IOException) te;
              } else {
                  throw new IllegalStateException(e);
              }
          } catch (Exception e) {
              throw new RuntimeException("TODO", e);
          }
          if (passphrase != null) {
              if (!identity.isEncrypted()) {
                  throw new JSchException("unexpected passphrase");
              }
              if (!identity.setPassphrase(passphrase.getBytes())) {
                  throw new JSchException("invalid passphrase");
              }
          } else {
              if (!identity.setPassphrase(null)) {
                  throw new JSchException("missing passphrase");
              }
          }
          jsch.removeIdentity(identity);
          jsch.addIdentity(identity, null);
      }
docs: Core method to actually add an identity. Identity is a private/public key pair.
  Identities are "not interactive" - this method reports missing passphrases or when
  a passphrase is specified for an identity that does not need one.
  
  @param passphrase null of none