MultiKeystoreCache.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.cache;

  21. import org.openspcoop2.security.SecurityException;
  22. import org.openspcoop2.security.keystore.MultiKeystore;
  23. import org.openspcoop2.utils.certificate.byok.BYOKRequestParams;

  24. /**
  25.  * MultiKeystoreCache
  26.  *
  27.  * @author Andrea Poli (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class MultiKeystoreCache extends AbstractKeystoreCache<MultiKeystore> {

  32.     @Override
  33.     public MultiKeystore createKeystore(String key, Object... params)
  34.             throws SecurityException {
  35.         String propertyFilePath = key;
  36.         if(params==null || params.length<=0){
  37.             return new MultiKeystore(propertyFilePath);
  38.         }
  39.         if(params.length==1){
  40.             if( ! (params[0] instanceof BYOKRequestParams) ){
  41.                 throw new SecurityException("Param[0] must be BYOKRequestParams");
  42.             }
  43.             BYOKRequestParams requestParams = (BYOKRequestParams) params[0];
  44.             return new MultiKeystore(propertyFilePath,requestParams);
  45.         }
  46.         else{
  47.             throw new SecurityException("Params [lenght:"+params.length+"] not supported");
  48.         }
  49.     }

  50.     @Override
  51.     public String getPrefixKey() {
  52.         return "MultiKeystore ";
  53.     }
  54. }