ParametriAutenticazionePrincipal.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.autenticazione;

  21. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  22. import org.openspcoop2.core.transazioni.utils.TipoCredenzialeMittente;
  23. import org.openspcoop2.utils.BooleanNullable;

  24. /**
  25.  * ParametriAutenticazionePrincipal
  26.  *
  27.  * @author Andrea Poli (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class ParametriAutenticazionePrincipal extends ParametriAutenticazione implements java.io.Serializable {

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

  37.     public static final String TIPO_AUTENTICAZIONE = "tipoAutenticazione";
  38.     public static final String NOME = "nome";
  39.     public static final String PATTERN = "pattern";
  40.    
  41.     public static final String CLEAN_PRINCIPAL = "cleanPrincipal";
  42.     public static final String CLEAN_PRINCIPAL_TRUE = "true";
  43.     public static final String CLEAN_PRINCIPAL_FALSE = "false";
  44.    
  45.     public static final String TOKEN_CLAIM = "claim";
  46.     public static final String TOKEN_CLAIM_ISSUER = "issuer";
  47.     public static final String TOKEN_CLAIM_SUBJECT = "subject";
  48.     public static final String TOKEN_CLAIM_CLIENT_ID = "clientId";
  49.     public static final String TOKEN_CLAIM_USERNAME = "username";
  50.     public static final String TOKEN_CLAIM_EMAIL = "eMail";
  51.     public static final String TOKEN_CLAIM_CUSTOM = "custom";
  52.    
  53.     public ParametriAutenticazionePrincipal(ParametriAutenticazione parametri) {
  54.         super(parametri);
  55.     }
  56.    
  57.     public TipoAutenticazionePrincipal getTipoAutenticazione() {
  58.         String valore = this.get(TIPO_AUTENTICAZIONE);
  59.         if(valore==null || "".equals(valore)) {
  60.             return null;
  61.         }
  62.         return TipoAutenticazionePrincipal.toEnumConstant(valore);
  63.     }
  64.    
  65.     public String getNome() {
  66.         String valore = this.get(NOME);
  67.         if(valore==null || "".equals(valore)) {
  68.             return null;
  69.         }
  70.         return valore;
  71.     }
  72.    
  73.     public String getPattern() {
  74.         String valore = this.get(PATTERN);
  75.         if(valore==null || "".equals(valore)) {
  76.             return null;
  77.         }
  78.         return valore;
  79.     }
  80.    
  81.     public BooleanNullable getCleanPrincipal() {
  82.         String valore = this.get(CLEAN_PRINCIPAL);
  83.         if(valore==null || "".equals(valore)) {
  84.             return BooleanNullable.NULL();
  85.         }
  86.         if(CLEAN_PRINCIPAL_FALSE.equalsIgnoreCase(valore)) {
  87.             return BooleanNullable.FALSE();
  88.         }
  89.         else if(CLEAN_PRINCIPAL_TRUE.equalsIgnoreCase(valore)) {
  90.             return BooleanNullable.TRUE();
  91.         }
  92.         return BooleanNullable.NULL();
  93.     }
  94.    
  95.     public TipoCredenzialeMittente getTokenClaim() {
  96.         String valore = this.get(TOKEN_CLAIM);
  97.         if(valore==null || "".equals(valore)) {
  98.             return null;
  99.         }
  100.         if(TOKEN_CLAIM_ISSUER.equalsIgnoreCase(valore)) {
  101.             return TipoCredenzialeMittente.TOKEN_ISSUER;
  102.         }
  103.         else if(TOKEN_CLAIM_SUBJECT.equalsIgnoreCase(valore)) {
  104.             return TipoCredenzialeMittente.TOKEN_SUBJECT;
  105.         }
  106.         else if(TOKEN_CLAIM_CLIENT_ID.equalsIgnoreCase(valore)) {
  107.             return TipoCredenzialeMittente.TOKEN_CLIENT_ID;
  108.         }
  109.         else if(TOKEN_CLAIM_USERNAME.equalsIgnoreCase(valore)) {
  110.             return TipoCredenzialeMittente.TOKEN_USERNAME;
  111.         }
  112.         else if(TOKEN_CLAIM_EMAIL.equalsIgnoreCase(valore)) {
  113.             return TipoCredenzialeMittente.TOKEN_EMAIL;
  114.         }
  115.         else if(TOKEN_CLAIM_CUSTOM.equalsIgnoreCase(valore)) {
  116.             return TipoCredenzialeMittente.TRASPORTO; // uso trasporto come custom
  117.         }
  118.         return null;
  119.     }
  120. }