SecretPasswordKeyDerivationConfig.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.security.keystore;

  21. import java.io.Serializable;

  22. /**
  23.  * SecretPasswordKeyDerivationConfig
  24.  *
  25.  * @author Andrea Poli (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public class SecretPasswordKeyDerivationConfig implements Serializable {

  30.     private static final long serialVersionUID = 1L;
  31.    
  32.     private String pwd = null;
  33.     private String pwdEncryptionMode = null;
  34.     private Integer pwdIteration = null;
  35.    
  36.     public SecretPasswordKeyDerivationConfig(String pwd, String pwdEncryptionMode) {
  37.         this(pwd, pwdEncryptionMode, null);
  38.     }
  39.     public SecretPasswordKeyDerivationConfig(String pwd, String pwdEncryptionMode, Integer pwdIteration) {
  40.         this.pwd = pwd;
  41.         this.pwdEncryptionMode = pwdEncryptionMode;
  42.         this.pwdIteration = pwdIteration;
  43.     }
  44.    
  45.     public String toKey() {
  46.         StringBuilder sb = new StringBuilder("PwdDerivationConfig_");
  47.         sb.append("mode:").append(this.pwdEncryptionMode);
  48.         sb.append("_");
  49.         sb.append("iter:").append(this.pwdIteration!=null ? this.pwdIteration : "-");
  50.         sb.append("_");
  51.         sb.append(this.pwd);
  52.         return sb.toString();
  53.     }
  54.    
  55.     public String getPassword() {
  56.         return this.pwd;
  57.     }
  58.     public String getPasswordEncryptionMode() {
  59.         return this.pwdEncryptionMode;
  60.     }
  61.     public Integer getPasswordIterator() {
  62.         return this.pwdIteration;
  63.     }
  64. }