ConnettoreEchoApiHelper.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 java.util.Map;

  22. import org.openspcoop2.core.config.rs.server.model.ConnettoreEcho;
  23. import org.openspcoop2.core.config.rs.server.model.ConnettoreEnum;
  24. import org.openspcoop2.core.config.rs.server.model.OneOfApplicativoServerConnettore;
  25. import org.openspcoop2.core.config.rs.server.model.OneOfConnettoreErogazioneConnettore;
  26. import org.openspcoop2.core.config.rs.server.model.OneOfConnettoreFruizioneConnettore;
  27. import org.openspcoop2.core.constants.CostantiDB;
  28. import org.openspcoop2.core.constants.TipiConnettore;
  29. import org.openspcoop2.core.registry.Connettore;
  30. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  31. import org.openspcoop2.web.lib.mvc.ServletUtils;

  32. /**
  33.  * ConnettoreEchoApiHelper
  34.  *
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  *
  38.  */
  39. public class ConnettoreEchoApiHelper extends AbstractConnettoreApiHelper<ConnettoreEcho> {

  40.     @Override
  41.     public boolean connettoreCheckData(ConnettoreEcho conn, ErogazioniEnv env, boolean erogazione) throws Exception {
  42.         return true;
  43.     }

  44.     @Override
  45.     public Connettore fillConnettoreRegistro(org.openspcoop2.core.registry.Connettore regConnettore,
  46.             ErogazioniEnv env,
  47.             ConnettoreEcho conn,
  48.             String oldConnT) throws Exception {
  49.         env.apsHelper.fillConnettore(
  50.                 regConnettore,
  51.                 conn.isDebug() != null && conn.isDebug() ? "true" : "false",                // this.connettoreDebug,
  52.                 TipiConnettore.NULLECHO.getNome(),          // endpointtype
  53.                 oldConnT,                       // oldConnT
  54.                 "",                     // tipoConn Personalizzato
  55.                 null, // this.url,
  56.                 null,   // this.nome,
  57.                 null,   // this.tipo,
  58.                 null,
  59.                 null,
  60.                 null,   // this.initcont,
  61.                 null,   // this.urlpgk,
  62.                 null, // this.url,
  63.                 null,   // this.connfact,
  64.                 null,   // this.sendas,
  65.                 null, // this.httpsurl,
  66.                 null,               // this.httpstipologia
  67.                 false,  // this.httpshostverify,
  68.                 ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS, // httpsTrustVerifyCert
  69.                 null,               // this.httpspath
  70.                 null,   // this.httpstipo,
  71.                 null,           // this.httpspwd,
  72.                 null,                   // this.httpsalgoritmo
  73.                 false,
  74.                 null,           // this.httpskeystore,
  75.                 "",                                                                 //  this.httpspwdprivatekeytrust
  76.                 null,               // pathkey
  77.                 null,       // this.httpstipokey
  78.                 null,           // this.httpspwdkey
  79.                 null,               // this.httpspwdprivatekey,  
  80.                 null,               // this.httpsalgoritmokey,
  81.                 null,                   // httpsKeyAlias
  82.                 null,                   // httpsTrustStoreCRLs
  83.                 null,                   // httpsTrustStoreOCSPPolicy
  84.                 null,                   // httpsKeyStoreBYOKPolicy
  85.            
  86.                 ServletUtils.boolToCheckBoxStatus( false ),
  87.                 null,
  88.                 null,
  89.                 null,
  90.                 null,
  91.                
  92.                 ServletUtils.boolToCheckBoxStatus( false ),
  93.                 null,   // this.tempiRisposta_connectionTimeout,
  94.                 null, //null,   // this.tempiRisposta_readTimeout,
  95.                 null,   // this.tempiRisposta_tempoMedioRisposta,
  96.                 "no",   // this.opzioniAvanzate,
  97.                 "",     // this.transfer_mode,
  98.                 "",     // this.transfer_mode_chunk_size,
  99.                 "",     // this.redirect_mode,
  100.                 "",     // this.redirect_max_hop,
  101.                 null,   // this.requestOutputFileName,
  102.                 null,   // this.requestOutputFileName_permissions
  103.                 null,   // this.requestOutputFileNameHeaders,
  104.                 null,   // this.requestOutputFileNameHeaders_permissions
  105.                 null,   // this.requestOutputParentDirCreateIfNotExists,
  106.                 null,   // this.requestOutputOverwriteIfExists,
  107.                 null,   // this.responseInputMode,
  108.                 null,   // this.responseInputFileName,
  109.                 null,   // this.responseInputFileNameHeaders,
  110.                 null,   // this.responseInputDeleteAfterRead,
  111.                 null,   // this.responseInputWaitTime,
  112.                 null,   // tokenPolicy
  113.                 null, null, // apiKeyHeader,  apiKeyValue
  114.                 null, null, // appIdHeader, appIdValue
  115.                 null, // connettoreStatusParams
  116.                 null // listExtendedConnettore
  117.                 );
  118.        
  119.         return regConnettore;
  120.     }

  121.     @Override
  122.     public org.openspcoop2.core.config.Connettore buildConnettoreConfigurazione(
  123.             org.openspcoop2.core.config.Connettore regConnettore, ErogazioniEnv env, ConnettoreEcho conn,
  124.             String oldConnType) throws Exception {

  125.         env.apsHelper.fillConnettore(
  126.                 regConnettore,
  127.                 conn.isDebug() != null && conn.isDebug() ? "true" : "false",                // this.connettoreDebug,
  128.                 TipiConnettore.NULLECHO.getNome(),          // endpointtype
  129.                 oldConnType,                        // oldConnT
  130.                 "",                     // tipoConn Personalizzato
  131.                 null, // this.url,
  132.                 null,   // this.nome,
  133.                 null,   // this.tipo,
  134.                 null,
  135.                 null,
  136.                 null,   // this.initcont,
  137.                 null,   // this.urlpgk,
  138.                 null, // this.url,
  139.                 null,   // this.connfact,
  140.                 null,   // this.sendas,
  141.                 null, // this.httpsurl,
  142.                 null,               // this.httpstipologia
  143.                 false,  // this.httpshostverify,
  144.                 ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS, // httpsTrustVerifyCert
  145.                 null,               // this.httpspath
  146.                 null,   // this.httpstipo,
  147.                 null,           // this.httpspwd,
  148.                 null,                   // this.httpsalgoritmo
  149.                 false,
  150.                 null,           // this.httpskeystore,
  151.                 "",                                                                 //  this.httpspwdprivatekeytrust
  152.                 null,               // pathkey
  153.                 null,       // this.httpstipokey
  154.                 null,           // this.httpspwdkey
  155.                 null,               // this.httpspwdprivatekey,  
  156.                 null,               // this.httpsalgoritmokey,
  157.                 null,                   // httpsKeyAlias
  158.                 null,                   // httpsTrustStoreCRLs
  159.                 null,                   // httpsTrustStoreOCSPPolicy
  160.                 null,                   // httpsKeyStoreBYOKPolicy
  161.            
  162.                 ServletUtils.boolToCheckBoxStatus( false ),
  163.                 null,
  164.                 null,
  165.                 null,
  166.                 null,
  167.                
  168.                 ServletUtils.boolToCheckBoxStatus( false ),
  169.                 null,   // this.tempiRisposta_connectionTimeout,
  170.                 null, //null,   // this.tempiRisposta_readTimeout,
  171.                 null,   // this.tempiRisposta_tempoMedioRisposta,
  172.                 "no",   // this.opzioniAvanzate,
  173.                 "",     // this.transfer_mode,
  174.                 "",     // this.transfer_mode_chunk_size,
  175.                 "",     // this.redirect_mode,
  176.                 "",     // this.redirect_max_hop,
  177.                 null,   // this.requestOutputFileName,
  178.                 null,   // this.requestOutputFileName_permissions
  179.                 null,   // this.requestOutputFileNameHeaders,
  180.                 null,   // this.requestOutputFileNameHeaders_permissions
  181.                 null,   // this.requestOutputParentDirCreateIfNotExists,
  182.                 null,   // this.requestOutputOverwriteIfExists,
  183.                 null,   // this.responseInputMode,
  184.                 null,   // this.responseInputFileName,
  185.                 null,   // this.responseInputFileNameHeaders,
  186.                 null,   // this.responseInputDeleteAfterRead,
  187.                 null,   // this.responseInputWaitTime,
  188.                 null,   // tokenPolicy
  189.                 null, null, // apiKeyHeader,  apiKeyValue
  190.                 null, null, // appIdHeader, appIdValue
  191.                 null, // connettoreStatusParams
  192.                 null // listExtendedConnettore
  193.                 );      
  194.         return regConnettore;
  195.     }

  196.     @Override
  197.     public ConnettoreEcho buildConnettore(Map<String, String> props, String tipo) {
  198.         ConnettoreEcho c = new ConnettoreEcho();
  199.        
  200.         c.setTipo(ConnettoreEnum.ECHO);
  201.         c.setDebug(Boolean.parseBoolean(props.get(CostantiDB.CONNETTORE_DEBUG)));
  202.        
  203.         return c;
  204.     }

  205.     @Override
  206.     public String getUrlConnettore(Map<String, String> props, String tipoConnettore) throws Exception {
  207.         return "[echo] govway://echo";
  208.     }

  209.     @Override
  210.     protected ConnettoreEcho getConnettore(OneOfConnettoreErogazioneConnettore conn) throws Exception {
  211.         return (ConnettoreEcho) conn;
  212.     }

  213.     @Override
  214.     protected ConnettoreEcho getConnettore(OneOfConnettoreFruizioneConnettore conn) throws Exception {
  215.         return (ConnettoreEcho) conn;
  216.     }

  217.     @Override
  218.     protected ConnettoreEcho getConnettore(OneOfApplicativoServerConnettore conn) throws Exception {
  219.         return (ConnettoreEcho) conn;
  220.     }

  221. }