First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package mnp.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP Project</p>
|
||||
* <p>Description: Progetto per Mobile Number Portability
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: OW</p>
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CriticalException extends Exception {
|
||||
|
||||
public CriticalException() {
|
||||
}
|
||||
public String getMessage() {
|
||||
/**@todo Override this java.lang.Throwable method*/
|
||||
return "Errore critico: prego rispedire il file";
|
||||
}
|
||||
|
||||
}
|
||||
17
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/log/LoggableFE.java
Normal file
17
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/log/LoggableFE.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package mnp.log;
|
||||
|
||||
import mnp.objects.*;
|
||||
import java.lang.*;
|
||||
|
||||
/**
|
||||
* Title: LoggableFE
|
||||
* Description: Interfaccia per la definizione dei log
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: Siemens
|
||||
* @author Ambra Parati
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface LoggableFE {
|
||||
public LogInfoFE getLogInfo() throws Exception;
|
||||
}
|
||||
201
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/log/ProcessLoggerFE.java
Normal file
201
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/log/ProcessLoggerFE.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package mnp.log;
|
||||
|
||||
import mnp.xml.*;
|
||||
import java.text.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import mnp.objects.*;
|
||||
import mnp.utility.*;
|
||||
import org.exolab.castor.xml.*;
|
||||
import xml.*;
|
||||
import xml.types.*;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Title: ProcessLoggerFE</p>
|
||||
* <p>Description: Classe per la gestione del log applicativo sul Front End</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Ambra Parati
|
||||
* @version 1.0
|
||||
* @version 2.0 C09_2017 RU_517 line 55 (Unreleased Resource: Streams)
|
||||
*/
|
||||
public class ProcessLoggerFE {
|
||||
// Formato della data nel nome del file di log
|
||||
private SimpleDateFormat sdfNomeLog = new SimpleDateFormat("yyyyMMdd");
|
||||
// Formato della data nel messaggio di log
|
||||
private SimpleDateFormat sdfMsg = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
// Codice del processo che scrive il log
|
||||
private String codiceProcesso;
|
||||
// Elenco di tutti i messaggi corrispondenti al processo
|
||||
private Hashtable messaggiProcesso = new Hashtable();
|
||||
// Informazioni sul log e sul processo
|
||||
private LogInfoFE _logInfo;
|
||||
// Path completo del file di log
|
||||
private String pathName;
|
||||
// Nome del processo
|
||||
private String processo;
|
||||
|
||||
|
||||
/**
|
||||
* Costruttore: inizializza le variabili di classe ed estre dal file XML tutti
|
||||
* i messaggi relativi al processo
|
||||
* @param logProcess Informazioni sul processo
|
||||
* @throws Exception
|
||||
*/
|
||||
public ProcessLoggerFE(LogProcessFE logProcess) throws Exception{
|
||||
_logInfo = logProcess.getProcess().getLogInfo();
|
||||
processo = _logInfo.getProcess();
|
||||
codiceProcesso = logProcess.getCodice();
|
||||
|
||||
// Ricava dal file di properties il path completo del file XMl contenente le informazioni sui log
|
||||
String nomeFile = Resources.getPathFileXMLLOG();
|
||||
|
||||
// C09_2017 RU_517 BEGIN
|
||||
FileReader frd = null;
|
||||
try {
|
||||
frd = new FileReader(nomeFile);
|
||||
// C09_2017 RU_517 END
|
||||
|
||||
MyListaLogProcessiFE listaProc = new MyListaLogProcessiFE();
|
||||
|
||||
|
||||
//listaProc = (MyListaLogProcessiFE)listaProc.unmarshal(frd);
|
||||
listaProc = (MyListaLogProcessiFE)Unmarshaller.unmarshal(MyListaLogProcessiFE.class, frd);
|
||||
|
||||
//Se il codice del processo è nullo lo ricavo dal file XML tramite il suo nome
|
||||
if(codiceProcesso==null)
|
||||
codiceProcesso = listaProc.getCODICE_PROCESSO(processo);
|
||||
|
||||
//Ricava dal file XML tutti i messaggi di log pper il processo identificato da codiceProcesso
|
||||
ANAGRAFICA_LOG_FE[] anagLogSeq = listaProc.getANAGRAFICA_LOG_FE(codiceProcesso);
|
||||
|
||||
//Inserisce tutte i messaggi nella Hashtable messaggiProcesso
|
||||
createMessaggiProcesso(anagLogSeq);
|
||||
}
|
||||
catch(IOException ex){
|
||||
System.out.println("Errore in lettura del file XML contenente i LOG");
|
||||
throw ex;
|
||||
}catch (ValidationException ex) {
|
||||
System.out.println("Errore di validazione");
|
||||
throw ex;
|
||||
}catch (MarshalException ex) {
|
||||
System.out.println("Errore marshall");
|
||||
throw ex;
|
||||
}
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Closing when previously closed will have no effect;
|
||||
finally {
|
||||
if(null != frd) {
|
||||
try {
|
||||
frd.close();
|
||||
} catch (Exception e) {
|
||||
frd = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruisce l'Hashtable messaggiProcesso
|
||||
* @param anagLogSeq Elenco dei log per il processo
|
||||
*/
|
||||
private void createMessaggiProcesso(ANAGRAFICA_LOG_FE[] anagLogSeq){
|
||||
// La chiave della Hashtable è la stringa corrispondente all'inter
|
||||
for (int i = 0; i < anagLogSeq.length; i++) {
|
||||
messaggiProcesso.put(anagLogSeq[i].getCODICE_LOG(), anagLogSeq[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrive una riga su file di log per la nuova modalità di logging per Governance
|
||||
* @param codiceLog Codice del messaggio da scrivere
|
||||
* @param msgVariabile Parte variabile del messaggio da scrivere
|
||||
*/
|
||||
public void write(String codiceLog, String msgVariabile){
|
||||
ANAGRAFICA_LOG_FE anagLog = (ANAGRAFICA_LOG_FE)(messaggiProcesso.get(codiceLog));
|
||||
String lineaLog = null;
|
||||
try {
|
||||
lineaLog = makeLine(anagLog, codiceLog, msgVariabile);
|
||||
if(lineaLog!=null)
|
||||
writeLine(lineaLog);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruisce la linea da scrivere sul log
|
||||
* @param anagLog Informazioni sul log
|
||||
* @param codiceLog Codice del messaggio di log
|
||||
* @param msgVariabile Parte variabile del messaggio
|
||||
* @return String - Linea da scrivere
|
||||
*/
|
||||
private String makeLine(ANAGRAFICA_LOG_FE anagLog, String codiceLog, String msgVariabile){
|
||||
String lineaLog = null;
|
||||
try {
|
||||
if(anagLog==null){
|
||||
anagLog = new ANAGRAFICA_LOG_FE();
|
||||
anagLog.setCODICE_LOG("0000");
|
||||
anagLog.setDESCRIZIONE("DATI SUL FILE XML NON SUFFICIENTI PER LA SCRITTURA DEL LOG");
|
||||
anagLog.setSEVERITA(SEVERITAType.C);
|
||||
anagLog.setLOG_ON(1);
|
||||
msgVariabile = msgVariabile + " (codice inserito:" + codiceLog + ")";
|
||||
}
|
||||
if(anagLog.getLOG_ON()==1){
|
||||
Date data = new Date();
|
||||
String codice = "FNP" + codiceProcesso + anagLog.getCODICE_LOG() + " ";
|
||||
String severita = anagLog.getSEVERITA() + " ";
|
||||
String nomeProcesso = processo + " ";
|
||||
String timestamp = sdfMsg.format(data) + " ";
|
||||
String descrizione = anagLog.getDESCRIZIONE() + "";
|
||||
|
||||
lineaLog = codice + severita + nomeProcesso + timestamp + descrizione;
|
||||
if (msgVariabile==null)
|
||||
msgVariabile="";
|
||||
|
||||
if (!msgVariabile.equalsIgnoreCase(""))
|
||||
lineaLog = lineaLog + "__" + msgVariabile + "\r\n";
|
||||
else
|
||||
lineaLog = lineaLog + "\r\n";
|
||||
}
|
||||
return lineaLog;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return lineaLog;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrive la line sul file
|
||||
* @param line Linea da scrivere
|
||||
*/
|
||||
private void writeLine(String line){
|
||||
// File su cui viene scritto il log
|
||||
RandomAccessFile log=null;
|
||||
try {
|
||||
Date data = new Date();
|
||||
pathName = _logInfo.getLogPath() + processo + sdfNomeLog.format(data) + ".log";
|
||||
log = new RandomAccessFile(pathName, "rw");
|
||||
log.seek(log.length());
|
||||
byte[] buffer = line.getBytes();
|
||||
log.write(buffer,0,line.length());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
try {
|
||||
if(log!=null)
|
||||
log.close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
214
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/manager/ReinvioManager.java
Normal file
214
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/manager/ReinvioManager.java
Normal file
@@ -0,0 +1,214 @@
|
||||
package mnp.manager;
|
||||
|
||||
import java.sql.*;
|
||||
import javax.sql.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import javax.naming.*;
|
||||
import java.net.*;
|
||||
import mnp.utility.*;
|
||||
import mnp.objects.*;
|
||||
import mnp.exception.*;
|
||||
import mnp.servlets.XMLSender;
|
||||
//Stefano[20-08-03]: nuovi log per Governance Front End
|
||||
import mnp.log.*;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: Reinvia ad intervallo di tempo specificato da crontab tutti quei file che
|
||||
* precedentemente non sono stati inviati agli AOM</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author: Francesca
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ReinvioManager implements LoggableFE{
|
||||
private static String PATH_LOCALE;
|
||||
private static String PATH_DEST;
|
||||
private ProcessLoggerFE log;
|
||||
protected String versione = "1.5.0.0";
|
||||
protected String codiceProcesso = "OA";
|
||||
private static boolean httpsFlag;
|
||||
private static boolean sslFlag;
|
||||
private static boolean proxyFlag;
|
||||
|
||||
public ReinvioManager() throws Exception {
|
||||
|
||||
try{
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch(Exception ex){
|
||||
System.out.println("Errore nella creazione del ProcessLogger");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
PATH_DEST = Resources.getInternalReceiverURL();
|
||||
PATH_LOCALE = Resources.getPathFileRinvio();
|
||||
httpsFlag =Resources.getInternalHttpsFlag();
|
||||
sslFlag =Resources.getInternalSslFlag();
|
||||
proxyFlag =Resources.getInternalProxyFlag();
|
||||
log.write("0001"," versione " + versione);
|
||||
|
||||
if(PATH_DEST==null || PATH_LOCALE==null) {
|
||||
throw new Exception("Impossibile caricare risorse da file di properties; risorse PATH_DEST o PATH_LOCALE mancanti");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prende i files non inviati dal FE al BE ordinandoli per data e passandoli
|
||||
* al metodo rinvio per la spedizione
|
||||
* @throws Exception
|
||||
*/
|
||||
public void reinvioFileXml() throws Exception{
|
||||
RandomAccessFile file = null;
|
||||
File f = null;
|
||||
File[] fileList = null;
|
||||
String dest = null;
|
||||
String tipo_file = null;
|
||||
String nome_file = null;
|
||||
String fileType = "";
|
||||
String fileXML = "";
|
||||
String ret = "";
|
||||
|
||||
TreeSet files = getFileNames(PATH_LOCALE);
|
||||
Iterator iter = files.iterator();
|
||||
String pathWarning = Resources.getPathFileRinvioWarning();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
FileInfo fileinfo = (FileInfo)iter.next();
|
||||
try {
|
||||
// Ottieni il contenuto del file
|
||||
fileXML = fileinfo.getFilexml();
|
||||
// Ottieni il nome del file
|
||||
nome_file = fileinfo.getFilename();
|
||||
// Ottieni il tipo_file
|
||||
fileType = fileXML.substring(
|
||||
fileXML.indexOf(">", fileXML.indexOf("<TIPO_MESSAGGIO>")) + 1,
|
||||
fileXML.indexOf("</TIPO_MESSAGGIO>"));
|
||||
ret = "";
|
||||
|
||||
String str = PATH_LOCALE + nome_file +".xml";
|
||||
File file1 = new File(str);
|
||||
|
||||
//KS12 2012 - controllo esistenza del file prima di inviarlo.
|
||||
//Risolve problema del invio contemporaneo
|
||||
if (file1.exists()) {
|
||||
// Tento l'invio a DBC BE
|
||||
try {
|
||||
XMLSender.sendXML(fileXML, fileType, nome_file, PATH_DEST, httpsFlag, sslFlag, proxyFlag, log);
|
||||
|
||||
// Se l'invio è andato a buon fine, cancello il file dalla directory di rinvio
|
||||
file1.delete();
|
||||
// N - INVIATO FILE XML
|
||||
log.write("0070"," " + nome_file + "_" + fileType + "_" + dest);
|
||||
}
|
||||
catch (CriticalException ex) {
|
||||
// Se becco una eccezione critica sposto il file nella dir di attenzione
|
||||
File moved = new File(pathWarning + nome_file + ".xml");
|
||||
Functions.copyFile(file1, moved);
|
||||
file1.delete();
|
||||
// C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Se becco una eccezione "normale", pazienza, ritenterò l'invio solo se il file è di tipo 1(Attivazione)
|
||||
// Se il file è di tipo diverso esco perchè potrei compromettere la sequenza temporale dei files.
|
||||
// C - ERRORE IN INVIO FILE XML
|
||||
log.write("0071"," " + nome_file + "_" + fileType + "_" + dest);
|
||||
if (!fileType.equalsIgnoreCase("1"))
|
||||
throw new Exception("Impossibile spedire il file \nDescrizione="+fileXML+"\n"+nome_file+"\n"+fileType);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae i file dal path specificato in input
|
||||
* @param PATH_LOCALE
|
||||
* @return TreeSet
|
||||
* @throws Exception
|
||||
*/
|
||||
public TreeSet getFileNames(String PATH_LOCALE) throws Exception {
|
||||
ObjectInputStream input = null;
|
||||
FileInputStream fInput = null;
|
||||
File dir = new File(PATH_LOCALE);
|
||||
TreeSet files = new TreeSet();
|
||||
|
||||
String[] aFiles = dir.list();
|
||||
if( aFiles == null )
|
||||
return files;
|
||||
|
||||
FileInfo fileinfo= new FileInfo();
|
||||
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Corretto per aprire e chiudere gli stream a ogni giro. Closing when previously closed will have no effect;
|
||||
// NOTA: invariato il comportamento precedente all-or-none, una eccezione fa uscire l'intero loop non solo saltare il giro
|
||||
for( int i = 0; i < aFiles.length; i++ ) {
|
||||
try{
|
||||
fInput = new FileInputStream(PATH_LOCALE + aFiles[i]);
|
||||
input = new ObjectInputStream(fInput);
|
||||
fileinfo = (FileInfo)input.readObject();
|
||||
files.add(fileinfo);
|
||||
}catch(Exception e){
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if(null != fInput) {
|
||||
try {
|
||||
fInput.close();
|
||||
fInput = null;
|
||||
} catch (Exception e) {
|
||||
fInput = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
if(null != input) {
|
||||
try {
|
||||
input.close();
|
||||
input = null;
|
||||
} catch (Exception e) {
|
||||
input = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
return files;
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method
|
||||
* */
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
ReinvioManager r = new ReinvioManager();
|
||||
r.reinvioFileXml();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("Attenzione: inizializzazione Task ReinvioManager fallita, reason: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
68
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/FileInfo.java
Normal file
68
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/FileInfo.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package mnp.objects;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author unascribed
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FileInfo implements Comparable, Serializable {
|
||||
|
||||
private String filexml;
|
||||
private String filename;
|
||||
private String tipofile;
|
||||
private Date data_ricezione;
|
||||
|
||||
|
||||
public FileInfo() {
|
||||
}
|
||||
public int compareTo(Object o) {
|
||||
|
||||
FileInfo f = (FileInfo)o;
|
||||
|
||||
int ris = 0;
|
||||
|
||||
if ( f.getData_ricezione().after(this.getData_ricezione()))
|
||||
ris= -1;
|
||||
else if ( f.getData_ricezione().before(this.getData_ricezione()))
|
||||
ris = 1;
|
||||
|
||||
return ris;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
public void setFilexml(String filexml) {
|
||||
this.filexml = filexml;
|
||||
}
|
||||
public String getFilexml() {
|
||||
return filexml;
|
||||
}
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
public void setTipofile(String tipofile) {
|
||||
this.tipofile = tipofile;
|
||||
}
|
||||
public String getTipofile() {
|
||||
return tipofile;
|
||||
}
|
||||
public void setData_ricezione(java.util.Date data_ricezione) {
|
||||
this.data_ricezione = data_ricezione;
|
||||
}
|
||||
public java.util.Date getData_ricezione() {
|
||||
return data_ricezione;
|
||||
}
|
||||
}
|
||||
53
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/LogInfoFE.java
Normal file
53
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/LogInfoFE.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package mnp.objects;
|
||||
|
||||
/**
|
||||
* Title: LogInfoFE
|
||||
* Description: Oggetto contenente le informazioni di log per processo
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: Siemens
|
||||
* @author A. Parati
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class LogInfoFE {
|
||||
|
||||
public LogInfoFE() {
|
||||
}
|
||||
// Processo a cui il log si riferisce
|
||||
private String process;
|
||||
// Path del log
|
||||
private String logPath;
|
||||
|
||||
public void setProcess(String newProcess) {
|
||||
process = eliminaAlberatura(newProcess);
|
||||
}
|
||||
public String getProcess() {
|
||||
return process;
|
||||
}
|
||||
public void setLogPath(String newLogPath) {
|
||||
logPath = newLogPath;
|
||||
}
|
||||
public String getLogPath() {
|
||||
return logPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toglie l'alberatura dal nome passato
|
||||
*/
|
||||
private String eliminaAlberatura(String newProcess){
|
||||
int numPunti = 0;
|
||||
for (int i = 0; i < newProcess.length(); i++) {
|
||||
if(newProcess.charAt(i)=='.')
|
||||
numPunti++;
|
||||
}
|
||||
for (int j = 0; j < numPunti; j++) {
|
||||
int k = 0;
|
||||
while (newProcess.charAt(0)!='.') {
|
||||
newProcess = newProcess.substring(1);
|
||||
k++;
|
||||
}
|
||||
newProcess = newProcess.substring(1);
|
||||
}
|
||||
return newProcess;
|
||||
}
|
||||
}
|
||||
39
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/LogProcessFE.java
Normal file
39
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/objects/LogProcessFE.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package mnp.objects;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p>Title: LogProcessFE</p>
|
||||
* <p>Description: Questo oggetto rappresenta un generico processo che scrive su
|
||||
* file di log</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Ambra Parati
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class LogProcessFE implements Serializable {
|
||||
|
||||
private mnp.log.LoggableFE process;
|
||||
private String codice;
|
||||
public LogProcessFE() {
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
public void setProcess(mnp.log.LoggableFE process) {
|
||||
this.process = process;
|
||||
}
|
||||
public mnp.log.LoggableFE getProcess() {
|
||||
return process;
|
||||
}
|
||||
public void setCodice(String codice) {
|
||||
this.codice = codice;
|
||||
}
|
||||
public String getCodice() {
|
||||
return codice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package mnp.securityLog;
|
||||
|
||||
public class ActionLogMapping {
|
||||
|
||||
// log Machine2Machine
|
||||
public static final int InvioFileXML = 1001;
|
||||
public static final int RicezioneFileXML = 1002;
|
||||
public static final int AbilitazioneGateway = 1003;
|
||||
|
||||
//log security
|
||||
public static final String LOG_CLIENT_APP_NAME = "MNP-GW";
|
||||
public static final String LOG_RESULT_CODE_OK = "OK";
|
||||
public static final String LOG_RESULT_CODE_KO = "KO";
|
||||
public static final int LOG_RESULT_CODE_DETAIL_OK = 0;
|
||||
public static final int LOG_RESULT_CODE_DETAIL_KO = -1;
|
||||
|
||||
private ActionLogMapping() {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mnp.service;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.ejb.EJBObject;
|
||||
|
||||
public interface GatewayManagerEJB extends EJBObject {
|
||||
public abstract TreeSet getFileReinviabili() throws RemoteException;
|
||||
public abstract TreeSet getFileNonReinviabili() throws RemoteException;
|
||||
public abstract void reinvioFile() throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package mnp.service;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.ejb.CreateException;
|
||||
import javax.ejb.EJBException;
|
||||
import javax.ejb.SessionBean;
|
||||
import javax.ejb.SessionContext;
|
||||
|
||||
import mnp.manager.ReinvioManager;
|
||||
import mnp.utility.Resources;
|
||||
|
||||
public class GatewayManagerEJBBean implements SessionBean {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ReinvioManager reinvioManager;
|
||||
private static String path_reinviabili;
|
||||
private static String path_non_reinviabili;
|
||||
SessionContext sessionContext;
|
||||
|
||||
//Recupera lista file reinviabili
|
||||
public TreeSet getFileReinviabili() throws RemoteException {
|
||||
TreeSet fileReinviabili = null;
|
||||
try {
|
||||
System.out.println("GatewayManagerEJBBean - esecuzione getFileReinviabili");
|
||||
fileReinviabili = reinvioManager.getFileNames(path_reinviabili);
|
||||
} catch (Exception e) {
|
||||
System.out.println("GatewayManagerEJBBean - eccezione nel recupero lista file reinviabili.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fileReinviabili;
|
||||
}
|
||||
|
||||
//Recupera lista file non reinviabili
|
||||
public TreeSet getFileNonReinviabili() throws RemoteException {
|
||||
TreeSet fileNonReinviabili = null;
|
||||
try {
|
||||
System.out.println("GatewayManagerEJBBean - esecuzione getFileNonReinviabili");
|
||||
fileNonReinviabili = reinvioManager.getFileNames(path_non_reinviabili);
|
||||
} catch (Exception e) {
|
||||
System.out.println("GatewayManagerEJBBean - eccezione nel recupero lista file non reinviabili.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fileNonReinviabili;
|
||||
}
|
||||
|
||||
public void reinvioFile() throws RemoteException {
|
||||
try {
|
||||
System.out.println("GatewayManagerEJBBean - esecuzione reinvio file");
|
||||
reinvioManager.reinvioFileXml();
|
||||
} catch (Exception e) {
|
||||
System.out.println("GatewayManagerEJBBean - eccezione nel reinvio file.");
|
||||
e.printStackTrace();
|
||||
throw new RemoteException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void ejbRemove() throws EJBException, RemoteException {
|
||||
System.out.println("ejbRemove GatewayManagerEJBBean");
|
||||
}
|
||||
|
||||
public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException {
|
||||
//this.sessionContext = sessionContext;
|
||||
}
|
||||
|
||||
public void ejbCreate() throws CreateException {
|
||||
try
|
||||
{
|
||||
System.out.println("Create GatewayManagerEJBBean");
|
||||
path_reinviabili = Resources.getPathFileRinvio();
|
||||
path_non_reinviabili = Resources.getPathFileRinvioWarning();
|
||||
reinvioManager = new ReinvioManager();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
System.out.println("Impossibile inizializzare GatewayManagerEJBBean");
|
||||
ex.printStackTrace();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void ejbActivate() throws EJBException, RemoteException {
|
||||
|
||||
}
|
||||
|
||||
public void ejbPassivate() throws EJBException, RemoteException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package mnp.service;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import javax.ejb.CreateException;
|
||||
import javax.ejb.EJBHome;
|
||||
|
||||
public interface GatewayManagerEJBHome extends EJBHome {
|
||||
public abstract GatewayManagerEJB create() throws CreateException, RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package mnp.servlets;
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
import it.valueteam.logging.SessionInfo;
|
||||
import it.valueteam.logging.Tracer;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
|
||||
import mnp.exception.*;
|
||||
import mnp.securityLog.ActionLogMapping;
|
||||
|
||||
/**
|
||||
* The single entry point for all web requests.
|
||||
*/
|
||||
public class ManagementServlet
|
||||
extends HttpServlet {
|
||||
String retCommand;
|
||||
String abilitazioneDaCrontabFE;
|
||||
// ------------------------------
|
||||
// Overridden HttpServlet methods
|
||||
// ------------------------------
|
||||
|
||||
public void init() {
|
||||
////Abilitazione Contesto
|
||||
getServletContext().setAttribute("StatoFrontEnd", "y");
|
||||
}
|
||||
|
||||
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws
|
||||
IOException, ServletException {
|
||||
process(req, resp);
|
||||
}
|
||||
|
||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
|
||||
IOException, ServletException {
|
||||
returnStateFE(req, resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the given HTTP request and provides an appropriate
|
||||
* response.
|
||||
*/
|
||||
protected void process(HttpServletRequest req,
|
||||
HttpServletResponse resp) throws IOException,
|
||||
ServletException {
|
||||
|
||||
boolean isDone = false;
|
||||
abilitazioneDaCrontabFE = req.getParameter("stato");
|
||||
try {
|
||||
synchronized (getServletConfig().getServletContext()) {
|
||||
getServletContext().setAttribute("StatoFrontEnd", abilitazioneDaCrontabFE);
|
||||
}
|
||||
isDone = true;
|
||||
} finally {
|
||||
securityLog(abilitazioneDaCrontabFE, req.getRemoteAddr(), isDone);
|
||||
}
|
||||
}
|
||||
|
||||
protected void returnStateFE(HttpServletRequest req,
|
||||
HttpServletResponse resp) throws IOException,
|
||||
ServletException {
|
||||
|
||||
synchronized (getServletConfig().getServletContext()) {
|
||||
abilitazioneDaCrontabFE = (String) getServletContext().getAttribute("StatoFrontEnd");
|
||||
char stato;
|
||||
if (abilitazioneDaCrontabFE == null)
|
||||
throw new ServletException("APPLICAZIONE MNP NON ATTIVA");
|
||||
//{ stato='n';}
|
||||
else {
|
||||
stato = abilitazioneDaCrontabFE.charAt(0);
|
||||
}
|
||||
|
||||
OutputStreamWriter osw = null;
|
||||
osw = new OutputStreamWriter(resp.getOutputStream());
|
||||
osw.write(stato);
|
||||
osw.flush();
|
||||
osw.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CarloM 12/10/2006 - aggiunta del log sicurezza
|
||||
private void securityLog(String fileName, String address, boolean isOK) {
|
||||
int actionCode = ActionLogMapping.AbilitazioneGateway;
|
||||
try {
|
||||
String descrRetCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_OK : ActionLogMapping.LOG_RESULT_CODE_KO;
|
||||
int retCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK : ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO;
|
||||
SessionInfo sI = new SessionInfo(InetAddress.getLocalHost().getHostName(), InetAddress.getLocalHost().getHostName(), null, null, null, null, null, "BEA", address);
|
||||
Azione action = new Azione(actionCode, null, retCode, "abilitazione = " + fileName, descrRetCode);
|
||||
Tracer.log(sI, action);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Errore nell'operazione di scrittura su log sicurezza. Operazione = " + actionCode);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
178
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/ReceiveServlet.java
Normal file
178
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/ReceiveServlet.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package mnp.servlets;
|
||||
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
import it.valueteam.logging.SessionInfo;
|
||||
import it.valueteam.logging.Tracer;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
import weblogic.security.PEMInputStream;
|
||||
import mnp.exception.*;
|
||||
import mnp.utility.*;
|
||||
import mnp.securityLog.ActionLogMapping;
|
||||
import mnp.servlets.*;
|
||||
import mnp.log.*;
|
||||
import mnp.objects.*;
|
||||
|
||||
|
||||
public class ReceiveServlet extends HttpServlet implements LoggableFE{
|
||||
|
||||
private String internalReceiverURL;
|
||||
private ProcessLoggerFE log;
|
||||
protected String versione = "1.4.0.2";
|
||||
protected String codiceProcesso = "PA";
|
||||
private String PATH_RINVIO;
|
||||
private String PATH_WARNING;
|
||||
private static boolean httpsFlag;
|
||||
private static boolean sslFlag;
|
||||
private static boolean proxyFlag;
|
||||
private String hName;
|
||||
private String hIP;
|
||||
public void init() throws ServletException {
|
||||
|
||||
try {
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Errore nella creazione del ProcessLogger");
|
||||
}
|
||||
String mnp_path_properties = getInitParameter("mnp_path_properties");
|
||||
|
||||
// N - INIZIO PROCESSO
|
||||
log.write("0001", " versione " + versione);
|
||||
if (mnp_path_properties == null) {
|
||||
// C - ERRORE NELL’INIZIALIZZAZIONE DELLA SERVLET
|
||||
log.write("8000", "");
|
||||
// C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003", "");
|
||||
throw new ServletException("Impossibile caricare 'mnp_path_properties'; controllare le impostazioni della web-application");
|
||||
}
|
||||
System.setProperty("mnp_path_properties", mnp_path_properties);
|
||||
PATH_RINVIO = Resources.getPathFileRinvio();
|
||||
PATH_WARNING = Resources.getPathFileRinvioWarning();
|
||||
internalReceiverURL = Resources.getInternalReceiverURL();
|
||||
httpsFlag =Resources.getInternalHttpsFlag();
|
||||
sslFlag =Resources.getInternalSslFlag();
|
||||
proxyFlag =Resources.getInternalProxyFlag();
|
||||
try{
|
||||
hName=Resources.getHostName();
|
||||
hIP=Resources.getHostAddress();
|
||||
}
|
||||
catch(UnknownHostException e){
|
||||
// C - ERRORE NELL'INIZIALIZZAZIONE DELLA SERVLET
|
||||
log.write("8000", "");
|
||||
// C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003", "");
|
||||
throw new ServletException("Impossibile impostare HOSTNAME e IP ADDRESS");
|
||||
}
|
||||
// N - INIZIALIZZAZIONE DELLA SERVLET EFFETTUATA
|
||||
log.write("8001", "");
|
||||
}
|
||||
|
||||
public String getServletInfo() {
|
||||
return "[ReceiveServlet]";
|
||||
}
|
||||
|
||||
|
||||
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,java.io.IOException
|
||||
{
|
||||
String filename = null;
|
||||
String filexml = null;
|
||||
String tipofile = null;
|
||||
String abilitazioneFE = null;
|
||||
|
||||
//// Legge il valore di contesto
|
||||
abilitazioneFE = (String) getServletContext().getAttribute("StatoFrontEnd");
|
||||
if (!abilitazioneFE.equals("y")) {
|
||||
response.sendError(response.SC_PRECONDITION_FAILED, "FE disabilitato");
|
||||
return;
|
||||
}
|
||||
|
||||
//// FINE Legge il valore di contesto
|
||||
|
||||
int len = request.getContentLength();
|
||||
filename = request.getParameter("filename");
|
||||
filexml = request.getParameter("filexml");
|
||||
tipofile = request.getParameter("tipofile");
|
||||
|
||||
// Indica se l'operazione da loggare ha avuto successo o meno
|
||||
boolean fileReceived = false;
|
||||
try {
|
||||
if(!((filename!=null && !filename.equals("")) &&
|
||||
(filexml!=null && !filexml.equals("")) &&
|
||||
(tipofile!=null && !tipofile.equals("")))) {
|
||||
// C - PARAMETRI MANCANTI
|
||||
log.write("8002","");
|
||||
throw new CriticalException();
|
||||
}
|
||||
|
||||
// N - FILE XML DA INVIARE
|
||||
log.write("0073"," " + filename + "_" + tipofile + "_DBC");
|
||||
System.out.println("internalReceiverURL " + internalReceiverURL);
|
||||
XMLSender.sendXML(filexml, tipofile, filename, internalReceiverURL, httpsFlag, sslFlag, proxyFlag, log);
|
||||
// N - INVIATO FILE XML
|
||||
log.write("0070"," " + filename + "_" + tipofile + "_DBC");
|
||||
fileReceived = true;
|
||||
}
|
||||
catch(CriticalException ce) {
|
||||
// C - ERRORE IN INVIO FILE XML
|
||||
log.write("0071"," " + filename + "_" + tipofile + "_DBC");
|
||||
response.sendError(response.SC_NOT_ACCEPTABLE, "Il file non può essere accettato dal server; controllare sintassi e formato");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// C - ERRORE IN INVIO FILE XML
|
||||
log.write("0071"," " + filename + "_" + tipofile + "_DBC");
|
||||
try {
|
||||
new XMLSaver().salvaFile(filename,filexml,tipofile, PATH_RINVIO);
|
||||
// N - FILE SALVATO PER SUCCESSIVO REINVIO
|
||||
log.write("8004"," " + filename + "_" + tipofile + "_" + PATH_RINVIO);
|
||||
}
|
||||
catch (Exception ext) {
|
||||
// C - IMPOSSIBILE SALVARE IL FILE
|
||||
log.write("8003"," " + filename + "_" + tipofile + "_" + PATH_RINVIO);
|
||||
response.sendError(response.SC_INTERNAL_SERVER_ERROR, "Non è stato possibile acquisire il file, ritentare");
|
||||
}
|
||||
} finally {
|
||||
securityLog(filename, request.getRemoteHost(), fileReceived);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy(){
|
||||
super.destroy();
|
||||
log.write("0002","");
|
||||
System.out.println("Salve, sono ReceiveServlet e sono miseramente morta!!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
//CarloM 12/10/2006 - aggiunta del log sicurezza
|
||||
private void securityLog(String fileName, String ipSorgente, boolean isOK) {
|
||||
int actionCode = ActionLogMapping.RicezioneFileXML;
|
||||
try {
|
||||
String descrRetCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_OK : ActionLogMapping.LOG_RESULT_CODE_KO;
|
||||
int retCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK : ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO;
|
||||
SessionInfo sI = new SessionInfo(hIP, hName, null, null, null, null, null, "BEA", ipSorgente);
|
||||
Azione action = new Azione(actionCode, null, retCode, "NomeFile = " + fileName, descrRetCode);
|
||||
Tracer.log(sI, action);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Errore nell'operazione di scrittura su log sicurezza. Operazione = " + actionCode);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
185
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/SendServlet.java
Normal file
185
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/SendServlet.java
Normal file
@@ -0,0 +1,185 @@
|
||||
package mnp.servlets;
|
||||
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
import it.valueteam.logging.SessionInfo;
|
||||
import it.valueteam.logging.Tracer;
|
||||
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
import javax.servlet.*;
|
||||
|
||||
import mnp.securityLog.ActionLogMapping;
|
||||
import mnp.utility.*;
|
||||
import mnp.log.*;
|
||||
import mnp.objects.*;
|
||||
import mnp.exception.*;
|
||||
|
||||
/**
|
||||
* Title: MNP Project
|
||||
* Description: Mobile Number Portability
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: ObjectWay spa
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SendServlet extends HttpServlet implements LoggableFE{
|
||||
|
||||
private ProcessLoggerFE log;
|
||||
protected String versione = "1.4.0.2";
|
||||
protected String codiceProcesso = "PB";
|
||||
private String testMode;
|
||||
private String testURL;
|
||||
private String hName;
|
||||
private String hIP;
|
||||
boolean sslEnabled;
|
||||
private static boolean httpsFlag;
|
||||
private static boolean sslFlag;
|
||||
private static boolean proxyFlag;
|
||||
|
||||
public void init() throws javax.servlet.ServletException
|
||||
{
|
||||
try{
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch(Exception ex){
|
||||
System.out.println("Errore nella creazione del ProcessLogger");
|
||||
}
|
||||
// N - INIZIO PROCESSO
|
||||
log.write("0001"," versione "+ versione);
|
||||
String mnp_path_properties = getInitParameter("mnp_path_properties");
|
||||
if(mnp_path_properties==null) {
|
||||
// C - ERRORE NELL'INIZIALIZZAZIONE DELLA SERVLET
|
||||
log.write("8100","");
|
||||
// C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
throw new ServletException("Impossibile caricare 'mnp_path_properties'; controllare le impostazioni della web-application");
|
||||
}
|
||||
|
||||
System.setProperty("mnp_path_properties", mnp_path_properties);
|
||||
|
||||
testMode = Resources.getTestMode();
|
||||
testURL = Resources.getTestURL();
|
||||
sslEnabled = Resources.withSSL();
|
||||
httpsFlag = Resources.getExternalHttpsFlag();
|
||||
sslFlag = Resources.getExternalSslFlag();
|
||||
proxyFlag = Resources.getExternalProxyFlag();
|
||||
try{
|
||||
hName=Resources.getHostName();
|
||||
hIP=Resources.getHostAddress();
|
||||
}
|
||||
catch(UnknownHostException e){
|
||||
// C - ERRORE NELL'INIZIALIZZAZIONE DELLA SERVLET
|
||||
log.write("8100","");
|
||||
// C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
throw new ServletException("Impossibile impostare HOSTNAME e IP ADDRESS");
|
||||
}
|
||||
// N - INIZIALIZZAZIONE DELLA SERVLET EFFETTUATA
|
||||
log.write("8101","");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ricava l'URL dell'operatore mobile
|
||||
* */
|
||||
private String getOloURL(String codOlo) throws Exception {
|
||||
String ret = null;
|
||||
if(testMode.equalsIgnoreCase("yes")) ret = testURL;
|
||||
else ret = Resources.getOloURL(codOlo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Torna informazioni sul servizio
|
||||
* */
|
||||
public String getServletInfo() {
|
||||
return "[SendServlet]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Riceve dal Back-End le informazioni da inviare agli AOM
|
||||
* */
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
|
||||
String filename = null;
|
||||
String filexml = null;
|
||||
String tipofile = null;
|
||||
String codOlo = null;
|
||||
String address = null;
|
||||
|
||||
filename = request.getParameter("filename");
|
||||
filexml = request.getParameter("filexml");
|
||||
tipofile = request.getParameter("tipofile");
|
||||
codOlo = request.getParameter("codOlo");
|
||||
|
||||
boolean fileSent = false;
|
||||
|
||||
try {
|
||||
address = getOloURL(codOlo);
|
||||
System.out.println("address " + address);
|
||||
// N - FILE XML DA INVIARE
|
||||
log.write("0073"," " + filename + "_" + tipofile + "_" + address);
|
||||
XMLSender.sendXML(filexml, tipofile, filename, address, httpsFlag, sslFlag, proxyFlag, log);
|
||||
// N - INVIATO FILE XML
|
||||
log.write("0070"," " + filename + "_" + tipofile + "_" + address);
|
||||
fileSent = true;
|
||||
}
|
||||
catch (java.io.InterruptedIOException ex) {
|
||||
// C - ERRORE IN INVIO FILE XML
|
||||
log.write("0071"," TIMEOUT NELLA CONNESSIONE CON AOM " + filename + "_" + tipofile +"_" + address);
|
||||
try {
|
||||
response.sendError(HttpURLConnection.HTTP_CLIENT_TIMEOUT, ex.getMessage());
|
||||
}
|
||||
catch (IOException ex1) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.write("9999"," " + filename + " ERRORE :"+ex.getMessage());
|
||||
// C - ERRORE IN INVIO FILE XML
|
||||
log.write("0071"," " + filename + "_" + tipofile + "_" + address);
|
||||
response.sendError(response.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
|
||||
} finally {
|
||||
securityLog(filename, address, fileSent);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy(){
|
||||
super.destroy();
|
||||
// N - PROCESSO TERMINATO CORRETTAMENTE
|
||||
log.write("0002","");
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
|
||||
//CarloM 12/10/2006 - aggiunta del log sicurezza
|
||||
private void securityLog(String fileName, String address, boolean isOK) {
|
||||
int actionCode = ActionLogMapping.InvioFileXML;
|
||||
try {
|
||||
String descrRetCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_OK : ActionLogMapping.LOG_RESULT_CODE_KO;
|
||||
int retCode = (isOK) ? ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK : ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO;
|
||||
SessionInfo sI = new SessionInfo(hIP, hName, null, null, null, null, null, "BEA", null);
|
||||
Map parametri = new HashMap();
|
||||
parametri.put("address", address);
|
||||
Azione action = new Azione(actionCode, parametri, retCode, "NomeFile = " + fileName, descrRetCode);
|
||||
Tracer.log(sI, action);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Errore nell'operazione di scrittura su log sicurezza. Operazione = " + actionCode);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
99
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/TestReceive.java
Normal file
99
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/TestReceive.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package mnp.servlets;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
|
||||
import mnp.utility.*;
|
||||
|
||||
/**
|
||||
* Title: MNP Project
|
||||
* Description: Mobile Number Portability
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: ObjectWay spa
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TestReceive extends HttpServlet {
|
||||
private int maxrichieste;
|
||||
|
||||
|
||||
public void init() throws ServletException
|
||||
{
|
||||
super.init();
|
||||
String n = getInitParameter("maxrichieste");
|
||||
try {
|
||||
maxrichieste=Integer.parseInt(n);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
maxrichieste=30;
|
||||
}
|
||||
|
||||
System.out.println("Salve, sono TestReceive e sono appena nata!!");
|
||||
}
|
||||
|
||||
|
||||
public void doPost(HttpServletRequest request,HttpServletResponse response)
|
||||
throws ServletException,java.io.IOException
|
||||
{
|
||||
String filename = null;
|
||||
String filexml = null;
|
||||
String tipofile = null;
|
||||
|
||||
filename = request.getParameter("filename");
|
||||
filexml = request.getParameter("filexml");
|
||||
tipofile = request.getParameter("tipofile");
|
||||
|
||||
if(!((filename!=null && !filename.equals("")) &&
|
||||
(filexml!=null && !filexml.equals("")) &&
|
||||
(tipofile!=null && !tipofile.equals("")))) {
|
||||
|
||||
System.out.println("Skipping request");
|
||||
return;
|
||||
}
|
||||
System.out.println("\n********\nRICEVO="+filexml+"\n"+filename+"\n"+tipofile+"\n*********");
|
||||
|
||||
try {
|
||||
if ((filexml.indexOf("ACKNOWLEDGE"))>0)
|
||||
{
|
||||
filexml= filexml.substring(
|
||||
(filexml.indexOf (">",(filexml.indexOf("<ACKNOWLEDGE>")) )+1 ),
|
||||
(filexml.length())
|
||||
);
|
||||
|
||||
filexml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ACKNOWLEDGE xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MNP.xsd\">"+filexml;
|
||||
//filexml=Resources.XMLAckHeader+filexml;
|
||||
//RequestManager.acquisizioneAck(filexml, filename,tipofile);
|
||||
System.out.println("Messaggio: "+filename+", di tipo: "+tipofile);
|
||||
}
|
||||
else
|
||||
{
|
||||
filexml= filexml.substring(
|
||||
(filexml.indexOf (">",(filexml.indexOf("<LISTA_MNP_RECORD>")) )+1 ),
|
||||
(filexml.length())
|
||||
);
|
||||
filexml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><LISTA_MNP_RECORD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MNP.xsd\">"+filexml;
|
||||
//filexml=Resources.XMLRequestHeader+filexml;
|
||||
// Prendo in carico solo i files di tipo ATTIVAZIONE (tipoFile = 1)
|
||||
System.out.println("Messaggio: "+filename+", di tipo: "+tipofile);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
super.destroy();
|
||||
System.out.println("Salve, sono TestReceive e sono miseramente morta!!");
|
||||
}
|
||||
|
||||
}
|
||||
217
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/UploadServlet.java
Normal file
217
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/UploadServlet.java
Normal file
@@ -0,0 +1,217 @@
|
||||
package mnp.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
//import java.rmi.RemoteException;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import mnp.log.LoggableFE;
|
||||
import mnp.log.ProcessLoggerFE;
|
||||
import mnp.objects.LogInfoFE;
|
||||
import mnp.objects.LogProcessFE;
|
||||
import mnp.proxy.FromGW.FrontendProxyEJB;
|
||||
import mnp.proxy.FromGW.FrontendProxyEJBHome;
|
||||
import mnp.utility.ApplicationCostants;
|
||||
import mnp.utility.FEServiceLocator;
|
||||
import mnp.utility.Resources;
|
||||
|
||||
import org.apache.commons.fileupload.*;
|
||||
import org.apache.commons.fileupload.disk.*;
|
||||
import org.apache.commons.fileupload.servlet.*;
|
||||
|
||||
|
||||
public class UploadServlet extends HttpServlet implements LoggableFE{
|
||||
private static final String CONTENT_TYPE = "text/html";
|
||||
//log
|
||||
protected static final String versione = "1.0.0";
|
||||
protected static final String codiceProcesso = "PA";
|
||||
private ProcessLoggerFE log;
|
||||
|
||||
//Initialize global variables
|
||||
public void init() throws ServletException {
|
||||
try {
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Errore nella creazione del ProcessLogger");
|
||||
ex.printStackTrace();
|
||||
throw new ServletException("Errore nella creazione del ProcessLogger");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Process the HTTP Get request
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
|
||||
ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
private final void processRequest(HttpServletRequest request,
|
||||
HttpServletResponse response) throws
|
||||
ServletException, IOException {
|
||||
|
||||
String oloMittente = null;
|
||||
String tipoFile = null;
|
||||
String fileName = null;
|
||||
String content = null;
|
||||
FEServiceLocator feServiceLocator=null;
|
||||
|
||||
InputStream is = null;
|
||||
String responseXML = null;
|
||||
try {
|
||||
// INIZIO TRATTAMENTO MESSAGGIO - VERSIONE
|
||||
log.write("0001", versione);
|
||||
boolean isMultipart = ServletFileUpload.isMultipartContent(new
|
||||
ServletRequestContext(request));
|
||||
if (isMultipart) {
|
||||
log.write("9999","RICEVUTA RICHIESTA MULTIPART");
|
||||
|
||||
//Inizio reperimento parametri dalla request
|
||||
oloMittente = request.getParameter(ApplicationCostants.REQUEST_OLO_MITTENTE);
|
||||
tipoFile = request.getParameter(ApplicationCostants.REQUEST_TIPO_FILE);
|
||||
fileName = request.getParameter(ApplicationCostants.REQUEST_FILE_NAME);
|
||||
log.write("9999", "PARAMETRI RICEVUTI NELL'URL : \n" + ApplicationCostants.REQUEST_OLO_MITTENTE + " = " + oloMittente + "\n"
|
||||
+ ApplicationCostants.REQUEST_TIPO_FILE + " = " + tipoFile + "\n" + ApplicationCostants.REQUEST_FILE_NAME + " = " + fileName);
|
||||
//Fine reperimento parametri dalla request
|
||||
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload servletFileUpload = new ServletFileUpload(factory);
|
||||
servletFileUpload.setSizeMax( -1);
|
||||
|
||||
List items = servletFileUpload.parseRequest(request);
|
||||
log.write("9999","IL PARSING DELLA REQUEST E' STATO ESEGUITO CORRETTAMENTE");
|
||||
Iterator iter = items.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
FileItem item = (FileItem) iter.next();
|
||||
if (item.isFormField()) {
|
||||
String name = item.getFieldName();
|
||||
log.write("9999","Parametro ricevuto in input: "+name);
|
||||
if (name.equalsIgnoreCase(ApplicationCostants.
|
||||
REQUEST_FILE_NAME)) {
|
||||
fileName = item.getString();
|
||||
if(fileName==null || fileName.trim().length()==0){
|
||||
fileName = item.getString();
|
||||
log.write("9999","RICEVUTO PARAMETRO IN MULTIPART NOME_FILE: "+fileName);
|
||||
}
|
||||
|
||||
}
|
||||
else if (name.equalsIgnoreCase(ApplicationCostants.
|
||||
REQUEST_TIPO_FILE)) {
|
||||
tipoFile = item.getString();
|
||||
if(tipoFile==null || tipoFile.trim().length()==0){
|
||||
tipoFile = item.getString();
|
||||
log.write("9999","RICEVUTO PARAMETRO IM MULTIPART TIPO_FILE: "+tipoFile);
|
||||
}
|
||||
}
|
||||
else if (name.equalsIgnoreCase(ApplicationCostants.
|
||||
REQUEST_OLO_MITTENTE)) {
|
||||
oloMittente = item.getString();
|
||||
if(oloMittente==null || oloMittente.trim().length()==0){
|
||||
oloMittente = item.getString();
|
||||
log.write("9999","RICEVUTO PARAMETRO IN MULTIPART OLO_MITTENTE: "+oloMittente);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fileName == null || fileName.trim().length() == 0) {
|
||||
fileName = URLDecoder.decode(item.getName(), "UTF-8");
|
||||
}
|
||||
is = item.getInputStream();
|
||||
int b = 0;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
while ((b=is.read())!=-1) {
|
||||
baos.write(b);
|
||||
}
|
||||
content = new String(baos.toByteArray());
|
||||
baos.close();
|
||||
log.write("9999","RICEVUTO TRACCIATO XML: "+content);
|
||||
}
|
||||
}
|
||||
//richiamo il servizio di acquisizione su FE
|
||||
//tutti i check vengono eseguiti su FE
|
||||
feServiceLocator = new FEServiceLocator();
|
||||
FrontendProxyEJBHome frontendProxyEJBHome = (FrontendProxyEJBHome)
|
||||
feServiceLocator.getRemoteHome(Resources.getFEPROXYJndiName(),
|
||||
FrontendProxyEJBHome.class);
|
||||
FrontendProxyEJB frontendProxyEJB = frontendProxyEJBHome.create();
|
||||
|
||||
responseXML = frontendProxyEJB.handleFileIn(tipoFile, fileName,
|
||||
content,
|
||||
oloMittente);
|
||||
|
||||
//eseguo il encode prima di mandare il file
|
||||
log.write("9999","ACK CREATO DAL FE DA INVIARE ALL'OLO MITTENTE :\n");
|
||||
log.write("9999","ACK: ["+responseXML+"]");
|
||||
|
||||
//responseXML = URLEncoder.encode(responseXML, "UTF-8");
|
||||
//rispondo
|
||||
response.setContentType("text/xml");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(responseXML);
|
||||
// FINE TRATTAMENTO MESSAGGIO
|
||||
log.write("0002", oloMittente);
|
||||
}
|
||||
else {
|
||||
log.write("9999", "IL TIPO FILE RICEVUTO NON E' MULTIPART");
|
||||
throw new UnsupportedOperationException("tipo file ricevuto non multipart!!!");
|
||||
}
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
e.printStackTrace();
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST,e.getMessage());
|
||||
log.write("9999","oloMittente:"+oloMittente);
|
||||
log.write("9999","tipoFile:"+tipoFile);
|
||||
log.write("9999","fileName:"+fileName);
|
||||
log.write("9999","content:"+content);
|
||||
// FINE TRATTAMENTO MESSAGGIO CON ECCEZIONI
|
||||
log.write("0003", "");
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
|
||||
if(e.getCause() instanceof mnp.proxy.FromGW.OutWindowTimeException){ // Maddechè?
|
||||
log.write("9999", "FILE RICEVUTO FUORI DALLE FINESTRE TEMPORALI :" + e.getCause().getMessage());
|
||||
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,e.getMessage());
|
||||
log.write("9999", "RESITUITO A "+oloMittente+" UN ERRORE HTTP " + HttpServletResponse.SC_SERVICE_UNAVAILABLE);
|
||||
}else{
|
||||
e.printStackTrace();
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,e.getMessage());
|
||||
// FINE TRATTAMENTO MESSAGGIO CON ECCEZIONI
|
||||
log.write("0003", "");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (feServiceLocator!=null)
|
||||
feServiceLocator.closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
//Clean up resources
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
|
||||
}
|
||||
195
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/XMLSaver.java
Normal file
195
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/XMLSaver.java
Normal file
@@ -0,0 +1,195 @@
|
||||
package mnp.servlets;
|
||||
|
||||
|
||||
import mnp.utility.*;
|
||||
import java.sql.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import mnp.objects.*;
|
||||
import mnp.log.*;
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: crea una directory sul file system salvando i file che al momento non sono stati inviati
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author Francesca
|
||||
* @version 1.0
|
||||
* @version 2.0 C09_2017 RU_517 line 69 and 130 (Unreleased Resource: Streams)
|
||||
*/
|
||||
public class XMLSaver implements LoggableFE{
|
||||
|
||||
private ProcessLoggerFE log;
|
||||
protected String versione = "1.4.0.1";
|
||||
protected String codiceProcesso = "PC";
|
||||
|
||||
public XMLSaver() throws Exception{
|
||||
try{
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch(Exception ex){
|
||||
System.out.println("Errore nella creazione del ProcessLogger");
|
||||
}
|
||||
}
|
||||
|
||||
/*creazione della directory dove andrò a salvare i file che al momento non verranno inviati*/
|
||||
private void creaDir(String sServerFilePath) throws Exception{
|
||||
File fDirect = new File(sServerFilePath);
|
||||
fDirect.mkdirs();
|
||||
}
|
||||
|
||||
/*metodo che salva i file che non il FE non è riuscito ad inviare al BE in quel momento
|
||||
e che saranno successivamente rinviati*/
|
||||
public void salvaFile(String filename, String filexml,String tipofile, String sServerFilePath) throws Exception
|
||||
{
|
||||
ObjectOutputStream out = null;
|
||||
String dest = null;
|
||||
|
||||
filexml = URLDecoder.decode(filexml,"UTF-8");
|
||||
FileInfo fileinfo = new FileInfo();
|
||||
fileinfo.setFilename(filename);
|
||||
fileinfo.setFilexml(filexml);
|
||||
fileinfo.setData_ricezione(new java.util.Date());
|
||||
fileinfo.setTipofile(tipofile);
|
||||
|
||||
try {
|
||||
creaDir(sServerFilePath);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// C - ERRORE NELLA CREAZIONE DELLA DIRECTORY
|
||||
log.write("0027"," " + sServerFilePath);
|
||||
throw ex;
|
||||
}
|
||||
File file = null;
|
||||
// C09_2017 RU_517 BEGIN
|
||||
FileOutputStream fos = null;
|
||||
try{
|
||||
file = new File(sServerFilePath,filename+".xml");
|
||||
fos = new FileOutputStream(file);
|
||||
out = new ObjectOutputStream(fos);
|
||||
out.writeObject(fileinfo);
|
||||
out.flush();
|
||||
}catch(Exception e){
|
||||
throw e;
|
||||
}finally{
|
||||
if(null != fos) {
|
||||
try {
|
||||
fos.close();
|
||||
if(null != out) {
|
||||
out.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
fos = null;
|
||||
out = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Il Main viene utilizzato come utility per salvare in oggetto serializzabile
|
||||
* un file xml
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
XMLSaver xmlSaver = null;
|
||||
File xmlSource = null;
|
||||
|
||||
if(args.length<1) {
|
||||
System.out.println("Usage: 'XMLSaver.class <PATH_DIR_XML_INPUT>' ");
|
||||
System.out.println("dove <PATH_DIR_XML_INPUT> è il directory dove risiedono i files xml da trasformare per l'acquisizione");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
System.out.println("Start Process....");
|
||||
|
||||
xmlSaver = new XMLSaver();
|
||||
xmlSource = new File(args[0]);
|
||||
char[] charRead = new char[1024*1024*5]; // 500 KB
|
||||
int nCharRead = -1;
|
||||
|
||||
System.out.println("Ricerca files da recuperare in dir: " + xmlSource);
|
||||
|
||||
// Ricerco i files grezzi da acquisire
|
||||
File[] fileList = xmlSource.listFiles();
|
||||
if(fileList==null) {
|
||||
System.out.println("No file found in dir: " + xmlSource);
|
||||
return;
|
||||
}
|
||||
BufferedReader br = null;
|
||||
String filexml = null;
|
||||
String filename = null;
|
||||
String tipofile = null;
|
||||
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
if (fileList[i].isDirectory())
|
||||
continue;
|
||||
|
||||
System.out.println("Analisi file: " + fileList[i].getName());
|
||||
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(fileList[i].getCanonicalPath()));
|
||||
nCharRead = br.read(charRead, 0, charRead.length);
|
||||
br.close();
|
||||
|
||||
// Ottengo i tre parametri del file ricevuto
|
||||
filexml = new String(charRead, 0, nCharRead);
|
||||
filename = fileList[i].getName();
|
||||
if (filename.endsWith(".xml")) {
|
||||
filename = filename.substring(0, filename.length() - ".xml".length());
|
||||
}
|
||||
tipofile = filexml.substring(
|
||||
filexml.indexOf(">", filexml.indexOf("<TIPO_MESSAGGIO>")) + 1,
|
||||
filexml.indexOf("</TIPO_MESSAGGIO>")).trim();
|
||||
|
||||
// Salvo il file serializzato nella directory specificata
|
||||
xmlSaver.salvaFile(filename, filexml, tipofile,
|
||||
Resources.getPathFileRinvio());
|
||||
|
||||
// Elimino il file originario
|
||||
fileList[i].delete();
|
||||
System.out.println("File: " + fileList[i].getName() + " elaborato con successo!");
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
System.out.println("Problemi nell'elaborazione del file: " + fileList[i].getName());
|
||||
}
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Corretto che apra e chiuda il reader a ogni giro. Closing when previously closed will have no effect;
|
||||
finally {
|
||||
if(null != br) {
|
||||
try {
|
||||
br.close();
|
||||
br = null;
|
||||
} catch (Exception e) {
|
||||
br = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
} // end for
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("Processo terminato in modo anomalo");
|
||||
}
|
||||
finally {
|
||||
System.out.println("Process ends.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
356
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/XMLSender.java
Normal file
356
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/XMLSender.java
Normal file
@@ -0,0 +1,356 @@
|
||||
package mnp.servlets;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import mnp.exception.*;
|
||||
import mnp.log.*;
|
||||
import mnp.utility.*;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: Il compito di questa classe e' quello di inviare i file inviati dagli altri
|
||||
* operatori al FE via HTTP al BE</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author Francesca
|
||||
* @version 1.0
|
||||
* @version 2.0 C09_2017 RU_517 line 103 (Unreleased Resource: Streams)
|
||||
*/
|
||||
public class XMLSender {
|
||||
|
||||
protected String key_file;
|
||||
protected String cert_file;
|
||||
protected String cacert_file;
|
||||
|
||||
public XMLSender() {
|
||||
}
|
||||
|
||||
/*invio i file o almeno ci provo da FE a BE, nel caso in cui non riesco a mandare i file
|
||||
vado a salvarli su un file system ritornando con un exception*/
|
||||
public static final void sendXML(String filexml, String tipofile, String filename, String address, boolean httpsFlag, boolean sslFlag, boolean proxyFlag, ProcessLoggerFE log) throws Exception {
|
||||
log.write("0073","Start sendXML con parametri in ingresso:");
|
||||
|
||||
log.write("0073","filexml "+filexml);
|
||||
log.write("0073","tipofile "+tipofile);
|
||||
log.write("0073","filename "+filename);
|
||||
log.write("0073","address "+address);
|
||||
log.write("0073","httpsFlag "+httpsFlag);
|
||||
log.write("0073","sslFlag "+sslFlag);
|
||||
log.write("0073","proxyFlag "+proxyFlag);
|
||||
|
||||
|
||||
String response = "KO";
|
||||
Integer responseCodeAO;
|
||||
String query = null;
|
||||
String ack_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ACKNOWLEDGE>";
|
||||
String rich_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><LISTA_MNP_RECORD>";
|
||||
//weblogic.net.http.HttpURLConnection sconnection = null;
|
||||
|
||||
try {
|
||||
if ( (filename == null || filename.equals("")) || (filexml == null || filexml.equals("")) || (tipofile == null || tipofile.equals(""))) {
|
||||
// C - PARAMETRI MANCANTI
|
||||
log.write("0080", "");
|
||||
throw new CriticalException();
|
||||
}
|
||||
|
||||
// Aggiunta per RU_90
|
||||
if (filename.length() != 27) {
|
||||
throw new CriticalException();
|
||||
}
|
||||
|
||||
String test = "filexml=" + filexml + "&filename=" + filename + "&tipofile=" + tipofile;
|
||||
System.out.println("Ricevo: " + test);
|
||||
|
||||
// Codifico per l'HTML in uscita
|
||||
filexml = URLEncoder.encode(filexml, "UTF-8");
|
||||
test = "filexml=" + filexml + "&filename=" + filename + "&tipofile=" + tipofile;
|
||||
System.out.println("Rimando: " + test);
|
||||
query = "filexml=" + filexml + "&filename=" + filename + "&tipofile=" + tipofile;
|
||||
URL wlsUrl = null;
|
||||
|
||||
//KIT200507
|
||||
//separazione http e https perch� devono essere usate classi diverse
|
||||
//causa problemi di handshake con IIS
|
||||
//HTTPS:
|
||||
if (sslFlag) {
|
||||
|
||||
log.write("0073"," flusso sslFlag ");
|
||||
|
||||
try {
|
||||
wlsUrl = new URL(new URL(address), address, new com.ibm.net.ssl.internal.www.protocol.https.Handler());
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
// C - ERRORE NELLA URL DELL'AOM
|
||||
log.write("0081", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
log.write("0073"," wlsUrl "+wlsUrl);
|
||||
System.out.println("wlsUrl " + wlsUrl);
|
||||
|
||||
int timeout = Resources.getHttpTimeOut();
|
||||
com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection sconnection = (com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection) wlsUrl.openConnection();
|
||||
|
||||
// Caricamento Certificati
|
||||
if (sslFlag) {
|
||||
FileInputStream fis =null;
|
||||
FileInputStream fist =null;
|
||||
try {
|
||||
System.out.println("Inizio caricamento certificati per SSL");
|
||||
String keystore = Resources.getKeyStore();
|
||||
String truststore = Resources.getTrustKeyStore();
|
||||
String keypwd = Resources.getPrivateKeyAliasPwd();
|
||||
String IBMJSSEProvider = "IBMJSSE2";
|
||||
//manager del keystore della Private Key
|
||||
String alg = KeyManagerFactory.getDefaultAlgorithm();
|
||||
KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg, IBMJSSEProvider); //<-- il provider!
|
||||
fis = new FileInputStream(keystore);
|
||||
KeyStore ks = KeyStore.getInstance("jks");
|
||||
ks.load(fis, null);
|
||||
fis.close();
|
||||
kmFact.init(ks, keypwd.toCharArray());
|
||||
KeyManager[] kms = kmFact.getKeyManagers();
|
||||
|
||||
//manager del keystore delle CA
|
||||
String algt = TrustManagerFactory.getDefaultAlgorithm();
|
||||
TrustManagerFactory tmFact = TrustManagerFactory.getInstance(algt, IBMJSSEProvider); //<-- il provider!
|
||||
fist = new FileInputStream(truststore);
|
||||
KeyStore kst = KeyStore.getInstance("jks");
|
||||
kst.load(fist, null);
|
||||
fist.close();
|
||||
tmFact.init(kst);
|
||||
TrustManager[] tms = tmFact.getTrustManagers();
|
||||
|
||||
//creazione del context SSL
|
||||
SSLContext sslContext;
|
||||
sslContext = SSLContext.getInstance("SSL_TLSv2", IBMJSSEProvider);
|
||||
sslContext.init(kms, tms, null);
|
||||
|
||||
//open connection
|
||||
sconnection = (com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection) wlsUrl.openConnection();
|
||||
|
||||
//set del Socket Factory alla connessione https
|
||||
SSLSocketFactory factory = sslContext.getSocketFactory();
|
||||
|
||||
// Setto il timeout della connessione solo se il destinatario NON � TIM (altrimenti potrei avere problemi
|
||||
// per il fatto che l'AOM crede di non avere spedito il file mentre invece il BE lo ha processato
|
||||
if (!address.equalsIgnoreCase(Resources.getInternalReceiverURL())) {
|
||||
//sconnection.setTimeout(timeout);
|
||||
CustomSSLSocketFactory csf = new CustomSSLSocketFactory(factory, timeout);
|
||||
sconnection.setSSLSocketFactory(csf);
|
||||
sconnection.setDefaultSSLSocketFactory(csf);
|
||||
}
|
||||
else {
|
||||
//Custom class per poter valorizzare il timeout sul socket
|
||||
sconnection.setSSLSocketFactory(factory);
|
||||
sconnection.setDefaultSSLSocketFactory(factory);
|
||||
}
|
||||
|
||||
log.write("0073","Caricamento certificati per SSL completato");
|
||||
System.out.println("Caricamento certificati per SSL completato");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// C - ERRORE NEL CARICAMENTO DEI CERTIFICATI
|
||||
log.write("0082", "");
|
||||
throw ex;
|
||||
}
|
||||
finally{
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Closing when previously closed will have no effect;
|
||||
if(null != fis) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
fis = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
if(null != fist) {
|
||||
try {
|
||||
fist.close();
|
||||
} catch (Exception e) {
|
||||
fist = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
}
|
||||
|
||||
// Set request method
|
||||
sconnection.setRequestMethod("POST");
|
||||
// Apertura canali e scrittura file
|
||||
sconnection.setDoOutput(true);
|
||||
sconnection.setDoInput(true);
|
||||
|
||||
OutputStreamWriter wout = null;
|
||||
try {
|
||||
sconnection.connect();
|
||||
wout = new OutputStreamWriter(sconnection.getOutputStream());
|
||||
wout.write(query);
|
||||
wout.flush();
|
||||
response = sconnection.getResponseMessage();
|
||||
responseCodeAO = sconnection.getResponseCode();
|
||||
|
||||
log.write("0073","Response Message: "+response);
|
||||
log.write("0073","Response Code: "+responseCodeAO);
|
||||
|
||||
}
|
||||
catch (java.io.InterruptedIOException ex1) {
|
||||
log.write("0073","java.io.InterruptedIOException: "+ex1.getMessage());
|
||||
System.out.println("filexml:" + filexml + ", " + ex1.getMessage());
|
||||
throw ex1;
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
log.write("0073","Exception rilevata: "+ex.getMessage());
|
||||
|
||||
ex.printStackTrace();
|
||||
int responseCode = sconnection.getResponseCode();
|
||||
log.write("0073","responseCode: "+responseCode);
|
||||
|
||||
switch (responseCode) {
|
||||
case java.net.HttpURLConnection.HTTP_NOT_ACCEPTABLE:
|
||||
throw new CriticalException();
|
||||
case java.net.HttpURLConnection.HTTP_INTERNAL_ERROR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// C - IMPOSSIBILE CONTATARE IL SERVER REMOTO
|
||||
log.write("0083", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
// if (response == null || !response.equalsIgnoreCase("OK")) {
|
||||
// log.write("0073","Errore response non valorizzata CORRETTAMENTE");
|
||||
//
|
||||
// // C - CONNESSIONE AOM NON DISPONIBILE
|
||||
// log.write("0072", " " + filename);
|
||||
// throw new Exception("Invio file fallito" + filename);
|
||||
// }
|
||||
|
||||
if (!(responseCodeAO == java.net.HttpURLConnection.HTTP_OK)) {
|
||||
//Il response code non è 200 Solo in caso di response code 200 il file si considera trasferito correttamente
|
||||
|
||||
log.write("0073","Response code non corretto");
|
||||
|
||||
// C - CONNESSIONE AOM NON DISPONIBILE
|
||||
log.write("0072", " " + filename);
|
||||
throw new Exception("Invio file fallito" + filename);
|
||||
|
||||
}
|
||||
|
||||
log.write("0073","Esecuzione SSL Completata Correttamente");
|
||||
|
||||
sconnection.disconnect();
|
||||
wout.close();
|
||||
}
|
||||
//HTTP:
|
||||
else {
|
||||
log.write("0073"," flusso HTTP ");
|
||||
|
||||
try {
|
||||
wlsUrl = new URL(address);
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
// C - ERRORE NELLA URL DELL'AOM
|
||||
log.write("0081", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
log.write("0073"," wlsUrl ");
|
||||
System.out.println("wlsUrl " + wlsUrl);
|
||||
int timeout = Resources.getHttpTimeOut();
|
||||
weblogic.net.http.HttpURLConnection connection = null;
|
||||
|
||||
if( httpsFlag ){
|
||||
System.setProperty("java.protocol.handler.pkgs", "weblogic.net");
|
||||
connection = new weblogic.net.http.HttpsURLConnection(wlsUrl);
|
||||
}
|
||||
else {
|
||||
connection = new weblogic.net.http.HttpURLConnection(wlsUrl);
|
||||
}
|
||||
|
||||
// Setto il timeout della connessione solo se il destinatario NON � TIM (altrimenti potrei avere problemi
|
||||
// per il fatto che l'AOM crede di non avere spedito il file mentre invece il BE lo ha processato
|
||||
if (!address.equalsIgnoreCase(Resources.getInternalReceiverURL())) {
|
||||
connection.setTimeout(timeout);
|
||||
}
|
||||
|
||||
// Set request method
|
||||
connection.setRequestMethod("POST");
|
||||
// Apertura canali e scrittura file
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
|
||||
OutputStreamWriter wout = null;
|
||||
try {
|
||||
connection.connect();
|
||||
wout = new OutputStreamWriter(connection.getOutputStream());
|
||||
wout.write(query);
|
||||
wout.flush();
|
||||
response = connection.getResponseMessage();
|
||||
responseCodeAO = connection.getResponseCode();
|
||||
|
||||
log.write("0073","Response Message: "+response);
|
||||
log.write("0073","Response Code: "+responseCodeAO);
|
||||
|
||||
}
|
||||
catch (java.io.InterruptedIOException ex1) {
|
||||
log.write("0073","java.io.InterruptedIOException: "+ex1.getMessage());
|
||||
|
||||
System.out.println("filexml:" + filexml + ", " + ex1.getMessage());
|
||||
throw ex1;
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
log.write("0073","Exception rilevata: "+ex.getMessage());
|
||||
|
||||
ex.printStackTrace();
|
||||
int responseCode = connection.getResponseCode();
|
||||
log.write("0073","responseCode: "+responseCode);
|
||||
|
||||
switch (responseCode) {
|
||||
case java.net.HttpURLConnection.HTTP_NOT_ACCEPTABLE:
|
||||
throw new CriticalException();
|
||||
case java.net.HttpURLConnection.HTTP_INTERNAL_ERROR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// C - IMPOSSIBILE CONTATARE IL SERVER REMOTO
|
||||
log.write("0083", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// if (response == null || !response.equalsIgnoreCase("OK")) {
|
||||
// log.write("0073","Errore response non valorizzata CORRETTAMENTE");
|
||||
//
|
||||
// // C - CONNESSIONE AOM NON DISPONIBILE
|
||||
// log.write("0072", " " + filename);
|
||||
// throw new Exception("Invio file fallito" + filename);
|
||||
// }
|
||||
|
||||
if (!(responseCodeAO == java.net.HttpURLConnection.HTTP_OK)) {
|
||||
//Il response code non è 200 Solo in caso di response code 200 il file si considera trasferito correttamente
|
||||
|
||||
log.write("0073","Response code non corretto");
|
||||
|
||||
// C - CONNESSIONE AOM NON DISPONIBILE
|
||||
log.write("0072", " " + filename);
|
||||
throw new Exception("Invio file fallito" + filename);
|
||||
|
||||
}
|
||||
log.write("0073","Invio file completato correttamente");
|
||||
|
||||
connection.disconnect();
|
||||
wout.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package mnp.servlets.init;
|
||||
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
import it.valueteam.logging.SessionInfo;
|
||||
import it.valueteam.logging.Tracer;
|
||||
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
import javax.servlet.*;
|
||||
|
||||
import mnp.securityLog.ActionLogMapping;
|
||||
import mnp.utility.*;
|
||||
import mnp.log.*;
|
||||
import mnp.objects.*;
|
||||
import mnp.exception.*;
|
||||
|
||||
/**
|
||||
* Title: MNP Project
|
||||
* Description: Mobile Number Portability
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: ObjectWay spa
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class InitServlet extends HttpServlet {
|
||||
|
||||
public void init() throws javax.servlet.ServletException
|
||||
{
|
||||
try{
|
||||
Functions.initializeSecurityTracer();
|
||||
System.out.println("Inizializzazione GW eseguita!!!");
|
||||
}
|
||||
catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("Errore durante inizializzazione");
|
||||
System.out.println("#############################################");
|
||||
System.out.println("##### #####");
|
||||
System.out.println("##### Initializing Application FAILED #####");
|
||||
System.out.println("##### #####");
|
||||
System.out.println("##### Check configuration and RESTART #####");
|
||||
System.out.println("##### #####");
|
||||
System.out.println("#############################################");
|
||||
}
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
|
||||
throw new ServletException();
|
||||
}
|
||||
|
||||
}
|
||||
25
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/pipppppoo.shtml
Normal file
25
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/servlets/pipppppoo.shtml
Normal file
@@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
pipppppoo
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--form action="http://10.12.7.66:7001/receive" method="post"-->
|
||||
<!--form action="http://10.6.19.106:7200/receive" method="post"-->
|
||||
<!--form action="http://10.12.7.220:8080/receive" method="post"-->
|
||||
<form action="http://localhost:8080/receive" method="post">
|
||||
|
||||
<br>Filexml<br>
|
||||
<textarea name="filexml" cols="50" rows="20"></textarea><br>
|
||||
<!--input type="textbox" name="filexml" value=''-->
|
||||
<br>Nome file<br>
|
||||
<input type="text" name="filename" value="OPIV20020624120600TIMG02030"><br>
|
||||
<br>Tipo file<br>
|
||||
<input type="text" name="tipofile" value="1"><br>
|
||||
<input type="submit"><br>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
package mnp.utility;
|
||||
|
||||
public class ApplicationCostants {
|
||||
|
||||
private ApplicationCostants() {
|
||||
}
|
||||
//nome dei parametri della request sulla richiesta di upload
|
||||
//che riceviamo dagli altri OLO
|
||||
public static final String REQUEST_OLO_MITTENTE = "Operatore";
|
||||
public static final String REQUEST_TIPO_FILE = "TipoFile";
|
||||
public static final String REQUEST_FILE_NAME = "FileName";
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package mnp.utility;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public final class CustomSSLSocketFactory
|
||||
extends SSLSocketFactory {
|
||||
|
||||
//The original socket factory without any timeouts set for the sockets.
|
||||
private SSLSocketFactory originalFactory;
|
||||
|
||||
//the time in milliseconds after which, socket should timeout.
|
||||
private int socketTimeout;
|
||||
|
||||
/**
|
||||
* Constructor : set the socket factory and timeout
|
||||
* period.
|
||||
*/
|
||||
public CustomSSLSocketFactory(SSLSocketFactory originalFactory, int timeout) {
|
||||
super();
|
||||
|
||||
this.originalFactory = originalFactory;
|
||||
socketTimeout = timeout;
|
||||
}
|
||||
|
||||
/*****Override the original methods to include the timeouts for sockets*****/
|
||||
|
||||
public String[] getDefaultCipherSuites() {
|
||||
return originalFactory.getDefaultCipherSuites();
|
||||
}
|
||||
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return originalFactory.getSupportedCipherSuites();
|
||||
}
|
||||
|
||||
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
|
||||
|
||||
Socket socket = originalFactory.createSocket(s, host, port, autoClose);
|
||||
socket.setSoTimeout(socketTimeout);
|
||||
return socket;
|
||||
}
|
||||
|
||||
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
|
||||
Socket socket = originalFactory.createSocket(host, port);
|
||||
socket.setSoTimeout(socketTimeout);
|
||||
return socket;
|
||||
}
|
||||
|
||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException {
|
||||
|
||||
Socket socket = originalFactory.createSocket(host, port, localHost, localPort);
|
||||
socket.setSoTimeout(socketTimeout);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
public Socket createSocket(InetAddress host, int port) throws IOException {
|
||||
|
||||
Socket socket = originalFactory.createSocket(host, port);
|
||||
socket.setSoTimeout(socketTimeout);
|
||||
return socket;
|
||||
}
|
||||
|
||||
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
|
||||
|
||||
Socket socket = originalFactory.createSocket(address, port, localAddress, localPort);
|
||||
socket.setSoTimeout(socketTimeout);
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
||||
186
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/FEServiceLocator.java
Normal file
186
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/FEServiceLocator.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package mnp.utility;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import javax.ejb.EJBHome;
|
||||
import javax.ejb.EJBLocalHome;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
import javax.sql.DataSource;
|
||||
import javax.mail.Session;
|
||||
import java.util.Properties;
|
||||
import javax.naming.*;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2007</p>
|
||||
* <p>Company: </p>
|
||||
* @author poccia carlo
|
||||
* @version 1.0
|
||||
* @version 2.0 C09_2017 RU_517 line 178 (Privacy Violation)
|
||||
*/
|
||||
public class FEServiceLocator {
|
||||
|
||||
private InitialContext ic;
|
||||
|
||||
public FEServiceLocator() throws Exception {
|
||||
try {
|
||||
ic = getInitialContext();
|
||||
}
|
||||
catch (NamingException ne) {
|
||||
throw new RuntimeException(ne);
|
||||
}
|
||||
}
|
||||
|
||||
private Object lookup(String jndiName) throws NamingException {
|
||||
return ic.lookup(jndiName);
|
||||
}
|
||||
|
||||
/**
|
||||
* will get the ejb Local home factory.
|
||||
* clients need to cast to the type of EJBHome they desire
|
||||
*
|
||||
* @return the Local EJB Home corresponding to the homeName
|
||||
*/
|
||||
public EJBLocalHome getLocalHome(String jndiHomeName) throws NamingException {
|
||||
return (EJBLocalHome) lookup(jndiHomeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* will get the ejb Remote home factory.
|
||||
* clients need to cast to the type of EJBHome they desire
|
||||
*
|
||||
* @return the EJB Home corresponding to the homeName
|
||||
*/
|
||||
public EJBHome getRemoteHome(String jndiHomeName, Class className) throws
|
||||
NamingException {
|
||||
Object objref = lookup(jndiHomeName);
|
||||
return (EJBHome) PortableRemoteObject.narrow(objref, className);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method helps in obtaining the jms connection factory
|
||||
* @return the factory for obtaining jms connection
|
||||
*/
|
||||
public ConnectionFactory getConnectionFactory(String connFactoryName) throws
|
||||
NamingException {
|
||||
return (ConnectionFactory) lookup(connFactoryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method obtains the topc itself for a caller
|
||||
* @return the Topic Destination to send messages to
|
||||
*/
|
||||
public Destination getDestination(String destName) throws NamingException {
|
||||
return (Destination) lookup(destName);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method obtains the datasource itself for a caller
|
||||
* @return the DataSource corresponding to the name parameter
|
||||
*/
|
||||
public DataSource getDataSource(String dataSourceName) throws NamingException {
|
||||
return (DataSource) lookup(dataSourceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method obtains the E-mail session itself for a caller
|
||||
* @return the Session corresponding to the name parameter
|
||||
*/
|
||||
public Session getSession(String sessionName) throws NamingException {
|
||||
return (Session) lookup(sessionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the URL value corresponding
|
||||
* to the env entry name.
|
||||
*/
|
||||
public URL getUrl(String envName) throws NamingException {
|
||||
return (URL) lookup(envName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the boolean value corresponding
|
||||
* to the env entry
|
||||
*/
|
||||
public boolean getBoolean(String envName) throws NamingException {
|
||||
Boolean bool = (Boolean) lookup(envName);
|
||||
return bool.booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the String value corresponding
|
||||
* to the env entry name.
|
||||
*/
|
||||
public String getString(String envName) throws NamingException {
|
||||
return (String) lookup(envName);
|
||||
}
|
||||
|
||||
/**
|
||||
* finalize
|
||||
*
|
||||
* @throws Throwable
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
closeAll();
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
if (ic != null) {
|
||||
try {
|
||||
ic.close();
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il contesto
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private InitialContext getInitialContext() throws Exception {
|
||||
|
||||
String user = "";
|
||||
String password = "";
|
||||
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
properties.put(Context.INITIAL_CONTEXT_FACTORY,
|
||||
Resources.getFEWLServerContextFactory());
|
||||
System.out.println("Context.INITIAL_CONTEXT_FACTORY: "+Resources.getFEWLServerContextFactory());
|
||||
properties.put(Context.PROVIDER_URL, Resources.getFEWLServerUrl());
|
||||
System.out.println("Context.PROVIDER_URL: "+Resources.getFEWLServerUrl());
|
||||
user = Resources.getFEWLServerUser();
|
||||
password = Resources.getFEWLServerPwd();
|
||||
|
||||
if ( (user != null) && (!user.equals(""))) {
|
||||
properties.put(Context.SECURITY_PRINCIPAL, user);
|
||||
properties.put(Context.SECURITY_CREDENTIALS,
|
||||
password == null ? "" : password);
|
||||
}
|
||||
return new InitialContext(properties);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("I parametri di configurazione del Context sono : \n");
|
||||
System.out.println("context.factory : [" +
|
||||
Resources.getFEWLServerContextFactory() + "]");
|
||||
System.out.println("url : [" + Resources.getFEWLServerUrl() + "]");
|
||||
System.out.println("user [" + user + "]");
|
||||
// C09_2017 RU_517 BEGIN
|
||||
System.out.println("password [n/a] removed from logs as of C09_2017 RU_517 Fortify Privacy Violation ");
|
||||
//System.out.println("password [" +password+"]");
|
||||
// C09_2017 RU_517 END
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
193
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/Functions.java
Normal file
193
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/Functions.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package mnp.utility;
|
||||
|
||||
|
||||
import it.valueteam.logging.Tracer;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Classe con funzioni varie
|
||||
* @version 2.0 C09_2017 RU_517 line 134 (Unreleased Resource: Streams)
|
||||
*
|
||||
*/
|
||||
public class Functions
|
||||
{
|
||||
|
||||
/**
|
||||
* Elimino codici strani dall'XML
|
||||
* */
|
||||
public static String parseClear(String s) {
|
||||
StringBuffer appo = new StringBuffer("");
|
||||
for(int i=0; i<s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
String str = String.valueOf(c);
|
||||
|
||||
if( !str.equals("\n") &&
|
||||
!str.equals("\t") &&
|
||||
!str.equals("\r")
|
||||
) {
|
||||
appo.append(str);
|
||||
}
|
||||
}
|
||||
return appo.toString();
|
||||
}
|
||||
|
||||
|
||||
// ritorna la stringa corrispondente alla String s, secondo HTTP
|
||||
public static String ParamString(String s)
|
||||
{
|
||||
Hashtable H=loadParamHT();
|
||||
return sostituteChars(s,H);
|
||||
}
|
||||
|
||||
// ritorna la stringa corrispondente alla String s, secondo HTML
|
||||
public static String HtmlString(String s)
|
||||
{
|
||||
Hashtable H=loadHtmlHT();
|
||||
return sostituteChars(s,H);
|
||||
}
|
||||
|
||||
// ritorna la stringa corrispondente alla String s, secondo XML
|
||||
public static String xmlString(String s)
|
||||
{
|
||||
Hashtable H=loadHtmlHT();
|
||||
boolean inTag = false;
|
||||
char openTag = '<';
|
||||
char closeTag = '>';
|
||||
|
||||
StringBuffer sb=new StringBuffer (s);
|
||||
for(int i=0;i<sb.length();i++)
|
||||
{
|
||||
char c = sb.charAt(i);
|
||||
|
||||
if( c==openTag )
|
||||
inTag = true;
|
||||
|
||||
Character chara = new Character(c);
|
||||
if(!inTag && H.containsKey(chara))
|
||||
{
|
||||
sb.deleteCharAt(i);
|
||||
String sost=(String)H.get(chara);
|
||||
sb.insert( i,sost );
|
||||
i+=(sost.length()-1);
|
||||
}
|
||||
if( inTag && c==closeTag )
|
||||
inTag = false;
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// funzione standard di sostituzione caratteri a String s secondo l'Hashtable H
|
||||
static String sostituteChars(String s,Hashtable H)
|
||||
{
|
||||
StringBuffer sb=new StringBuffer (s);
|
||||
for(int i=0;i<sb.length();i++)
|
||||
{
|
||||
Character c=new Character(sb.charAt(i));
|
||||
if(H.containsKey(c))
|
||||
{
|
||||
sb.deleteCharAt(i);
|
||||
String sost=(String)H.get(c);
|
||||
sb.insert( i,sost );
|
||||
i+=(sost.length()-1);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// restituisce l' Hashtable cotenente i caratteri non ammessi come chiavi e la stringa equivalente in HTTP come elemento
|
||||
private static Hashtable loadParamHT()
|
||||
{
|
||||
Hashtable h=new Hashtable();
|
||||
//h.put(new Character(' '), "%20");h.put(new Character('\n'), "%0D");h.put(new Character('!'), "%21");h.put(new Character((char)34), "%22");// " doppio apiceh.put(new Character((char)92), "%5C");// \ backslashh.put(new Character('#'), "%23");h.put(new Character('&'), "%26");h.put(new Character('*'), "%2A");h.put(new Character((char)39), "%27");// ' apiceh.put(new Character('%'), "%25");h.put(new Character('`'), "%60");h.put(new Character('/'), "%2F");h.put(new Character('>'), "%3E");h.put(new Character('<'), "%3C");h.put(new Character('?'), "%3F");h.put(new Character('='), "%3D");h.put(new Character('-'), "%2D");h.put(new Character('@'), "%40");
|
||||
for (int i=0;i<256;i++)
|
||||
{
|
||||
if(i==32) {
|
||||
}
|
||||
if(!(i>47&&i<58 || i>64&&i<91 || i>96 && i<123) && (i!=10)) h.put(new Character((char)i), "%"+Integer.toHexString(i) );
|
||||
|
||||
}
|
||||
return h;
|
||||
}
|
||||
// restituisce l' Hashtable cotenente i caratteri non ammessi come chiavi e la stringa equivalente in HTML come elemento
|
||||
private static Hashtable loadHtmlHT()
|
||||
{
|
||||
Hashtable h=new Hashtable();
|
||||
h.put(new Character('&'),"&" );
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copia un file in un altro
|
||||
* */
|
||||
public static void copyFile(File in, File out) throws Exception {
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
|
||||
try {
|
||||
fis = new FileInputStream(in);
|
||||
fos = new FileOutputStream(out);
|
||||
byte[] buf = new byte[1024];
|
||||
int i = 0;
|
||||
while ( (i = fis.read(buf)) != -1) {
|
||||
fos.write(buf, 0, i);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Closing when previously closed will have no effect;
|
||||
if(null != fis) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
fis = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
if(null != fos) {
|
||||
try {
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
fos = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializeSecurityTracer() {
|
||||
try {
|
||||
System.out.println("configuring security log");
|
||||
Properties pLog = new Properties();
|
||||
Properties pLog1 = new Properties();
|
||||
pLog.put("tracciamento.dir",Resources.getTRACCIAMENTO_DIR());
|
||||
pLog.put("tracciamento.fileName",Resources.getTRACCIAMENTO_FILENAME());
|
||||
pLog.put("tracciamento.pattern",Resources.getTRACCIAMENTO_PATTERN());
|
||||
/** Begin Log4j base */
|
||||
pLog1.put("log4j.logger.org.apache", Resources.getLOGGER_LEVEL_AND_APPENDER_NAME());
|
||||
pLog1.put("log4j.appender.stdout", Resources.getAPPENDER());
|
||||
pLog1.put("log4j.appender.stdout.layout", Resources.getLAYOUT());
|
||||
pLog1.put("log4j.appender.stdout.layout.ConversionPattern", Resources.getCONVERSION_PATTERN());
|
||||
/** End Log4j base*/
|
||||
SecurityLogLoader actionLogMapping = new SecurityLogLoader();
|
||||
Hashtable h = actionLogMapping.getActionMap();
|
||||
Hashtable hh = actionLogMapping.getRetCodeMap();
|
||||
Tracer.configure(pLog,pLog1,h,hh);
|
||||
System.out.println(" security log configured");
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Errore nell'inizializzazione del tracer");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,554 @@
|
||||
package mnp.utility;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import mnp.log.LoggableFE;
|
||||
import mnp.log.ProcessLoggerFE;
|
||||
import mnp.objects.LogInfoFE;
|
||||
import mnp.objects.LogProcessFE;
|
||||
|
||||
|
||||
public class OLOComunicationManager implements LoggableFE{
|
||||
|
||||
|
||||
private static boolean httpsFlag;
|
||||
private static boolean sslFlag;
|
||||
private static final String BOUNDARY = "--MNP_BOUNDARY_FOR_MULTIPART";
|
||||
private static int timeout = 0;
|
||||
|
||||
protected String versione = "1.4.0.1";
|
||||
protected String codiceProcesso = "PC"; // codice processo?
|
||||
private ProcessLoggerFE log = null;
|
||||
static {
|
||||
try {
|
||||
//parametri per i test
|
||||
httpsFlag = Resources.getExternalHttpsFlag();
|
||||
sslFlag = Resources.getExternalSslFlag();
|
||||
timeout = Resources.getHttpTimeOut();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println(
|
||||
"Impossibile inizializzare OLOComunicationManager.....Controllare proprietà!!!!!!!!!!!!!");
|
||||
}
|
||||
}
|
||||
|
||||
public OLOComunicationManager() throws Exception {
|
||||
try {
|
||||
LogProcessFE logProcessFE = new LogProcessFE();
|
||||
logProcessFE.setCodice(codiceProcesso);
|
||||
logProcessFE.setProcess(this);
|
||||
log = new ProcessLoggerFE(logProcessFE);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Errore nella creazione del LogProcessFE");
|
||||
throw new Exception("Errore nella creazione del LogProcessFE");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Effettua l'invio del file verso un olo tramite form/multipart
|
||||
* @param: content il contenuto del file dainviare
|
||||
* @param: tipofile la tipologia di file da inviare (N,R)
|
||||
* @param: filename nome del file da inviare
|
||||
* @param: codOlo codice OLo donating destinatario del file
|
||||
*/
|
||||
public String sendFileMultipart(String filename,
|
||||
String tipofile, String codOlo,
|
||||
String content,String address) throws
|
||||
Exception {
|
||||
|
||||
|
||||
|
||||
|
||||
String response = null;
|
||||
OutputStreamWriter wout = null;
|
||||
java.net.HttpURLConnection connection = null;
|
||||
String responseMSG = null;
|
||||
InputStream win = null;
|
||||
ByteArrayOutputStream requestStream = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
//INIZIO TRATTAMENTO MESSAGGIO - VERSIONE
|
||||
log.write("0001",versione);
|
||||
|
||||
System.out.println("Parametri con cui costruire la REQUEST:\n");
|
||||
System.out.println(ApplicationCostants.REQUEST_TIPO_FILE + tipofile + ":\n");
|
||||
System.out.println(ApplicationCostants.REQUEST_OLO_MITTENTE + codOlo +
|
||||
":\n");
|
||||
System.out.println(ApplicationCostants.REQUEST_FILE_NAME + filename +
|
||||
":\n");
|
||||
|
||||
|
||||
|
||||
connection = getHttpConnection(createAddresWithParameter(address, codOlo, tipofile, filename));
|
||||
|
||||
connection.setRequestProperty("Content-type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY);
|
||||
connection.setRequestProperty("Accept", "*/*");
|
||||
connection.setRequestProperty("Connection", "Keep-Alive");
|
||||
connection.setRequestProperty("Cache-Control", "no-cache");
|
||||
|
||||
|
||||
requestStream.write(new String("--"+BOUNDARY+"\r\n").getBytes());
|
||||
|
||||
writeParamValue(requestStream,ApplicationCostants.REQUEST_TIPO_FILE , tipofile);
|
||||
writeParamValue(requestStream, ApplicationCostants.REQUEST_OLO_MITTENTE, codOlo);
|
||||
writeParamValue(requestStream, ApplicationCostants.REQUEST_FILE_NAME, filename);
|
||||
writeFileValue(requestStream, filename, content);
|
||||
|
||||
System.out.println("La mia REQUEST multipart:\n"+ requestStream.toString());
|
||||
wout = new OutputStreamWriter(connection.getOutputStream());
|
||||
wout.write(requestStream.toString());
|
||||
wout.write("\r\n");
|
||||
wout.flush();
|
||||
|
||||
response = connection.getResponseMessage();
|
||||
if (response == null || !response.equalsIgnoreCase("OK")) {
|
||||
throw new IOException("Errore sulla risposta da OLO,response: "+response);
|
||||
}
|
||||
|
||||
win = connection.getInputStream();
|
||||
|
||||
int b = 0;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
while ((b=win.read())!=-1) {
|
||||
baos.write(b);
|
||||
}
|
||||
responseMSG = new String(baos.toByteArray());
|
||||
baos.close();
|
||||
responseMSG = URLDecoder.decode(responseMSG,"UTF-8");
|
||||
//FINE TRATTAMENTO MESSAGGIO
|
||||
log.write("0002","");
|
||||
System.out.println("responseMSG:"+responseMSG);
|
||||
}
|
||||
catch (java.io.InterruptedIOException tex) {
|
||||
tex.printStackTrace();
|
||||
log.write("9999", "Timeout nella connessione con:"+codOlo);
|
||||
//FINE TRATTAMENTO MESSAGGIO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
// TimeOut nella connessione
|
||||
throw new InterruptedIOException("Timeout nella connessione: " +
|
||||
tex.getMessage());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
int responseCode = connection.getResponseCode();
|
||||
log.write("9999", "responseCode:" + responseCode);
|
||||
//FINE TRATTAMENTO MESSAGGIO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
if (responseCode == java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT) {
|
||||
// TimeOut nella connessione FE - OLO
|
||||
throw new InterruptedIOException(
|
||||
"Timeout nella connessione con OLO:" + codOlo);
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//FINE TRATTAMENTO MESSAGGIO CON ECCEZIONI
|
||||
log.write("0003","");
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
log.write("9999", "Problemi nell'invio del file all'OLO: " + t.getMessage());
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
finally {
|
||||
try {
|
||||
requestStream.close();
|
||||
} catch (Exception ex2) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
try {
|
||||
wout.close();
|
||||
}
|
||||
catch (Exception ex2) {
|
||||
//nothing to do
|
||||
}
|
||||
try {
|
||||
win.close();
|
||||
}
|
||||
catch (Exception ex2) {
|
||||
//nothing to do
|
||||
}
|
||||
try {
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
//nothing to do
|
||||
}
|
||||
}
|
||||
return responseMSG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setta il valore di un aparametro all'interno di una form multipart
|
||||
* @param: out: outputstream della connection
|
||||
* @param: name: nome del parametro da settare nel form
|
||||
* @param: value: valore del parametro da settare nel form
|
||||
*/
|
||||
private static void writeParamValue(ByteArrayOutputStream out, String name,
|
||||
String value) throws
|
||||
IOException {
|
||||
//out.write(BOUNDARY);
|
||||
out.write(new String("Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n").getBytes());
|
||||
//out.write("Content-Type: text/plain;charset=utf-8");
|
||||
out.write(value.getBytes());
|
||||
out.write(new String("\r\n").getBytes());
|
||||
out.write(new String("--"+BOUNDARY+"\r\n").getBytes());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setta il nome e il contenuto del file all'interno di una form multipart
|
||||
* @param: out: outputstream della connection
|
||||
* @param: name: nome del file da inviare nel form
|
||||
* @param: content: contenuto del file da invare nel form
|
||||
*/
|
||||
|
||||
|
||||
private static void writeFileValue(ByteArrayOutputStream out, String name,
|
||||
String content) throws
|
||||
IOException {
|
||||
//out.write(new String("--"+BOUNDARY+"\r\n").getBytes());
|
||||
out.write(new String("Content-Disposition: form-data; name=\"myprovafile\"; filename=\"" + name + "\"").
|
||||
getBytes());
|
||||
out.write("\r\nContent-Type: text/xml\r\n".getBytes());
|
||||
out.write(new String("\r\n"+content).getBytes());
|
||||
out.write(new String("\r\n--" + BOUNDARY + "--\r\n").getBytes());
|
||||
}
|
||||
|
||||
|
||||
private static String encode(String value) {
|
||||
if (value == null || value.trim().length() == 0)return value;
|
||||
StringBuffer newValue = new StringBuffer(value.length());
|
||||
char[] chars = value.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (chars[i] == '\\') {
|
||||
newValue.append("\\\\");
|
||||
if (chars[i] == '\\') {
|
||||
newValue.append("\\\\");
|
||||
}
|
||||
else {
|
||||
newValue.append(chars[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newValue.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo aggiunto per nuovi log Governance
|
||||
**/
|
||||
public LogInfoFE getLogInfo() throws Exception{
|
||||
LogInfoFE logInfoFE = new LogInfoFE();
|
||||
logInfoFE.setLogPath(Resources.getLogPath());
|
||||
logInfoFE.setProcess(getClass().getName());
|
||||
return(logInfoFE);
|
||||
}
|
||||
|
||||
/*invio i file o almeno ci provo da FE a BE, nel caso in cui non riesco a mandare i file
|
||||
vado a salvarli su un file system ritornando con un exception*/
|
||||
private final java.net.HttpURLConnection getHttpConnection(String
|
||||
address) throws Exception {
|
||||
log.write("9999", "INDIRIZZO DELL'OLO DA CHIAMARE : " + address);
|
||||
System.out.println("URL dell'OLO da chiamare: "+address);
|
||||
URL wlsUrl = null;
|
||||
java.net.HttpURLConnection connection = null;
|
||||
log.write("9999", "address:" + address);
|
||||
try {
|
||||
//HTTPS:
|
||||
if (sslFlag) {
|
||||
try {
|
||||
wlsUrl = new URL(new URL(address), address,
|
||||
new com.ibm.net.ssl.internal.www.protocol.https.
|
||||
Handler());
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
// C - ERRORE NELLA URL DELL'OLO
|
||||
//todo
|
||||
log.write("0081", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// Caricamento Certificati
|
||||
if (sslFlag) {
|
||||
FileInputStream fis = null;
|
||||
FileInputStream fist = null;
|
||||
try {
|
||||
log.write("9999", "Inizio caricamento certificati per SSL");
|
||||
String keystore = Resources.getKeyStore();
|
||||
String truststore = Resources.getTrustKeyStore();
|
||||
String keypwd = Resources.getPrivateKeyAliasPwd();
|
||||
String IBMJSSEProvider = "IBMJSSE2";
|
||||
//manager del keystore della Private Key
|
||||
String alg = KeyManagerFactory.getDefaultAlgorithm();
|
||||
KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg,
|
||||
IBMJSSEProvider); //<-- il provider!
|
||||
fis = new FileInputStream(keystore);
|
||||
KeyStore ks = KeyStore.getInstance("jks");
|
||||
ks.load(fis, null);
|
||||
fis.close();
|
||||
kmFact.init(ks, keypwd.toCharArray());
|
||||
KeyManager[] kms = kmFact.getKeyManagers();
|
||||
|
||||
//manager del keystore delle CA
|
||||
String algt = TrustManagerFactory.getDefaultAlgorithm();
|
||||
TrustManagerFactory tmFact = TrustManagerFactory.getInstance(algt,
|
||||
IBMJSSEProvider); //<-- il provider!
|
||||
fist = new FileInputStream(truststore);
|
||||
KeyStore kst = KeyStore.getInstance("jks");
|
||||
kst.load(fist, null);
|
||||
fist.close();
|
||||
tmFact.init(kst);
|
||||
TrustManager[] tms = tmFact.getTrustManagers();
|
||||
|
||||
//creazione del context SSL
|
||||
SSLContext sslContext;
|
||||
sslContext = SSLContext.getInstance("SSL_TLS", IBMJSSEProvider);
|
||||
sslContext.init(kms, tms, null);
|
||||
|
||||
//open connection
|
||||
connection = (com.ibm.net.ssl.internal.www.protocol.https.
|
||||
HttpsURLConnection) wlsUrl.openConnection();
|
||||
|
||||
//set del Socket Factory alla connessione https
|
||||
SSLSocketFactory factory = sslContext.getSocketFactory();
|
||||
|
||||
com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection
|
||||
appoConnection =
|
||||
(com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection)
|
||||
connection;
|
||||
// Setto il timeout della connessione
|
||||
CustomSSLSocketFactory csf = new CustomSSLSocketFactory(factory,
|
||||
timeout);
|
||||
appoConnection.setSSLSocketFactory(csf);
|
||||
appoConnection.setDefaultSSLSocketFactory(csf);
|
||||
log.write("9999", "Caricamento certificati per SSL completato");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// C - ERRORE NEL CARICAMENTO DEI CERTIFICATI
|
||||
//todo
|
||||
log.write("0082", "");
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Closing when previously closed will have no effect;
|
||||
if(null != fis) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
fis = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
if(null != fist) {
|
||||
try {
|
||||
fist.close();
|
||||
} catch (Exception e) {
|
||||
fist = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
}
|
||||
}
|
||||
//HTTP:
|
||||
else {
|
||||
try {
|
||||
wlsUrl = new URL(address);
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
// C - ERRORE NELLA URL DELL'OLO
|
||||
log.write("0081", " " + address);
|
||||
throw ex;
|
||||
}
|
||||
log.write("9999", "wlsUrl " + wlsUrl);
|
||||
int timeout = Resources.getHttpTimeOut();
|
||||
|
||||
if (httpsFlag) {
|
||||
System.setProperty("java.protocol.handler.pkgs", "weblogic.net");
|
||||
connection = new weblogic.net.http.HttpsURLConnection(wlsUrl);
|
||||
}
|
||||
else {
|
||||
connection = new weblogic.net.http.HttpURLConnection(wlsUrl);
|
||||
}
|
||||
|
||||
( (weblogic.net.http.HttpURLConnection) connection).setTimeout(timeout);
|
||||
connection.connect();
|
||||
}
|
||||
// Set request method
|
||||
connection.setRequestMethod("POST");
|
||||
// Apertura canali e scrittura file
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
|
||||
return connection;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private String createAddresWithParameter(String addr, String olo, String tipoFile, String fileName) {
|
||||
StringBuffer buffer = new StringBuffer(addr + "?");
|
||||
buffer.append(ApplicationCostants.REQUEST_OLO_MITTENTE).append("=").append(olo).append("&");
|
||||
buffer.append(ApplicationCostants.REQUEST_TIPO_FILE).append("=").append(tipoFile).append("&");
|
||||
buffer.append(ApplicationCostants.REQUEST_FILE_NAME).append("=").append(fileName);
|
||||
return buffer.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Effettua l'invio del file verso un olo utilizzando le stesse modalità di DBC
|
||||
// * @param: filexml il contenuto del file dainviare
|
||||
// * @param: tipofile la tipologia di file da inviare (N,R)
|
||||
// * @param: filename nome del file da inviare
|
||||
// * @param: codOlo codice OLo donating destinatario del file
|
||||
// */
|
||||
// public static final void sendFileAsParameter(String filexml,
|
||||
// String tipofile,
|
||||
// String filename,
|
||||
// String codOlo) throws
|
||||
// Exception {
|
||||
// String response = null;
|
||||
//
|
||||
// System.out.println("Sending: " + filename + " to FE....");
|
||||
//
|
||||
// // CODIFICA: (1° step): Sostituzione caratteri non ammessi con XML
|
||||
// filexml = XmlUtility.xmlString(filexml);
|
||||
// String test = "\n******* CODIFICA: (1° step:XML)\nfilexml=" + filexml +
|
||||
// "&filename=" + filename + "&tipofile=" + tipofile +
|
||||
// "&codOlo=" + codOlo;
|
||||
//
|
||||
// // CODIFICA: (2° step): Codifica per HTML
|
||||
// filexml = URLEncoder.encode(filexml, "UTF-8");
|
||||
// test = "\n******* CODIFICA: (2° step:HTTP)\nfilexml=" + filexml +
|
||||
// "&filename=" + filename + "&tipofile=" + tipofile + "&codOlo=" +
|
||||
// codOlo;
|
||||
//
|
||||
// String query = "filexml=" + filexml + "&filename=" + filename +
|
||||
// "&tipofile=" + tipofile + "&codOlo=" + codOlo;
|
||||
//
|
||||
// OutputStreamWriter wout = null;
|
||||
//
|
||||
// System.out.println("Sending: " + filename +
|
||||
// " to FE... DONE, with response: " + response);
|
||||
//
|
||||
// weblogic.net.http.HttpURLConnection connection = null;
|
||||
//
|
||||
// try {
|
||||
// connection = getHttpConnection();
|
||||
// connection.connect();
|
||||
// wout = new OutputStreamWriter(connection.getOutputStream());
|
||||
// //wout.write(query);
|
||||
// wout.flush();
|
||||
// response = connection.getResponseMessage();
|
||||
// }
|
||||
// catch (java.io.InterruptedIOException tex) {
|
||||
// // TimeOut nella connessione BE - FE
|
||||
// throw new InterruptedIOException(
|
||||
// "Timeout nella connessione con il Front-end");
|
||||
// }
|
||||
// catch (IOException ex) {
|
||||
// int responseCode = connection.getResponseCode();
|
||||
// if (responseCode == java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT) {
|
||||
// // TimeOut nella connessione FE - AOM
|
||||
// throw new InterruptedIOException(
|
||||
// "Timeout nella connessione fra Front-End e AOM");
|
||||
// }
|
||||
// else {
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
// finally {
|
||||
// connection.disconnect();
|
||||
// }
|
||||
// if (response == null || !response.equalsIgnoreCase("OK")) {
|
||||
// throw new Exception("Bad Response");
|
||||
// }
|
||||
// wout.close();
|
||||
//
|
||||
// }
|
||||
|
||||
//
|
||||
//
|
||||
// protected static final weblogic.net.http.HttpURLConnection
|
||||
// getHttpConnection() throws Exception {
|
||||
//
|
||||
//
|
||||
// weblogic.net.http.HttpURLConnection connection = null;
|
||||
//
|
||||
// if (httpsFlag) {
|
||||
// System.setProperty("java.protocol.handler.pkgs", "weblogic.net");
|
||||
// connection = new weblogic.net.http.HttpsURLConnection(sendServ);
|
||||
// }
|
||||
// else {
|
||||
// connection = new weblogic.net.http.HttpURLConnection(sendServ);
|
||||
// }
|
||||
//
|
||||
// // Caricamento Certificati
|
||||
// if (httpsFlag && sslFlag) {
|
||||
// try {
|
||||
// KeyStore ks = KeyStore.getInstance("jks");
|
||||
// ks.load(new FileInputStream(Resources.getKeyStore()), null);
|
||||
// PrivateKey key = (PrivateKey) ks.getKey(Resources.
|
||||
// getPrivateKeyAlias(),
|
||||
// Resources.getPrivateKeyAliasPwd().
|
||||
// toCharArray());
|
||||
// Certificate[] certChain = ks.getCertificateChain(Resources.
|
||||
// getPrivateKeyAlias());
|
||||
// ( (weblogic.net.http.HttpsURLConnection) connection).
|
||||
// loadLocalIdentity(certChain, key);
|
||||
// System.out.println("Caricamento certificati per SSL completato");
|
||||
// }
|
||||
// catch (IOException ex) {
|
||||
// System.out.println("ERRORE caricamento certificati per SSL");
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //set timeout
|
||||
// connection.setTimeout(timeout);
|
||||
//
|
||||
// // Set request method
|
||||
// connection.setRequestMethod("POST");
|
||||
// //connection.setRequestProperty("content", "xml");
|
||||
//
|
||||
// // Apertura canali e scrittura file
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
// try {
|
||||
//
|
||||
// connection.connect();
|
||||
// }
|
||||
// catch (java.io.InterruptedIOException tex) {
|
||||
// // TimeOut nella connessione BE - FE
|
||||
// throw new InterruptedIOException(
|
||||
// "Timeout nella connessione con il Front-end");
|
||||
// }
|
||||
// catch (IOException ex) {
|
||||
// int responseCode = connection.getResponseCode();
|
||||
// if (responseCode ==
|
||||
// java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT) {
|
||||
// // TimeOut nella connessione FE - AOM
|
||||
// throw new InterruptedIOException(
|
||||
// "Timeout nella connessione fra Front-End e AOM");
|
||||
// }
|
||||
// else {
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
505
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/Resources.java
Normal file
505
dbcmnpsrc/GW/mnpdev/mnpgw/src/mnp/utility/Resources.java
Normal file
@@ -0,0 +1,505 @@
|
||||
package mnp.utility;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.securityutility.*;
|
||||
|
||||
/**
|
||||
* Title: MNP Project
|
||||
* Des cription: Mobile Number Portability
|
||||
* Copyright: Copyright (c) 2002
|
||||
* Company: Siemens
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0 (Modifica File di Properties 28/08/2002)
|
||||
* @version 2.0 (11/11/2002): Aggiunte proprietà: CCRM_NOTIF_VALID_PREFIX_OUT, PATH_CCRM_OUT
|
||||
*/
|
||||
|
||||
public class Resources {
|
||||
private static Properties props = null;
|
||||
|
||||
private static String propertiesPath = null;
|
||||
private static String hName=null;
|
||||
private static String hIP=null;
|
||||
static{
|
||||
init();
|
||||
}
|
||||
|
||||
private Resources() {
|
||||
}
|
||||
|
||||
private static void init(){
|
||||
Properties appProps = new Properties();
|
||||
FileInputStream fInput = null;
|
||||
|
||||
try {
|
||||
if (System.getProperty("mnpgw_path_properties") != null)
|
||||
propertiesPath=System.getProperty("mnpgw_path_properties");
|
||||
else
|
||||
propertiesPath= System.getProperty("mnp_path_properties");
|
||||
|
||||
System.out.println("Path delle Properties ottenuto: "+propertiesPath);
|
||||
fInput = new FileInputStream(propertiesPath);
|
||||
appProps.load(fInput);
|
||||
//decifro gli eventuali valore cifrati
|
||||
try {
|
||||
props = CryptoUtility.getInstance().getCleanProperties(appProps);
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
System.out.println("ERRORE nella creazione del properties crifrato");
|
||||
ex1.printStackTrace();
|
||||
fInput = new FileInputStream(propertiesPath);
|
||||
props=new Properties();
|
||||
props.load(fInput);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("ERRORE nella creazione del properties");
|
||||
}
|
||||
finally {
|
||||
if (fInput!=null)
|
||||
try {
|
||||
fInput.close();
|
||||
}
|
||||
catch (IOException ex1) {
|
||||
//niente da fare
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sezione certificati e SSL
|
||||
* */
|
||||
|
||||
public static String getKeyFile()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_KEY_FILE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getCertFile()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_CERT_FILE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getCaCertFile()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_CACERT_FILE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getKeyStore()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_KEYSTORE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getTrustKeyStore()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_TRUSTKEYSTORE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getPrivateKeyAlias()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("SSL_PRIVATEKEY_ALIAS"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getPrivateKeyAliasPwd()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("{3DES}SSL_PRIVATEKEY_ALIAS_PWD"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* CARLO 03-02-2003
|
||||
* aggiunto metodo Trim(String) richiemato da tutti i metodi
|
||||
* Se null->null altrimenti trimmo
|
||||
* */
|
||||
|
||||
private static final String Trim(String valore){
|
||||
if (valore!=null)
|
||||
return valore.trim();
|
||||
else return null;
|
||||
}
|
||||
//
|
||||
|
||||
public static String getHOSTPROXY()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("HOSTPROXY"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getPORTPROXY()
|
||||
{
|
||||
if (props==null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("PORTPROXY"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static boolean withProxy()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String hasProxy = Trim(props.getProperty("EnableProxy"));
|
||||
if ( hasProxy==null || hasProxy.equalsIgnoreCase("yes"))
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public static boolean withSSL()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String hasSSL = Trim(props.getProperty("EnableSSL"));
|
||||
if ( hasSSL==null || hasSSL.equalsIgnoreCase("yes") )
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public static boolean getInternalHttpsFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("INTERNAL_HTTPS_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getInternalSslFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("INTERNAL_SSL_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getInternalProxyFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("INTERNAL_PROXY_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getExternalHttpsFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("EXTERNAL_HTTPS_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getExternalSslFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("EXTERNAL_SSL_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getExternalProxyFlag()
|
||||
{
|
||||
if(props == null)
|
||||
init();
|
||||
|
||||
String s = Trim(props.getProperty("EXTERNAL_PROXY_FLAG"));
|
||||
if (s!=null && s.equalsIgnoreCase("true"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prende dal file di properties il path
|
||||
* del server dove salvare i file perchè non riesce a inviare
|
||||
* ossia il path assoluto.
|
||||
* Francesca 11/03/2003
|
||||
*/
|
||||
public static String getPathFileRinvio(){
|
||||
String sPathFileRinvio = null;
|
||||
if(props == null)
|
||||
init();
|
||||
sPathFileRinvio = Trim(props.getProperty("path_file_rinvio"));
|
||||
return sPathFileRinvio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prende dal file di properties il path
|
||||
* del server dove salvare i file perchè non riesce a inviare
|
||||
* ossia il path assoluto.
|
||||
* Francesca 11/03/2003
|
||||
*/
|
||||
public static String getPathFileRinvioWarning(){
|
||||
String sPathFileRinvioW = null;
|
||||
if(props == null)
|
||||
init();
|
||||
sPathFileRinvioW = Trim(props.getProperty("path_file_rinvio_warning"));
|
||||
return sPathFileRinvioW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prende dal file di properties il path
|
||||
* del destinatario per inviare i file
|
||||
* Francesca 14/03/2003
|
||||
*/
|
||||
public static String getInternalReceiverURL(){
|
||||
String sPathDest = null;
|
||||
if(props == null)
|
||||
init();
|
||||
sPathDest = Trim(props.getProperty("InternalReceiverURL"));
|
||||
return sPathDest;
|
||||
}
|
||||
|
||||
public static String getTestMode(){
|
||||
String testMode = null;
|
||||
if(props == null)
|
||||
init();
|
||||
testMode = Trim(props.getProperty("test"));
|
||||
return testMode;
|
||||
}
|
||||
|
||||
public static String getTestURL(){
|
||||
String testURL = null;
|
||||
if(props == null)
|
||||
init();
|
||||
testURL = Trim(props.getProperty("testURL"));
|
||||
return testURL;
|
||||
}
|
||||
|
||||
public static String getOloURL(String codOlo){
|
||||
String sPathOlo = null;
|
||||
if(props == null)
|
||||
init();
|
||||
sPathOlo = Trim(props.getProperty(codOlo.toLowerCase()));
|
||||
return sPathOlo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prende dal file di properties il path
|
||||
* del file XML che contiene i log
|
||||
* Ambra 12/08/2003
|
||||
*/
|
||||
public static String getPathFileXMLLOG(){
|
||||
String pathFileXMLLOG = null;
|
||||
if(props == null)
|
||||
init();
|
||||
pathFileXMLLOG = Trim(props.getProperty("path_file_XMLLOG"));
|
||||
return pathFileXMLLOG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce la stringa di info sul file di log in base al tipo di processo
|
||||
* @return Stringa path del log
|
||||
* Stefano
|
||||
*/
|
||||
public static String getLogPath(){
|
||||
String logPath = null;
|
||||
if(props == null)
|
||||
init();
|
||||
logPath = Trim(props.getProperty("LOG_PATH"));
|
||||
return logPath;
|
||||
}
|
||||
|
||||
public static int getHttpTimeOut() throws Exception{
|
||||
if( props == null )
|
||||
init();
|
||||
String app = Trim(props.getProperty("HTTP_TIMEOUT"));
|
||||
int ret = 0;
|
||||
try {
|
||||
ret = Integer.parseInt(app);
|
||||
//trasformo il dato in millesecondi
|
||||
ret = ret * 60000;
|
||||
}
|
||||
catch(Exception ex) {
|
||||
System.out.println("Proprieta' HTTP_TIMEOUT non presente");
|
||||
throw ex;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//log sicurezza
|
||||
/**
|
||||
*
|
||||
* @return String : il percorso del file XML contenente le operazioni e gli esiti
|
||||
*/
|
||||
public static String getXMLSecurityLogPathFile() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("XML_SECURITY_LOG_PATH"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return la directory nella quale scrivere il log di sicurezza
|
||||
*/
|
||||
public static String getTRACCIAMENTO_DIR() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("tracciamento.dir"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return il nome del file di log sicurezza
|
||||
*/
|
||||
public static String getTRACCIAMENTO_FILENAME() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("tracciamento.filename"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return il pattern da utilizzare per il log di sicurezza
|
||||
*/
|
||||
public static String getTRACCIAMENTO_PATTERN() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("tracciamento.pattern"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* getLOGGER_LEVEL_AND_APPENDER_NAME
|
||||
*/
|
||||
public static String getLOGGER_LEVEL_AND_APPENDER_NAME() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("log4j.logger.org.apache"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log4j base properties
|
||||
*/
|
||||
public static String getAPPENDER() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("log4j.appender.stdout"));
|
||||
}
|
||||
|
||||
public static String getLAYOUT() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("log4j.appender.stdout.layout"));
|
||||
}
|
||||
|
||||
public static String getCONVERSION_PATTERN() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("log4j.appender.stdout.layout.ConversionPattern"));
|
||||
}
|
||||
|
||||
/**
|
||||
* context factory x wls
|
||||
* @return String
|
||||
*/
|
||||
public static String getFEWLServerContextFactory() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("FE.WLSERVER.CONTEXT.FACTORY"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* url di connessione a dbc
|
||||
* @return String
|
||||
*/
|
||||
public static String getFEWLServerUrl() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("FE.WLSERVER.URL"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* username x utente
|
||||
* @return String
|
||||
*/
|
||||
public static String getFEWLServerUser() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("FE.WLSERVER.USER"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Password dell'utente
|
||||
* @return String
|
||||
*/
|
||||
public static String getFEWLServerPwd() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("{3DES}FE.WLSERVER.USER.PWD"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* JNDI NAME del servizio su FE
|
||||
* @return String
|
||||
*/
|
||||
public static String getFEPROXYJndiName() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("FE.FEPROXY.JNDI_NAME"));
|
||||
return ret;
|
||||
}
|
||||
public static String getHostName() throws UnknownHostException{
|
||||
|
||||
if(hName == null)
|
||||
hName=InetAddress.getLocalHost().getHostName();
|
||||
|
||||
return hName;
|
||||
}
|
||||
public static String getHostAddress() throws UnknownHostException{
|
||||
|
||||
if(hIP == null)
|
||||
hIP=InetAddress.getLocalHost().getHostAddress();
|
||||
|
||||
return hIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package mnp.utility;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import mnp.xml.logsicurezza.*;
|
||||
|
||||
import org.exolab.castor.xml.*;
|
||||
|
||||
public class SecurityLogLoader {
|
||||
|
||||
private Hashtable mappaAzione,mappaRetCode;
|
||||
|
||||
public SecurityLogLoader() throws Exception {
|
||||
// C09_2017 RU_517 line 21 (Unreleased Resource: Streams)
|
||||
FileReader frd = null;
|
||||
try {
|
||||
mappaAzione= new Hashtable();
|
||||
mappaRetCode=new Hashtable();
|
||||
String nomeFile = Resources.getXMLSecurityLogPathFile();
|
||||
frd = new FileReader(nomeFile);
|
||||
LISTA_LOG_SICUREZZA logList = (LISTA_LOG_SICUREZZA) Unmarshaller.
|
||||
unmarshal(LISTA_LOG_SICUREZZA.class, frd);
|
||||
LOG_ACTIONItem[] actionItems = ((LOG_ACTION)logList.getLOG_ACTION()).getLOG_ACTIONItem();
|
||||
LOG_RET_CODEItem[] retCodeItems = ((LOG_RET_CODE)logList.getLOG_RET_CODE()).getLOG_RET_CODEItem();
|
||||
for (int i = 0; i < actionItems.length; i++) {
|
||||
mappaAzione.put(new Integer( ((LOG_ACTION_ITEM)actionItems[i].getLOG_ACTION_ITEM()).getCODICE_LOG()),
|
||||
((LOG_ACTION_ITEM)actionItems[i].getLOG_ACTION_ITEM()).getDESCRIZIONE_LOG()
|
||||
);
|
||||
}
|
||||
for (int i = 0; i < retCodeItems.length; i++) {
|
||||
mappaRetCode.put( new Integer( ((LOG_RET_CODE_ITEM)retCodeItems[i].getLOG_RET_CODE_ITEM()).getVALORE()),
|
||||
((LOG_RET_CODE_ITEM)retCodeItems[i].getLOG_RET_CODE_ITEM()).getDESCRIZIONE()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
System.out.println(
|
||||
"Errore in lettura del file XML relativo alle Azioni del log di sicurezza");
|
||||
throw ex;
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
System.out.println("Errore di validazione");
|
||||
throw ex;
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
System.out.println("Errore marshall");
|
||||
throw ex;
|
||||
}
|
||||
// C09_2017 RU_517 BEGIN
|
||||
// Closing when previously closed will have no effect;
|
||||
finally {
|
||||
if(null != frd) {
|
||||
try {
|
||||
frd.close();
|
||||
} catch (Exception e) {
|
||||
frd = null;
|
||||
System.out.println("FAIL release stream: ["+e.getClass().getName()+"] - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// C09_2017 RU_517 END
|
||||
}
|
||||
|
||||
public Hashtable getActionMap() {
|
||||
return mappaAzione;
|
||||
}
|
||||
|
||||
public Hashtable getRetCodeMap() {
|
||||
return mappaRetCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package mnp.xml;
|
||||
|
||||
import xml.*;
|
||||
import xml.types.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author unascribed
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MyListaLogProcessiFE extends LISTA_LOG_PROCESSI_FE implements Serializable{
|
||||
|
||||
public MyListaLogProcessiFE() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il codice corrispondente al processo identificato dal nome passato
|
||||
* @param nomeProcesso Nome del processo
|
||||
* @return String Codice del processo
|
||||
*/
|
||||
public String getCODICE_PROCESSO(String nomeProcesso)
|
||||
{
|
||||
ANAGRAFICA_PROCESSO_FE[] anagProcSeq = getANAGRAFICA_PROCESSO_FE();
|
||||
int i = 0;
|
||||
boolean trovato = false;
|
||||
String codiceProcesso = null;
|
||||
while (i<=anagProcSeq.length && trovato==false) {
|
||||
if(anagProcSeq[i].getNOME_PROCESSO().equalsIgnoreCase(nomeProcesso)){
|
||||
codiceProcesso = anagProcSeq[i].getCODICE_PROCESSO();
|
||||
trovato = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return codiceProcesso;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dato il codice del processo restituisce l'elenco dei messaggi corrispondenti
|
||||
* @param codiceProcesso Codice del processo
|
||||
* @return ANAGRAFICA_LOG_FE[] Elenco dei messaggi del processo
|
||||
*/
|
||||
public ANAGRAFICA_LOG_FE[] getANAGRAFICA_LOG_FE(String codiceProcesso)
|
||||
{
|
||||
int i = 0;
|
||||
boolean trovato = false;
|
||||
ANAGRAFICA_LOG_FE[] anagLogSeq = null;
|
||||
ANAGRAFICA_PROCESSO_FE[] anagProcList = getANAGRAFICA_PROCESSO_FE();
|
||||
while (i<=anagProcList.length && trovato==false) {
|
||||
ANAGRAFICA_PROCESSO_FE anagProc = (ANAGRAFICA_PROCESSO_FE) anagProcList[i];
|
||||
if(anagProc.getCODICE_PROCESSO().equalsIgnoreCase(codiceProcesso)){
|
||||
anagLogSeq = anagProc.getANAGRAFICA_LOG_FE();
|
||||
trovato = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return anagLogSeq;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user