JasyptType.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.crypt;

  21. /**
  22.  * JasyptType
  23.  *
  24.  * @author Poli Andrea (apoli@link.it)
  25.  * @author $Author$
  26.  * @version $Rev$, $Date$
  27.  */
  28. public enum JasyptType {

  29.     /*
  30.      * http://www.jasypt.org/api/jasypt/1.8/org/jasypt/util/password/rfc2307/package-summary.html
  31.      */
  32.     RFC2307_MD5, // Algorithm: MD5, Salt size: 0 (no salt), Iterations: 1 (no hash iteration), Prefix: {MD5}
  33.     RFC2307_SMD5, // Algorithm: MD5, Salt size: 8, Iterations: 1 (no hash iteration), Prefix: {SMD5}, Invert position of salt in message before digesting, Invert position of plain salt in encryption results, Use lenient salt size check
  34.     RFC2307_SHA, // Algorithm: SHA-1, Salt size: 0 (no salt), Iterations: 1 (no hash iteration), Prefix: {SHA}
  35.     RFC2307_SSHA, // Algorithm: SHA-1, Salt size: 8, Iterations: 1 (no hash iteration), Prefix: {SSHA}, Invert position of salt in message before digesting, Invert position of plain salt in encryption results, Use lenient salt size check
  36.    
  37.     /*
  38.      * http://www.jasypt.org/api/jasypt/1.8/org/jasypt/util/password/package-summary.html
  39.      */
  40.     JASYPT_BASIC_PASSWORD, // Algorithm: MD5, Salt size: 8, Iterations: 1000
  41.     JASYPT_STRONG_PASSWORD; // Algorithm: SHA-256, Salt size: 16, Iterations: 100000
  42.    
  43.     public CryptType toCryptType() {
  44.         switch (this) {
  45.        
  46.         case RFC2307_MD5:
  47.             return CryptType.RFC2307_MD5;
  48.         case RFC2307_SMD5:
  49.             return CryptType.RFC2307_SMD5;
  50.         case RFC2307_SHA:
  51.             return CryptType.RFC2307_SHA;
  52.         case RFC2307_SSHA:
  53.             return CryptType.RFC2307_SSHA;
  54.            
  55.         case JASYPT_BASIC_PASSWORD:
  56.             return CryptType.JASYPT_BASIC_PASSWORD;
  57.         case JASYPT_STRONG_PASSWORD:
  58.             return CryptType.JASYPT_STRONG_PASSWORD;
  59.            
  60.         default:
  61.             return null;
  62.         }
  63.     }
  64. }