EsitoToken.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.token;

  21. import java.io.ByteArrayOutputStream;
  22. import java.io.PrintStream;

  23. import org.openspcoop2.message.OpenSPCoop2Message;


  24. /**
  25.  * Esito di un processo di gestione token.
  26.  *
  27.  * @author Andrea Poli (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public abstract class EsitoToken implements java.io.Serializable {

  32.    
  33.     /**
  34.      *
  35.      */
  36.     private static final long serialVersionUID = 1L;

  37.     private String token;
  38.    
  39.     /** Dettagli aggiuntivi */
  40.     private String details;
  41.        
  42.     private Exception eccezioneProcessamento;
  43.    
  44.     private boolean noCache = false;
  45.    
  46.     private OpenSPCoop2Message errorMessage;
  47.     private String wwwAuthenticateErrorHeader;
  48.    
  49.    
  50.     public String getWwwAuthenticateErrorHeader() {
  51.         return this.wwwAuthenticateErrorHeader;
  52.     }
  53.     public void setWwwAuthenticateErrorHeader(String wwwAuthenticateErrorHeader) {
  54.         this.wwwAuthenticateErrorHeader = wwwAuthenticateErrorHeader;
  55.     }
  56.     public OpenSPCoop2Message getErrorMessage() {
  57.         return this.errorMessage;
  58.     }
  59.     public void setErrorMessage(OpenSPCoop2Message errorMessage) {
  60.         this.errorMessage = errorMessage;
  61.     }
  62.     public String getToken() {
  63.         return this.token;
  64.     }
  65.     public void setToken(String token) {
  66.         this.token = token;
  67.     }
  68.    
  69.     public String getDetails() {
  70.         return this.details;
  71.     }
  72.     public void setDetails(String details) {
  73.         this.details = details;
  74.     }
  75.    
  76.     public Exception getEccezioneProcessamento() {
  77.         return this.eccezioneProcessamento;
  78.     }
  79.     public void setEccezioneProcessamento(Exception eccezioneProcessamento) {
  80.         this.eccezioneProcessamento = eccezioneProcessamento;
  81.         this.noCache = true; // per default quando si imposta una eccezione di processamento il risultato non sarĂ  salvato. Se si vuole cacharlo richiamare il metodo setNoCache(false);
  82.     }
  83.    
  84.     public boolean isNoCache() {
  85.         return this.noCache;
  86.     }

  87.     public void setNoCache(boolean noCache) {
  88.         this.noCache = noCache;
  89.     }
  90.    
  91.    
  92.     @Override
  93.     public String toString(){
  94.         StringBuilder bf = new StringBuilder();
  95.        
  96.         if(this.details!=null){
  97.             bf.append(" ");
  98.             bf.append("details["+this.details+"]");
  99.         }
  100.        
  101.         if(this.eccezioneProcessamento!=null){
  102.             bf.append(" ");
  103.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  104.             PrintStream ps = new PrintStream(bout);
  105.             try{
  106.                 this.eccezioneProcessamento.printStackTrace(ps);
  107.             }finally{
  108.                 try{
  109.                     ps.flush();
  110.                     ps.close();
  111.                     bout.flush();
  112.                     bout.close();
  113.                 }catch(Exception eClose){
  114.                     // close
  115.                 }
  116.             }
  117.             bf.append("stackTraceEccezioneProcessamento: \n"+bout.toString());
  118.         }
  119.         return bf.toString();
  120.     }
  121. }