NegoziazioneTokenDynamicParametersModIUtils.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.lang.reflect.Method;

  22. import org.openspcoop2.protocol.sdk.ProtocolException;
  23. import org.openspcoop2.protocol.utils.ModIUtils;

  24. /**
  25.  * NegoziazioneTokenDynamicParametersModIUtils
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class NegoziazioneTokenDynamicParametersModIUtils {
  32.    
  33.     private NegoziazioneTokenDynamicParametersModIUtils() {}

  34.     private static Object modIProperties = null;
  35.     private static synchronized void initModiProperties() throws ProtocolException {
  36.         if(modIProperties==null) {
  37.             try {
  38.                 modIProperties = ModIUtils.getModiProperties();
  39.             }catch(Exception e) {
  40.                 throw new ProtocolException(e.getMessage(),e);
  41.             }
  42.         }
  43.     }
  44.     private static Object getModiProperties() throws ProtocolException {
  45.         if(modIProperties==null) {
  46.             initModiProperties();
  47.         }
  48.         return modIProperties;
  49.     }
  50.     public static String getSicurezzaMessaggioCertificatiKeyStoreTipo() throws ProtocolException {
  51.         try {
  52.             Object instance = getModiProperties();
  53.             Method m = instance.getClass().getMethod("getSicurezzaMessaggioCertificatiKeyStoreTipo");
  54.             return (String) m.invoke(instance);
  55.         }catch(Exception e) {
  56.             throw new ProtocolException(e.getMessage(),e);
  57.         }
  58.     }
  59.     public static String getSicurezzaMessaggioCertificatiKeyStorePath() throws ProtocolException {
  60.         try {
  61.             if(getSicurezzaMessaggioCertificatiKeyStoreTipo()!=null) {
  62.                 Object instance = getModiProperties();
  63.                 Method m = instance.getClass().getMethod("getSicurezzaMessaggioCertificatiKeyStorePath");
  64.                 return (String) m.invoke(instance);
  65.             }
  66.             return null;
  67.         }catch(Exception e) {
  68.             throw new ProtocolException(e.getMessage(),e);
  69.         }
  70.     }
  71.     public static String getSicurezzaMessaggioCertificatiKeyStorePassword() throws ProtocolException {
  72.         try {
  73.             if(getSicurezzaMessaggioCertificatiKeyStoreTipo()!=null) {
  74.                 Object instance = getModiProperties();
  75.                 Method m = instance.getClass().getMethod("getSicurezzaMessaggioCertificatiKeyStorePassword");
  76.                 return (String) m.invoke(instance);
  77.             }
  78.             return null;
  79.         }catch(Exception e) {
  80.             throw new ProtocolException(e.getMessage(),e);
  81.         }
  82.     }
  83.     public static String getSicurezzaMessaggioCertificatiKeyAlias() throws ProtocolException {
  84.         try {
  85.             if(getSicurezzaMessaggioCertificatiKeyStoreTipo()!=null) {
  86.                 Object instance = getModiProperties();
  87.                 Method m = instance.getClass().getMethod("getSicurezzaMessaggioCertificatiKeyAlias");
  88.                 return (String) m.invoke(instance);
  89.             }
  90.             return null;
  91.         }catch(Exception e) {
  92.             throw new ProtocolException(e.getMessage(),e);
  93.         }
  94.     }
  95.     public static String getSicurezzaMessaggioCertificatiKeyPassword() throws ProtocolException {
  96.         try {
  97.             if(getSicurezzaMessaggioCertificatiKeyStoreTipo()!=null) {
  98.                 Object instance = getModiProperties();
  99.                 Method m = instance.getClass().getMethod("getSicurezzaMessaggioCertificatiKeyPassword");
  100.                 return (String) m.invoke(instance);
  101.             }
  102.             return null;
  103.         }catch(Exception e) {
  104.             throw new ProtocolException(e.getMessage(),e);
  105.         }
  106.     }
  107.    
  108. }