AbstractEsitoValidazioneToken.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 org.openspcoop2.protocol.sdk.constants.IntegrationFunctionError;

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

  30.    
  31.     /**
  32.      *
  33.      */
  34.     private static final long serialVersionUID = 1L;

  35.     private boolean valido;
  36.     private IntegrationFunctionError integrationFunctionError;
  37.    
  38.     private boolean dateValide;
  39.    
  40.     private boolean inCache;

  41.     public boolean isValido() {
  42.         return this.valido;
  43.     }
  44.     public IntegrationFunctionError getIntegrationFunctionError() {
  45.         return this.integrationFunctionError;
  46.     }
  47.     public void setTokenValido() {
  48.         this.valido = true;
  49.         this.integrationFunctionError = null;
  50.     }
  51.     public void setTokenInternalError() {
  52.         this.valido = false;
  53.         this.integrationFunctionError = IntegrationFunctionError.INTERNAL_REQUEST_ERROR;
  54.     }
  55.     public void setTokenValidazioneFallita() {
  56.         this.valido = false;
  57.         this.integrationFunctionError = IntegrationFunctionError.TOKEN_INVALID;
  58.     }
  59.     public void setTokenScaduto() {
  60.         this.valido = false;
  61.         this.integrationFunctionError = IntegrationFunctionError.TOKEN_EXPIRED;
  62.     }
  63.     public void setTokenNotUsableBefore() {
  64.         this.valido = false;
  65.         this.integrationFunctionError = IntegrationFunctionError.TOKEN_NOT_USABLE_BEFORE;
  66.     }
  67.     public void setTokenInTheFuture() {
  68.         this.valido = false;
  69.         this.integrationFunctionError = IntegrationFunctionError.TOKEN_IN_THE_FUTURE;
  70.     }
  71.    
  72.     public boolean isInCache() {
  73.         return this.inCache;
  74.     }
  75.     public void setInCache(boolean inCache) {
  76.         this.inCache = inCache;
  77.     }
  78.    
  79.     public boolean isDateValide() {
  80.         return this.dateValide;
  81.     }
  82.     public void setDateValide(boolean dateValide) {
  83.         this.dateValide = dateValide;
  84.     }
  85.    
  86.     @Override
  87.     public String toString(){
  88.         StringBuilder bf = new StringBuilder();
  89.        
  90.         bf.append("token valido: ");
  91.         bf.append(this.valido);
  92.        
  93.         bf.append(" date valide: ");
  94.         bf.append(this.dateValide);
  95.        
  96.         bf.append(" info in cache: ");
  97.         bf.append(this.inCache);
  98.        
  99.         bf.append(super.toString());
  100.        
  101.         return bf.toString();
  102.     }
  103. }