ErogazioniCheckNotNull.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.core.config.rs.server.api.impl.erogazioni;

  21. import org.openspcoop2.core.config.rs.server.model.ApiImplAllegatoSpecificaLivelloServizio;
  22. import org.openspcoop2.core.config.rs.server.model.ApiImplAllegatoSpecificaSemiformale;
  23. import org.openspcoop2.core.config.rs.server.model.ApiImplAllegatoSpecificaSicurezza;
  24. import org.openspcoop2.core.config.rs.server.model.ConnettoreConfigurazioneHttpsClient;
  25. import org.openspcoop2.core.config.rs.server.model.GruppoNuovaConfigurazione;
  26. import org.openspcoop2.core.config.rs.server.model.TipoSpecificaLivelloServizioEnum;
  27. import org.openspcoop2.core.config.rs.server.model.TipoSpecificaSicurezzaEnum;
  28. import org.openspcoop2.core.registry.Documento;
  29. import org.openspcoop2.core.registry.constants.TipiDocumentoLivelloServizio;
  30. import org.openspcoop2.core.registry.constants.TipiDocumentoSemiformale;
  31. import org.openspcoop2.core.registry.constants.TipiDocumentoSicurezza;
  32. import org.openspcoop2.utils.service.fault.jaxrs.FaultCode;
  33. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;

  34. /**
  35.  * ErogazioniCheckNotNull
  36.  *
  37.  * @author $Author$
  38.  * @version $Rev$, $Date$
  39.  */
  40. public class ErogazioniCheckNotNull {

  41.     public static String getHttpskeystore(ConnettoreConfigurazioneHttpsClient httpsClient) {
  42.         String httpskeystore = null;
  43.         if ( httpsClient != null ) {
  44.             if ( httpsClient.getKeystorePath() != null || httpsClient.getKeystoreTipo() != null ) {
  45.                 httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_RIDEFINISCI;  
  46.             }
  47.             else
  48.                 httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  49.         }
  50.         return httpskeystore;
  51.     }
  52.    
  53.     public static void checkAutenticazione(GruppoNuovaConfigurazione conf) {
  54.         if (conf.getAutenticazione() == null) {
  55.             throw FaultCode.RICHIESTA_NON_VALIDA.toException(GruppoNuovaConfigurazione.class.getName()+": Indicare il campo obbligatorio 'autenticazione'");
  56.         }
  57.     }
  58.    
  59.     public static boolean isNotNullTipoSpecifica(ApiImplAllegatoSpecificaSemiformale allegatoSS, Documento documento) {
  60.         if(allegatoSS.getTipoSpecifica()==null) {
  61.             documento.setTipo(TipiDocumentoSemiformale.LINGUAGGIO_NATURALE.toString()); // default
  62.             return false;
  63.         }
  64.         return true;
  65.     }
  66.    
  67.     public static boolean isNotNullTipoSpecifica(ApiImplAllegatoSpecificaLivelloServizio allegatoLS, Documento documento) {
  68.         if(allegatoLS.getTipoSpecifica()==null) {
  69.             documento.setTipo(TipiDocumentoLivelloServizio.WSLA.toString()); // default
  70.             return false;
  71.         }
  72.         return true;
  73.     }
  74.    
  75.     public static boolean isNotNullTipoSpecifica(ApiImplAllegatoSpecificaSicurezza allegatoLS, Documento documento) {
  76.         if(allegatoLS.getTipoSpecifica()==null) {
  77.             documento.setTipo(TipiDocumentoSicurezza.LINGUAGGIO_NATURALE.toString()); // default
  78.             return false;
  79.         }
  80.         return true;
  81.     }
  82.    
  83.     public static void documentoToImplAllegato(ApiImplAllegatoSpecificaLivelloServizio allegatoSL, TipiDocumentoLivelloServizio tipo) {
  84.         if(allegatoSL.getTipoSpecifica()==null) {
  85.             if(TipiDocumentoLivelloServizio.WSAGREEMENT.equals(tipo)) {
  86.                 allegatoSL.setTipoSpecifica(TipoSpecificaLivelloServizioEnum.WS_AGREEMENT);
  87.             }
  88.         }
  89.     }
  90.    
  91.     public static void documentoToImplAllegato(ApiImplAllegatoSpecificaSicurezza allegatoSSec, TipiDocumentoSicurezza tipo) {
  92.         if(allegatoSSec.getTipoSpecifica()==null) {
  93.             if(TipiDocumentoSicurezza.WSPOLICY.equals(tipo)) {
  94.                 allegatoSSec.setTipoSpecifica(TipoSpecificaSicurezzaEnum.WS_POLICY);
  95.             }
  96.             else if(TipiDocumentoSicurezza.XACML_POLICY.equals(tipo)) {
  97.                 allegatoSSec.setTipoSpecifica(TipoSpecificaSicurezzaEnum.XACML_POLICY);
  98.             }
  99.         }
  100.     }
  101. }