Decrypt.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.security;

  21. import java.security.Key;
  22. import java.security.cert.Certificate;

  23. import javax.crypto.spec.IvParameterSpec;

  24. import org.openspcoop2.utils.UtilsException;
  25. import org.openspcoop2.utils.certificate.KeyStore;
  26. import org.openspcoop2.utils.io.Base64Utilities;
  27. import org.openspcoop2.utils.io.HexBinaryUtilities;

  28. /**
  29.  * Encrypt
  30.  *
  31.  * @author Poli Andrea (apoli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class Decrypt extends AbstractCipher {


  36.     public Decrypt(byte[] secretKey, String algorithm) {
  37.         super(javax.crypto.Cipher.DECRYPT_MODE, secretKey, algorithm);
  38.     }
  39.     public Decrypt(byte[] secretKey, String algorithm, IvParameterSpec ivParameterSpec) {
  40.         super(javax.crypto.Cipher.DECRYPT_MODE, secretKey, algorithm, ivParameterSpec);
  41.     }
  42.     public Decrypt(byte[] secretKey, String algorithm, byte[] ivParameterSpec) {
  43.         super(javax.crypto.Cipher.DECRYPT_MODE, secretKey, algorithm, ivParameterSpec);
  44.     }

  45.     public Decrypt(Certificate certificate) {
  46.         super(javax.crypto.Cipher.DECRYPT_MODE, certificate);
  47.     }

  48.     public Decrypt(Key key) {
  49.         super(javax.crypto.Cipher.DECRYPT_MODE, key);
  50.     }
  51.     public Decrypt(Key key, IvParameterSpec ivParameterSpec) {
  52.         super(javax.crypto.Cipher.DECRYPT_MODE, key, ivParameterSpec);
  53.     }
  54.     public Decrypt(Key key, byte[] ivParameterSpec) {
  55.         super(javax.crypto.Cipher.DECRYPT_MODE, key, ivParameterSpec);
  56.     }

  57.     public Decrypt(KeyStore keystore, String alias, String passwordPrivateKey) throws UtilsException {
  58.         super(javax.crypto.Cipher.DECRYPT_MODE, keystore, alias, passwordPrivateKey);
  59.     }

  60.     public Decrypt(KeyStore keystore, String alias) throws UtilsException {
  61.         super(javax.crypto.Cipher.DECRYPT_MODE, keystore, alias);
  62.     }

  63.     public Decrypt(KeyStore keystore) throws UtilsException {
  64.         super(javax.crypto.Cipher.DECRYPT_MODE, keystore);
  65.     }

  66.     public byte[] decrypt(byte[] data, String algorithm) throws UtilsException{
  67.         return super.process(data, algorithm);
  68.     }
  69.    
  70.     public byte[] decryptBase64(byte[] data, String algorithm) throws UtilsException{
  71.         return super.process(Base64Utilities.decode(data),algorithm);
  72.     }
  73.    
  74.     public byte[] decryptBase64(String data, String algorithm) throws UtilsException{
  75.         return super.process(Base64Utilities.decode(data),algorithm);
  76.     }
  77.    
  78.     public byte[] decryptHexBinary(char[] data, String algorithm) throws UtilsException{
  79.         return super.process(HexBinaryUtilities.decode(data),algorithm);
  80.     }
  81.    
  82.     public byte[] decryptHexBinary(String data, String algorithm) throws UtilsException{
  83.         return super.process(HexBinaryUtilities.decode(data),algorithm);
  84.     }
  85.    

  86. }