code: public void encrypt(byte[] password) throws GeneralSecurityException {
  
          if (isEncrypted()) {
              return;
          }
  
          if (this.encAlg == null) {
              setEncryptionAlgorithm("DES-EDE3-CBC");
          }
  
          if (this.ivData == null) {
              generateIV();
          }
  
          Key key = getSecretKey(password, this.initializationVector.getIV());
  
          Cipher cipher = getCipher();
          cipher.init(Cipher.ENCRYPT_MODE, key, this.initializationVector);
  
          /* encrypt the raw PKCS11 */
  
          this.keyData = cipher.doFinal(getEncoded(this.intKey));
          this.isEncrypted = true;
          this.encodedKey = null;
      }
docs: Encrypts the private key with given password.
  Does nothing if the key is encrypted already.
  
  @param password password to encrypt the key with.
  @throws GeneralSecurityException whenever an error occurs during encryption.