BYOKUnwrapFactory.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.pdd.config;

  21. import java.util.Map;

  22. import org.openspcoop2.pdd.core.byok.BYOKUnwrapPolicyUtilities;
  23. import org.openspcoop2.pdd.core.dynamic.DynamicMapBuilderUtils;
  24. import org.openspcoop2.utils.UtilsException;
  25. import org.openspcoop2.utils.certificate.byok.BYOKProvider;
  26. import org.openspcoop2.utils.transport.http.IBYOKUnwrapFactory;
  27. import org.openspcoop2.utils.transport.http.IBYOKUnwrapManager;
  28. import org.slf4j.Logger;

  29. /**
  30.  * BYOKUnwrapManager
  31.  *
  32.  * @author Poli Andrea (apoli@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class BYOKUnwrapFactory implements IBYOKUnwrapFactory {

  37.     @Override
  38.     public IBYOKUnwrapManager newInstance(String policy, Logger log) throws UtilsException {
  39.         return getBYOKUnwrapManager(policy, log);
  40.     }

  41.     public static IBYOKUnwrapManager getBYOKUnwrapManager(String idPolicy, Logger log) throws UtilsException{
  42.         IBYOKUnwrapManager byokUnwrapManager = null;
  43.         if(BYOKProvider.isPolicyDefined(idPolicy)) {
  44.             Map<String, Object> dynamicMap = DynamicMapBuilderUtils.buildDynamicMap(null, null, null,
  45.                     log);
  46.             try {
  47.                 byokUnwrapManager = BYOKUnwrapPolicyUtilities.getBYOKUnwrapManager(idPolicy, dynamicMap);
  48.             }catch(Exception e) {
  49.                 throw new UtilsException(e.getMessage(),e);
  50.             }
  51.         }
  52.         return byokUnwrapManager;
  53.     }
  54. }