BYOKRequestParams.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.certificate.byok;

  21. import java.util.Map;

  22. import org.openspcoop2.utils.UtilsException;

  23. /**
  24.  * BYOKRequestParams
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class BYOKRequestParams {
  31.            
  32.     private Map<String,Object> dynamicMap; // non e' serializzabile; contiene oggetti non serializzabili
  33.    
  34.     private String keyIdentity; // local
  35.    
  36.     private BYOKConfig config;
  37.     private Map<String,String> inputMap;
  38.    
  39.     public Map<String, Object> getDynamicMap() {
  40.         return this.dynamicMap;
  41.     }
  42.     public void setDynamicMap(Map<String, Object> dynamicMap) {
  43.         this.dynamicMap = dynamicMap;
  44.     }
  45.    
  46.     public String getKeyIdentity() {
  47.         return this.keyIdentity;
  48.     }
  49.     public void setKeyIdentity(String keyIdentity) {
  50.         this.keyIdentity = keyIdentity;
  51.     }
  52.    
  53.     public BYOKConfig getConfig() {
  54.         return this.config;
  55.     }
  56.     public void setConfig(BYOKConfig config) {
  57.         this.config = config;
  58.     }
  59.     public Map<String, String> getInputMap() {
  60.         return this.inputMap;
  61.     }
  62.     public void setInputMap(Map<String, String> inputMap) {
  63.         this.inputMap = inputMap;
  64.     }
  65.    
  66.    
  67.     public static BYOKRequestParams getBYOKRequestParamsByKmsId(String kmsId,
  68.             Map<String, String> inputMap, Map<String, Object> dynamicMap) throws UtilsException {
  69.        
  70.         BYOKManager manager = BYOKManager.getInstance();
  71.         if(manager==null) {
  72.             throw new UtilsException("BYOKManager not initialized");
  73.         }
  74.        
  75.         return getBYOKRequestParamsByKmsId(kmsId, manager,
  76.                 inputMap, dynamicMap);
  77.     }
  78.     public static BYOKRequestParams getBYOKRequestParamsByKmsId(String kmsId, BYOKManager manager,
  79.             Map<String, String> inputMap, Map<String, Object> dynamicMap) throws UtilsException {
  80.         BYOKConfig bconfig = manager.getKMSConfigByType(kmsId);
  81.         if(bconfig==null) {
  82.             throw new UtilsException("BYOK configuration for kms id '"+kmsId+"' not found");
  83.         }
  84.         BYOKRequestParams req = new BYOKRequestParams();
  85.         req.setConfig(bconfig);
  86.            
  87.         req.setInputMap(inputMap);
  88.        
  89.         req.setDynamicMap(dynamicMap);
  90.        
  91.         req.setKeyIdentity(kmsId);
  92.        
  93.         return req;
  94.     }
  95. }