AutorizzazioneContenutoOK.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.core.autorizzazione.pd;


  21. import java.io.ByteArrayOutputStream;

  22. import org.openspcoop2.message.OpenSPCoop2Message;
  23. import org.openspcoop2.pdd.core.autorizzazione.AutorizzazioneException;
  24. import org.openspcoop2.pdd.logger.OpenSPCoop2Logger;

  25. /**
  26.  * Esempio di AutorizzazioneContenutoOK
  27.  *
  28.  * @author Andrea Poli (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */

  32. public class AutorizzazioneContenutoOK extends AbstractAutorizzazioneContenutoBase {

  33.     @Override
  34.     public EsitoAutorizzazionePortaDelegata process(DatiInvocazionePortaDelegata datiInvocazione,OpenSPCoop2Message msg) throws AutorizzazioneException {

  35.         EsitoAutorizzazionePortaDelegata esito = new EsitoAutorizzazionePortaDelegata();
  36.        
  37.         // Autorizzazzione servizio applicativo
  38.         try{
  39.            
  40.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  41.             msg.writeTo(bout, false);
  42.             bout.flush();
  43.             bout.close();
  44.            
  45.             System.out.println("(TestOK) Messaggio ricevuto: "+bout.toString());
  46.            
  47.             esito.setAutorizzato(true);
  48.             return esito;
  49.            
  50.         }catch(Exception e){
  51.             esito.setEccezioneProcessamento(e);
  52.             OpenSPCoop2Logger.getLoggerOpenSPCoopCore().error("Autorizzazione per contenuto non riuscita",e);
  53.             throw new AutorizzazioneException("Errore di processamento durante l'autorizzazione per contenuto: "+e.getMessage(),e);
  54.         }
  55.    

  56.     }

  57. }