code: private void initCipher(int mode) throws InvalidKeyException, InvalidAlgorithmParameterException
      {
          if (key != null)
          {
              if (params != null)
              {
                  if (random != null)
                  {
                      cipher.init(mode, key, params, random);
                  }
                  else
                  {
                      cipher.init(mode, key, params);
                  }
              }
              else if (spec != null)
              {
                  if (random != null)
                  {
                      cipher.init(mode, key, spec, random);
                  }
                  else
                  {
                      cipher.init(mode, key, spec);
                  }
              }
              else
              {
                  if (random != null)
                  {
                      cipher.init(mode, key, random);
                  }
                  else
                  {
                      cipher.init(mode, key);
                  }
              }
          }
          else
          {
              if (random != null)
              {
                  cipher.init(mode, certificate, random);
              }
              else
              {
                  cipher.init(mode, certificate);
              }
          }
      }
docs: Initialize {@link cipher} by calling one of {@code Cipher.init} methods
  using {@code mode} and one or some of {@link #key}, {@link #params},
  {@link #spec}, {@link #certificate} and {@link #random}.