Exemple #1
0
        private InfoUtente GetInfoUtenteConservazione(string idAmm)
        {
            DocsPaVO.utente.Utente u      = null;
            InfoUtente             infoUC = new InfoUtente();

            try
            {
                //u = Utenti.UserManager.getUtente("UTENTECONSERVAZIONE", idAmm);
                DocsPaDB.Query_DocsPAWS.Utenti utenti = new DocsPaDB.Query_DocsPAWS.Utenti();
                u = utenti.GetUtente("UTENTECONSERVAZIONE", idAmm, "CENTRO_SERVIZI");

                infoUC.idPeople              = u.idPeople;
                infoUC.idAmministrazione     = u.idAmministrazione;
                infoUC.codWorkingApplication = "CS";
                infoUC.idGruppo              = "0";
                infoUC.idCorrGlobali         = "0";
                infoUC.userId = "UTENTECONSERVAZIONE";
            }

            catch (Exception ex)
            {
                logger.Debug("Errore nel reperimento dell'utente di sistema - ", ex);
                infoUC = null;
            }

            return(infoUC);
        }
Exemple #2
0
        /// <summary>
        /// Reperimento configurazioni LDAP impostate per un utente
        /// </summary>
        /// <param name="idUser"></param>
        /// <returns></returns>
        public static LdapUserConfig GetLdapUserConfig(string idUser)
        {
            DocsPaVO.utente.Utente user = null;

            using (DocsPaDB.Query_DocsPAWS.Utenti utentiDb = new DocsPaDB.Query_DocsPAWS.Utenti())
                user = utentiDb.getUtenteById(idUser);

            return(GetLdapUserConfigByName(user.userId));
        }
Exemple #3
0
        /// <summary>
        /// Costruisce un oggetto InfoUtente a partire dagli id recuperati
        /// dalla tabella di configurazione stampa
        /// </summary>
        /// <param name="reg">Oggetto RegistroConservazionePrint contentente user_id e id_gruppo</param>
        /// <returns></returns>
        private InfoUtente GetInfoUtenteStampa(RegistroConservazionePrint reg)
        {

            DocsPaVO.utente.Utente u = Utenti.UserManager.getUtenteById(reg.print_userId);
            DocsPaVO.utente.Ruolo r = Utenti.UserManager.getRuoloByIdGruppo(reg.print_role);

            InfoUtente retVal = Utenti.UserManager.GetInfoUtente(u, r);

            return retVal;

        }
Exemple #4
0
        /// <summary>
        /// Login al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool retValue = false;

            utente      = null;
            loginResult = UserLogin.LoginResult.UNKNOWN_USER;
            try
            {
                utente = new Utente();

                CorteContentServices.UserCredentialsRequestType userCred = new CorteContentServices.UserCredentialsRequestType();
                CorteContentServices.ResultType result = new CorteContentServices.ResultType();
                userCred.userCredentials          = new CorteContentServices.UserCredentialsType();
                userCred.userCredentials.userId   = userLogin.UserName;
                userCred.userCredentials.password = userLogin.Password;

                result = this.WsUserInstance.Login(userCred);

                if (OCSUtils.isValidServiceResult(result))
                {
                    //definizione del dst
                    // il dst tiene in memoria le informazioni necessarie per l'autenticazione dell'utente
                    // ci sono operazioni in cui non viene utilizzato l'utente applicativo ma è necessario
                    // utilizzare le credenziali effettive dell'utente che si connette al sistema.
                    // Per esempio nelle ricerche
                    utente     = new Utente();
                    utente.dst = this.GetAuthenticationToken(userLogin.UserName, userLogin.Password);

                    retValue    = true;
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                    logger.Debug(string.Format("OCS.LoginUser: utente {0} connesso", userLogin.UserName));
                }
                else
                {
                    retValue    = false;
                    utente      = null;
                    loginResult = UserLogin.LoginResult.UNKNOWN_USER;

                    logger.Debug(string.Format("Errore in OCS.Login:\n{0}", result.message));
                }
            }
            catch (Exception ex)
            {
                retValue    = false;
                utente      = null;
                loginResult = UserLogin.LoginResult.UNKNOWN_USER;

                logger.Error(string.Format("Errore in OCS.Login:\n{0}", ex.ToString()));
            }

            return(retValue);
        }
Exemple #5
0
        public static RicercaSmistamentoElement AggiungiElementoRicerca(string idElemento, string tipo, InfoUtente infoUtente, string idRegistro)
        {
            //List<RicercaSmistamentoElement> elements = new List<RicercaSmistamentoElement>();

            //string tipo = idElemento.Split('§')[0];
            //string id = idElemento.Split('§')[1];

            try
            {
                RicercaSmistamentoElement el = new RicercaSmistamentoElement();

                // RUOLO
                if (tipo.Equals("R"))
                {
                    string idGruppo            = BusinessLogic.Utenti.UserManager.getRuoloById(idElemento).idGruppo;
                    DocsPaVO.utente.Ruolo role = BusinessLogic.Utenti.UserManager.getRuoloByIdGruppo(idGruppo);

                    el.IdUO = role.uo.systemId;

                    el.IdRuolo          = idElemento;
                    el.DescrizioneRuolo = role.descrizione;

                    el.Type = SmistamentoNodeType.RUOLO;
                }
                // UTENTE
                else
                {
                    DocsPaVO.utente.Utente ut = BusinessLogic.Utenti.UserManager.getUtenteById(idElemento);
                    ut.ruoli = BusinessLogic.Utenti.UserManager.getRuoliUtente(idElemento);
                    Ruolo role = ((Ruolo[])ut.ruoli.ToArray(typeof(Ruolo))).FirstOrDefault();

                    el.IdUO = role.uo.systemId;

                    el.IdRuolo = role.systemId;
                    //el.DescrizioneRuolo = role.descrizione;

                    el.IdUtente          = ut.idPeople;
                    el.DescrizioneUtente = ut.cognome + " " + ut.nome;

                    el.Type = SmistamentoNodeType.UTENTE;
                }

                return(el);
            }
            catch (Exception ex)
            {
                logger.Debug("Elemento non trovato - tipo=" + tipo + ", id=" + idElemento);
                return(null);
            }
        }
Exemple #6
0
        public static Services.Authentication.LogOut.LogOutResponse LogOut(Services.Authentication.LogOut.LogOutRequest request)
        {
            Services.Authentication.LogOut.LogOutResponse response = new Services.Authentication.LogOut.LogOutResponse();

            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "LogOut");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                BusinessLogic.Utenti.Login.logoff(utente.userId, utente.idAmministrazione, utente.dst);

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #7
0
 public bool Logoff(DocsPaVO.utente.Utente utente)
 {
     try
     {
         utente = BusinessLogic.Utenti.UserManager.getUtente(utente.idPeople);
         BusinessLogic.Utenti.Login.logoff(utente.userId, utente.idAmministrazione, utente.sessionID, utente.dst);
         BusinessLogic.UserLog.UserLog.WriteLog(utente.userId, null, null, utente.idAmministrazione, "LOGOFF", null, null, DocsPaVO.Logger.CodAzione.Esito.OK, null);
         return(true);
     }
     catch (Exception e)
     {
         logger.Debug("Hermes - metodo:  Logoff.", e);
         return(false);
     }
 }
Exemple #8
0
        public GetHashDocumentoResponse GetHashDocumento(GetHashDocumentoRequest request)
        {
            GetHashDocumentoResponse response = new GetHashDocumentoResponse();

            response.Success  = false;
            response.HashAlgo = GetHashDocumentoResponse.AlgoritomoHash.none;
            try
            {
                // Hash repository
                // ottenuto da GetFileFirmato con applicazione algoritmo di hashing (256 oppure no)
                DocsPaVO.utente.Utente     utente     = BusinessLogic.Utenti.UserManager.getUtenteById(request.IdPeople);
                DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, null);
                SchedaDocumento            sd         = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, request.IdDocumento);
                FileRequest fr = sd.documenti[0] as FileRequest;
                if (fr != null)
                {
                    FileDocumento fd            = BusinessLogic.Documenti.FileManager.getFileFirmato(fr, infoUtente, false);
                    string        improntaDalDB = string.Empty;
                    using (DocsPaDB.Query_DocsPAWS.Documenti documentiDb = new DocsPaDB.Query_DocsPAWS.Documenti())
                    {
                        documentiDb.GetImpronta(out improntaDalDB, fr.versionId, request.IdDocumento);
                    }
                    string improntaDalFile = string.Empty;
                    improntaDalFile   = DocsPaUtils.Security.CryptographyManager.CalcolaImpronta256(fd.content);
                    response.HashAlgo = GetHashDocumentoResponse.AlgoritomoHash.SHA256;
                    if (improntaDalFile != improntaDalDB)
                    {
                        improntaDalFile   = DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(fd.content);
                        response.HashAlgo = GetHashDocumentoResponse.AlgoritomoHash.SHA1;
                    }
                    response.HashDatabase   = improntaDalDB;
                    response.HashRepository = improntaDalFile;
                    response.Success        = true;
                }

                // Hash database
                // facciamo una query scalare
            }
            catch (Exception ex)
            {
                response.Success      = false;
                response.ErrorMessage = ex.Message;
            }

            return(response);
        }
Exemple #9
0
        public DocsPaVO.utente.Utente Login(DocsPaVO.utente.UserLogin userLogin)
        {
            DocsPaVO.utente.Utente utente = null;
            string idWebSession           = string.Empty;
            string ipAddress = string.Empty;

            DocsPaVO.utente.UserLogin.LoginResult loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
            try
            {
                utente = BusinessLogic.Utenti.Login.loginMethod(userLogin, out loginResult, true, idWebSession, out ipAddress);
            }
            catch (Exception e)
            {
                logger.Debug("Hermes -  metodo: Login.", e);
            }

            return(utente);
        }
Exemple #10
0
        /// <summary>
        /// Connessione dell'utente al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            try
            {
                // Connessione al sistema ETDOCS
                bool connected = this.UserManagerETDOCS.LoginUser(userLogin, out utente, out loginResult);



                return(connected);
            }
            catch (Exception ex)
            {
                string errorMessage = string.Format("Errore nella login dell'utente al sistema documentale: {0}", ex.Message);
                logger.Debug(errorMessage);
                throw new ApplicationException(errorMessage, ex);
            }
        }
Exemple #11
0
        private static string GetToken(DocsPaVO.utente.Utente utente, DocsPaVO.utente.Ruolo ruolo)
        {
            //Controllo Correttezza Ruolo
            bool okRuolo = false;

            foreach (DocsPaVO.utente.Ruolo rl in utente.ruoli)
            {
                if (rl.idGruppo == ruolo.idGruppo)
                {
                    okRuolo = true;
                }
            }

            if (okRuolo)
            {
                string tokenDiAutenticazione = null;
                try
                {
                    string clearToken = string.Empty;
                    clearToken += ruolo.systemId + "|";
                    clearToken += utente.idPeople + "|";
                    clearToken += ruolo.idGruppo + "|";
                    clearToken += utente.dst + "|";
                    clearToken += utente.idAmministrazione + "|";
                    clearToken += utente.userId + "|";
                    clearToken += utente.sede + "|";
                    clearToken += utente.urlWA;

                    tokenDiAutenticazione = Utils.Encrypt(clearToken);
                }
                catch (Exception e)
                {
                    //  logger.Debug("Errore durante il GetInfoUtente.", e);
                }

                tokenDiAutenticazione = "SSO=" + tokenDiAutenticazione;
                return(tokenDiAutenticazione);
            }
            else
            {
                //logger.Debug("L'utente : " + utente.descrizione + " non appartiene al ruolo : " + ruolo.descrizione);
                return(null);
            }
        }
Exemple #12
0
        /// <summary>
        /// Connessione dell'utente al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            try
            {
                // Connessione al sistema ETDOCS
                bool connected = this.UserManagerETDOCS.LoginUser(userLogin, out utente, out loginResult);

                if (connected)
                {
                    DocsPaVO.utente.Utente utenteDTCM;

                    // Completamento dati oggetto UserLogin con i metadati dell'utente connesso
                    userLogin.SystemID          = utente.idPeople;
                    userLogin.IdAmministrazione = utente.idAmministrazione;

                    // Connessione al sistema DOCUMENTUM
                    connected = this.UserManagerDocumentum.LoginUser(userLogin, out utenteDTCM, out loginResult);

                    // Assegnazione dell'id di sessione DOCUMENTUM
                    if (connected)
                    {
                        utente.dst = utenteDTCM.dst;
                    }
                    else
                    {
                        utente.dst = null;
                    }
                }

                return(connected);
            }
            catch (Exception ex)
            {
                string errorMessage = string.Format("Errore nella login dell'utente al sistema documentale: {0}", ex.Message);
                logger.Debug(errorMessage);
                throw new ApplicationException(errorMessage, ex);
            }
        }
Exemple #13
0
        public static Services.Roles.GetRole.GetRoleResponse GetRole(Services.Roles.GetRole.GetRoleRequest request)
        {
            Services.Roles.GetRole.GetRoleResponse response = new Services.Roles.GetRole.GetRoleResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetRole");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.CodeRole) && string.IsNullOrEmpty(request.IdRole))
                {
                    throw new PisException("REQUIRED_CODE_OR_ID_ROLE");
                }

                if (!string.IsNullOrEmpty(request.CodeRole) && !string.IsNullOrEmpty(request.IdRole))
                {
                    throw new PisException("REQUIRED_ONLY_CODE_OR_ID_ROLE");
                }

                Domain.Role       roleResponse     = new Domain.Role();
                Domain.Register[] registerResponse = null;

                DocsPaVO.utente.Ruolo ruolo    = null;
                ArrayList             registri = new ArrayList();
                if (!string.IsNullOrEmpty(request.CodeRole))
                {
                    ruolo = BusinessLogic.Utenti.UserManager.getRuoloByCodice(request.CodeRole);
                }
                else
                {
                    if (!string.IsNullOrEmpty(request.IdRole))
                    {
                        //Id gruppo
                        ruolo = BusinessLogic.Utenti.UserManager.getRuoloByIdGruppo(request.IdRole);
                    }
                }

                if (ruolo != null)
                {
                    registri                 = BusinessLogic.Utenti.RegistriManager.getListaRegistriRfRuolo(ruolo.systemId, string.Empty, string.Empty);
                    roleResponse.Code        = ruolo.codiceRubrica;
                    roleResponse.Description = ruolo.descrizione;
                    roleResponse.Id          = ruolo.idGruppo;
                    if (registri != null && registri.Count > 0)
                    {
                        registerResponse = new Domain.Register[registri.Count];
                        int i = 0;
                        foreach (DocsPaVO.utente.Registro reg in registri)
                        {
                            Domain.Register regTemp = new Domain.Register();
                            regTemp.Code        = reg.codRegistro;
                            regTemp.Description = reg.descrizione;
                            regTemp.Id          = reg.systemId;
                            if (!string.IsNullOrEmpty(reg.chaRF) && (reg.chaRF).Equals("1"))
                            {
                                regTemp.IsRF = true;
                            }
                            else
                            {
                                regTemp.IsRF = false;
                            }
                            if (!string.IsNullOrEmpty(reg.stato))
                            {
                                if (reg.stato.Equals("A"))
                                {
                                    regTemp.State = "Open";
                                }
                                else
                                {
                                    regTemp.State = "Closed";
                                }
                            }
                            registerResponse[i] = regTemp;
                            i++;
                        }
                    }
                }
                else
                {
                    //Ruolo non trovato
                    throw new PisException("ROLE_NO_EXIST");
                }

                response.Role           = roleResponse;
                response.Role.Registers = registerResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #14
0
        public static Services.Token.GetAuthenticationToken.GetAuthenticationTokenResponse GetAuthenticationToken(Services.Token.GetAuthenticationToken.GetAuthenticationTokenRequest request)
        {
            Services.Token.GetAuthenticationToken.GetAuthenticationTokenResponse response = new Services.Token.GetAuthenticationToken.GetAuthenticationTokenResponse();
            try
            {
                DocsPaVO.utente.Utente utente = null;
                if (request == null || string.IsNullOrEmpty(request.UserName))
                {
                    throw new PisException("MISSING_PARAMETER");
                }

                if (string.IsNullOrEmpty(request.CodeAdm))
                {
                    throw new PisException("MISSING_PARAMETER");
                }
                utente = BusinessLogic.Utenti.UserManager.getUtenteByCodice(request.UserName, request.CodeAdm);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                else
                {
                    string token = null;
                    logger.Debug("Verifico le chiavi di configurazione");
                    if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN")) && DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN").Equals("1"))
                    {
                        logger.Debug("Chiavi di configurazione presenti");
                        token = DocsPaUtils.Security.SSOAuthTokenHelper.Generate(request.UserName.ToUpper());
                        logger.Debug("token generato.");
                    }
                    if (string.IsNullOrEmpty(token))
                    {
                        logger.Error("Errore nella generazione del token.");
                        throw new PisException("APPLICATION_ERROR");
                    }
                    else
                    {
                        response.AuthenticationToken = token;
                    }

                    response.Success = true;
                }
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #15
0
        public static DocsPaVO.utente.Utente esercitaDelega(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.utente.UserLogin objLogin, string webSessionId, string id_delega, string idRuoloDelegante, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            DocsPaVO.utente.Utente utente = null;

            loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
            try
            {
                //INC000001112977 PAT gestione deleghe
                //Dismetto le deleghe rimaste in esercizio
                DocsPaDB.Query_DocsPAWS.Deleghe deleghe = new DocsPaDB.Query_DocsPAWS.Deleghe();
                deleghe.DismettiDelegheInEsercizio(infoUtente);

                // Get User

                // ricostruzione informazioni utente delegante
                logger.DebugFormat("username {0} idAmm {1}", objLogin.UserName, objLogin.IdAmministrazione);
                utente = BusinessLogic.Utenti.UserManager.getUtente(objLogin.UserName, objLogin.IdAmministrazione);
                if (utente == null)
                {
                    logger.Error("utente è null");
                }


                // impostazione token di autenticazione
                DocsPaDocumentale.Documentale.UserManager userManager = new DocsPaDocumentale.Documentale.UserManager();
                utente.dst = userManager.GetSuperUserAuthenticationToken();

                // Impostazione id sessione utente
                utente.sessionID = webSessionId;

                //Verifico che l'utente delegante non sia connesso
                //si verifica la tabella DPA_LOGIN per unicità della connessione
                //la funzione torna True se l'utente è già collegato
                DocsPaDB.Query_DocsPAWS.Utenti gestioneUtenti = new DocsPaDB.Query_DocsPAWS.Utenti();

                if (!gestioneUtenti.CheckUserLogin(utente.userId, utente.idAmministrazione))
                {
                    if (idRuoloDelegante == "0")
                    {
                        //L'utente delegato eredita tutti i ruoli del delegante
                        utente.ruoli = BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople);
                    }
                    else
                    {
                        ArrayList ruoli     = BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople);
                        ArrayList listRuolo = new ArrayList();
                        foreach (DocsPaVO.utente.Ruolo ruolo in ruoli)
                        {
                            if (idRuoloDelegante.Equals(ruolo.systemId))
                            {
                                listRuolo.Add(ruolo);
                            }
                        }
                        utente.ruoli = listRuolo;
                    }
                    utente.dominio = getDominio(utente.idPeople);

                    if (utente.ruoli.Count == 0)
                    {
                        loginResult = DocsPaVO.utente.UserLogin.LoginResult.NO_RUOLI;
                        utente      = null;
                    }
                    else
                    {
                        gestioneUtenti.LockUserLoginDelegato(utente.userId, utente.idAmministrazione, webSessionId, objLogin.IPAddress, utente.dst, infoUtente.userId, id_delega);
                        loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                    }
                }
                else
                {
                    //Utente delegante loggato: viene rimosso dalla dpa_login (cosidetta porcata)
                    DocsPaDB.Query_DocsPAWS.Utenti dbUserManager = new DocsPaDB.Query_DocsPAWS.Utenti();
                    if (gestioneUtenti.UnlockUserLogin(utente.userId, utente.idAmministrazione, utente.sessionID))
                    {
                        if (idRuoloDelegante == "0")
                        {
                            //L'utente delegato eredita tutti i ruoli del delegante
                            utente.ruoli = BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople);
                        }
                        else
                        {
                            ArrayList ruoli     = BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople);
                            ArrayList listRuolo = new ArrayList();
                            foreach (DocsPaVO.utente.Ruolo ruolo in ruoli)
                            {
                                if (idRuoloDelegante.Equals(ruolo.systemId))
                                {
                                    listRuolo.Add(ruolo);
                                }
                            }
                            utente.ruoli = listRuolo;
                        }
                        utente.dominio = getDominio(utente.idPeople);

                        if (utente.ruoli.Count == 0)
                        {
                            loginResult = DocsPaVO.utente.UserLogin.LoginResult.NO_RUOLI;
                            utente      = null;
                        }
                        else
                        {
                            gestioneUtenti.LockUserLoginDelegato(utente.userId, utente.idAmministrazione, webSessionId, objLogin.IPAddress, utente.dst, infoUtente.userId, id_delega);
                            loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                        }
                    }
                    else
                    {
                        loginResult = DocsPaVO.utente.UserLogin.LoginResult.USER_ALREADY_LOGGED_IN;
                        utente      = null;
                    }
                }
            }
            catch (Exception e)
            {
                logger.ErrorFormat("msg {0}  stk {1} ", e.Message, e.StackTrace);
                loginResult = DocsPaVO.utente.UserLogin.LoginResult.APPLICATION_ERROR;
                logger.Debug("Errore nella gestione degli utenti (loginMethod)");
                utente = null;
            }

            return(utente);
        }
Exemple #16
0
        public static Services.Roles.GetRoles.GetRolesResponse GetRoles(Services.Roles.GetRoles.GetRolesRequest request)
        {
            Services.Roles.GetRoles.GetRolesResponse response = new Services.Roles.GetRoles.GetRolesResponse();

            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetRoles");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.UserID))
                {
                    throw new PisException("REQUIRED_USERID");
                }

                Domain.Role[] roleResponse = null;

                DocsPaVO.utente.Utente utenteDaCercare = null;
                ArrayList arrayRuoli = new ArrayList();

                if (!string.IsNullOrEmpty(request.UserID))
                {
                    utenteDaCercare = BusinessLogic.Utenti.UserManager.getUtente(request.UserID, Utils.GetIdAmministrazione(request.UserID));
                }
                else
                {
                    throw new PisException("REQUIRED_USERID");
                }

                if (utenteDaCercare != null)
                {
                    DocsPaVO.utente.InfoUtente infoUtenteDaCercare = new DocsPaVO.utente.InfoUtente(utenteDaCercare, Utils.GetRuoloPreferito(utenteDaCercare.idPeople));
                    arrayRuoli = BusinessLogic.Utenti.UserManager.getRuoliUtente(infoUtenteDaCercare.idPeople);
                    if (arrayRuoli != null && arrayRuoli.Count > 0)
                    {
                        roleResponse = new Domain.Role[arrayRuoli.Count];
                        int i = 0;
                        foreach (DocsPaVO.utente.Ruolo rol in arrayRuoli)
                        {
                            Domain.Role roleTemp = new Domain.Role();
                            roleTemp.Code        = rol.codiceRubrica;
                            roleTemp.Description = rol.descrizione;
                            roleTemp.Id          = rol.idGruppo;
                            roleResponse[i]      = roleTemp;
                            i++;
                        }
                    }
                    else
                    {
                        throw new PisException("USER_NO_ROLES");
                    }
                }
                else
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }

                response.Roles = roleResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #17
0
        /// <summary>
        /// Login al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool retValue = false;

            utente      = null;
            loginResult = UserLogin.LoginResult.UNKNOWN_USER;

            try
            {
                string userName     = TypeUtente.NormalizeUserName(userLogin.UserName);
                string userPassword = string.Empty;
                // Modifica 21-12-2012, recupero ticket documentum se login tramite token.
                //if (DocsPaServices.DocsPaQueryHelper.isUtenteDominioOrLdap(userLogin))
                if (userLogin.SSOLogin)
                {
                    // L'utente è agganciato in amministrazione ad un dominio,
                    // pertanto viene richiamato il servizio documentum per la generazione del ticket di autenticazione
                    userPassword = DctmTokenFactoryHelper.Generate(userName);
                }
                else
                {
                    userPassword = userLogin.Password;
                }

                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userName,
                    userPassword,
                    userLogin.Dominio);

                string token = DctmServices.DctmRepositoryIdentityHelper.CreateAuthenticationToken(identity);

                // Verifica validità credenziali
                if (this.VerifyCredentials(userName, token, out loginResult))
                {
                    utente      = new Utente();
                    utente.dst  = token;
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                }

                //per LDAP oppure per SHIBBOLETH
                if (userLogin.SSOLogin)
                {
                    utente.dst = UserManager.ImpersonateSuperUser();
                }
                //FINE per LDAP oppure per SHIBBOLETH


                retValue = (loginResult == DocsPaVO.utente.UserLogin.LoginResult.OK);
            }
            catch (Exception ex)
            {
                retValue    = false;
                utente      = null;
                loginResult = UserLogin.LoginResult.UNKNOWN_USER;

                logger.Debug(string.Format("Errore in Documentum.Login:\n{0}", ex.ToString()));
            }

            return(retValue);
        }
Exemple #18
0
        public string InviaRelata(byte[] fileReleata, String Stato, string token)
        {
            AlboToken   at        = new AlboToken();
            AlboTokenVO tvo       = at.DecryptToken(token);
            String      docNumber = tvo.DocNumber;
            String      nomeFile  = "Relata.pdf";

            string IdAmministrazione = BusinessLogic.Utenti.UserManager.getIdAmmUtente(tvo.userID);

            DocsPaVO.utente.Utente utente = BusinessLogic.Utenti.UserManager.getUtente(tvo.userID, IdAmministrazione);
            utente.dst = BusinessLogic.Utenti.UserManager.getSuperUserAuthenticationToken();
            if (utente == null)
            {
                throw new ApplicationException(string.Format("Utente {0} non trovato", tvo.userID));
            }

            DocsPaVO.utente.Ruolo[] ruoli = (DocsPaVO.utente.Ruolo[])BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople).ToArray(typeof(DocsPaVO.utente.Ruolo));

            if (ruoli != null && ruoli.Length > 0)
            {
                throw new ApplicationException("L'utente non non risulta associato ad alcun ruolo");
            }

            DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, ruoli[0]);

            DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato();
            all.descrizione = "Relata di Pubblicazione";

            all.docNumber    = docNumber;
            all.fileName     = nomeFile;
            all.version      = "0";
            all.numeroPagine = 1;
            DocsPaVO.documento.Allegato allIns = null;
            String err = String.Empty;

            try
            {
                allIns = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all);
            }
            catch (Exception ex)
            {
                logger.DebugFormat("Problemi nell'inserire l'allegato per la relata di pubblicazione {0} \r\n {1}", ex.Message, ex.StackTrace);
            }

            try
            {
                DocsPaVO.documento.SchedaDocumento sd    = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber);
                DocsPaVO.documento.FileDocumento   fdAll = new DocsPaVO.documento.FileDocumento();
                fdAll.content = fileReleata;
                fdAll.length  = fileReleata.Length;

                fdAll.name = nomeFile;
                fdAll.bypassFileContentValidation = true;
                DocsPaVO.documento.FileRequest fRAll = (DocsPaVO.documento.FileRequest)sd.documenti[0];
                fRAll = (DocsPaVO.documento.FileRequest)all;
                if (fdAll.content.Length > 0)
                {
                    logger.Debug("controllo se esiste l'ext");
                    if (!BusinessLogic.Documenti.DocManager.esistiExt(nomeFile))
                    {
                        BusinessLogic.Documenti.DocManager.insertExtNonGenerico(nomeFile, "application/octet-stream");
                    }

                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fRAll, fdAll, infoUtente, out err))
                    {
                        logger.Debug("errore durante la putfile");
                    }
                }
            }
            catch (Exception ex)
            {
                if (err == "")
                {
                    err = string.Format("Errore nel reperimento del file allegato: {0}.  {1}", nomeFile, ex.Message);
                }
                BusinessLogic.Documenti.AllegatiManager.rimuoviAllegato(all, infoUtente);
                logger.Debug(err);
            }


            //Mettere il cambio di stato.

            return("OK");
        }
Exemple #19
0
        /// <summary>
        /// Connessione dell'utente al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool result = false;

            utente      = null;
            loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;

            try
            {
                string name     = string.Empty;
                string password = string.Empty;

                if (!string.IsNullOrEmpty(userLogin.UserName))
                {
                    name = userLogin.UserName;
                }

                if (!string.IsNullOrEmpty(userLogin.Password))
                {
                    password = userLogin.Password;
                }

                DocsPaDB.Query_DocsPAWS.Utenti user = new DocsPaDB.Query_DocsPAWS.Utenti();

                result = user.IsUtenteDisabled(userLogin.UserName, userLogin.IdAmministrazione);

                if (result)
                {
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.DISABLED_USER;
                    utente      = null;
                    result      = false;
                }
                else
                {
                    // Connessione al sistema OCS
                    DocsPaVO.utente.Utente utenteOCS;
                    result = this.UserManagerOCS.LoginUser(userLogin, out utenteOCS, out loginResult);

                    // Assegnazione dell'id di sessione OCS
                    if (result)
                    {
                        DocsPaDB.Query_DocsPAWS.Utenti utenti = new DocsPaDB.Query_DocsPAWS.Utenti();
                        utente     = utenti.GetUtente(name, userLogin.IdAmministrazione);
                        utente.dst = utenteOCS.dst;
                    }
                    else
                    {
                        result      = false;
                        loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_USER;
                    }
                }
            }
            catch (Exception exception)
            {
                logger.Debug("Errore nella login.", exception);
                result = false;
                utente = null;
            }

            return(result);

            #region OLD

            /* OLD
             * try
             * {
             *  // Connessione al sistema ETDOCS
             *  bool connected = this.UserManagerETDOCS.LoginUser(userLogin, out utente, out loginResult);
             *
             *  if (connected)
             *  {
             *      DocsPaVO.utente.Utente utenteOCS;
             *
             *      // Connessione al sistema OCS
             *      connected = this.UserManagerOCS.LoginUser(userLogin, out utenteOCS, out loginResult);
             *
             *      // Assegnazione dell'id di sessione OCS
             *      if (connected)
             *          utente.dst = utenteOCS.dst;
             *  }
             *
             *  return connected;
             * }
             * catch (Exception ex)
             * {
             *  string errorMessage = string.Format("Errore nella login dell'utente al sistema documentale: {0}", ex.Message);
             *  logger.Debug(errorMessage);
             *  throw new ApplicationException(errorMessage, ex);
             * }
             */
            #endregion
        }
Exemple #20
0
        public static Services.Roles.GetUsersInRole.GetUsersInRoleResponse GetUsersInRole(Services.Roles.GetUsersInRole.GetUsersInRoleRequest request)
        {
            Services.Roles.GetUsersInRole.GetUsersInRoleResponse response = new Services.Roles.GetUsersInRole.GetUsersInRoleResponse();

            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetUsersInRole");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.CodeRole))
                {
                    throw new PisException("REQUIRED_CODE_ROLE");
                }

                Domain.User[] userResponse = null;

                DocsPaVO.utente.Ruolo ruolo = null;

                if (!string.IsNullOrEmpty(request.CodeRole))
                {
                    ruolo = BusinessLogic.Utenti.UserManager.getRuoloByCodice(request.CodeRole);
                    if (ruolo != null)
                    {
                        List <DocsPaVO.utente.UserMinimalInfo> userList = BusinessLogic.Utenti.UserManager.GetUsersInRoleMinimalInfo(ruolo.idGruppo);
                        if (userList != null && userList.Count > 0)
                        {
                            int i = 0;
                            userResponse = new Domain.User[userList.Count];
                            foreach (DocsPaVO.utente.UserMinimalInfo minimalUser in userList)
                            {
                                Domain.User            tempUser = new Domain.User();
                                DocsPaVO.utente.Utente utenteU  = BusinessLogic.Utenti.UserManager.getUtenteById(minimalUser.SystemId);
                                tempUser.Description = utenteU.descrizione;
                                tempUser.Name        = utenteU.nome;
                                tempUser.Surname     = utenteU.cognome;
                                tempUser.UserId      = utenteU.userId;
                                tempUser.Id          = utenteU.idPeople;
                                userResponse[i]      = tempUser;
                                i++;
                            }
                        }
                    }
                    else
                    {
                        //Ruolo non trovato
                        throw new PisException("ROLE_NO_EXIST");
                    }
                }
                else
                {
                    throw new PisException("REQUIRED_CODE_ROLE");
                }

                response.Users = userResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #21
0
        public static Services.Authentication.LogIn.LogInResponse LogIn(Services.Authentication.LogIn.LogInRequest request)
        {
            Services.Authentication.LogIn.LogInResponse response = new Services.Authentication.LogIn.LogInResponse();

            try
            {
                DocsPaVO.utente.Utente utente = null;
                string idWebSession           = string.Empty;
                string ipAddress = string.Empty;

                if (request != null && (string.IsNullOrEmpty(request.UserName) || string.IsNullOrEmpty(request.Password)))
                {
                    throw new PisException("MISSING_PARAMETER");
                }

                DocsPaVO.utente.UserLogin.LoginResult loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;

                DocsPaVO.utente.UserLogin login = new DocsPaVO.utente.UserLogin
                {
                    UserName = request.UserName,
                    Password = request.Password,
                };

                utente = BusinessLogic.Utenti.Login.loginMethod(login, out loginResult, true, idWebSession, out ipAddress);

                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }

                // Giovanni Olivari - 06/11/2012
                // Se l'utente non ha Ruoli viene generata un'eccezione prima di questo blocco di codice,
                // quindi arrivati qui posso essere sicuro di avere almeno un ruolo, prendo il primo della lista
                //
                DocsPaVO.utente.Ruolo ruolo = null;
                ruolo = (DocsPaVO.utente.Ruolo)utente.ruoli[0];

                if (loginResult == DocsPaVO.utente.UserLogin.LoginResult.OK)
                {
                    // Generazione del token di autenticazione
                    response.AuthenticationToken = CreateAuthToken(utente, ruolo);

                    BusinessLogic.Utenti.Login.logoff(utente.userId, utente.idAmministrazione, utente.dst);
                }
                else
                {
                    throw new PisException("MISSING_PARAMETER");
                }

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #22
0
        public static Services.Registers.GetRegisterOrRF.GetRegisterOrRFResponse GetRegisterOrRF(Services.Registers.GetRegisterOrRF.GetRegisterOrRFRequest request)
        {
            Services.Registers.GetRegisterOrRF.GetRegisterOrRFResponse response = new Services.Registers.GetRegisterOrRF.GetRegisterOrRFResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetRegisterOrRF");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.CodeRegister) && string.IsNullOrEmpty(request.IdRegister))
                {
                    throw new PisException("REQUIRED_CODE_OR_ID_REGISTER");
                }

                if (!string.IsNullOrEmpty(request.CodeRegister) && !string.IsNullOrEmpty(request.IdRegister))
                {
                    throw new PisException("REQUIRED_ONLY_CODE_OR_ID_REGISTER");
                }


                Domain.Register registerResponse = new Domain.Register();

                DocsPaVO.utente.Registro registro = null;

                if (!string.IsNullOrEmpty(request.CodeRegister))
                {
                    registro = BusinessLogic.Utenti.RegistriManager.getRegistroByCodAOO(request.CodeRegister, infoUtente.idAmministrazione);
                }
                else
                {
                    if (!string.IsNullOrEmpty(request.IdRegister))
                    {
                        try
                        {
                            registro = BusinessLogic.Utenti.RegistriManager.getRegistro(request.IdRegister);
                        }
                        catch
                        {
                            //Registro non trovato
                            throw new PisException("REGISTER_NOT_FOUND");
                        }
                    }
                }

                if (registro != null)
                {
                    registerResponse = Utils.GetRegister(registro);
                }
                else
                {
                    //Registro non trovato
                    throw new PisException("REGISTER_NOT_FOUND");
                }

                response.Register = registerResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #23
0
        public static Services.Registers.GetRegistersOrRF.GetRegistersOrRFResponse GetRegistersOrRF(Services.Registers.GetRegistersOrRF.GetRegistersOrRFRequest request)
        {
            Services.Registers.GetRegistersOrRF.GetRegistersOrRFResponse response = new Services.Registers.GetRegistersOrRF.GetRegistersOrRFResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetRegistersOrRF");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.CodeRole) && string.IsNullOrEmpty(request.IdRole))
                {
                    throw new PisException("REQUIRED_CODE_OR_ID_ROLE");
                }

                if (!string.IsNullOrEmpty(request.CodeRole) && !string.IsNullOrEmpty(request.IdRole))
                {
                    throw new PisException("REQUIRED_ONLY_CODE_OR_ID_ROLE");
                }

                Domain.Register[] registerResponse = null;

                DocsPaVO.utente.Registro[] registri = null;

                DocsPaVO.utente.Ruolo ruolo         = null;
                ArrayList             registriLista = new ArrayList();

                if (!string.IsNullOrEmpty(request.CodeRole))
                {
                    ruolo = BusinessLogic.Utenti.UserManager.getRuoloByCodice(request.CodeRole);
                }
                else
                {
                    if (!string.IsNullOrEmpty(request.IdRole))
                    {
                        try
                        {
                            //Id gruppo
                            ruolo = BusinessLogic.Utenti.UserManager.getRuoloByIdGruppo(request.IdRole);
                        }
                        catch
                        {
                            //Ruolo non trovato
                            throw new PisException("ROLE_NO_EXIST");
                        }
                    }
                }

                if (ruolo != null)
                {
                    //Prendi i registri e gli rf
                    if ((!request.OnlyRegisters && !request.OnlyRF) || (request.OnlyRegisters && request.OnlyRF))
                    {
                        registriLista = BusinessLogic.Utenti.RegistriManager.getListaRegistriRfRuolo(ruolo.systemId, string.Empty, string.Empty);
                    }
                    else
                    {
                        //Prendi solo i registri
                        if (request.OnlyRegisters && !request.OnlyRF)
                        {
                            registriLista = BusinessLogic.Utenti.RegistriManager.getListaRegistriRfRuolo(ruolo.systemId, "0", string.Empty);
                        }
                        else
                        {
                            //Prendi solo gli RF
                            if (request.OnlyRF && !request.OnlyRegisters)
                            {
                                registriLista = BusinessLogic.Utenti.RegistriManager.getListaRegistriRfRuolo(ruolo.systemId, "1", string.Empty);
                            }
                        }
                    }
                    if (registriLista != null && registriLista.Count > 0)
                    {
                        registerResponse = new Domain.Register[registriLista.Count];
                        int i = 0;
                        foreach (DocsPaVO.utente.Registro reg in registriLista)
                        {
                            Domain.Register regTemp = new Domain.Register();
                            regTemp             = Utils.GetRegister(reg);
                            registerResponse[i] = regTemp;
                            i++;
                        }
                    }
                }
                else
                {
                    //Ruolo non trovato
                    throw new PisException("ROLE_NO_EXIST");
                }

                response.Registers = registerResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }
Exemple #24
0
        public static Services.Authentication.Authenticate.AuthenticateResponse Authenticate(Services.Authentication.Authenticate.AuthenticateRequest request)
        {
            Services.Authentication.Authenticate.AuthenticateResponse response = new Services.Authentication.Authenticate.AuthenticateResponse();
            try
            {
                DocsPaVO.utente.Utente utente = null;
                if (request == null || string.IsNullOrEmpty(request.UserName))
                {
                    throw new PisException("MISSING_PARAMETER");
                }

                if (string.IsNullOrEmpty(request.Password))
                {
                    throw new PisException("MISSING_PARAMETER");
                }

                DocsPaVO.utente.UserLogin    userlog    = new UserLogin(request.UserName, request.Password, null);
                System.Collections.ArrayList listaAmmin = BusinessLogic.Utenti.UserManager.getListaIdAmmUtente(userlog);

                if (listaAmmin != null && listaAmmin.Count > 0)
                {
                    if (listaAmmin.Count == 1)
                    {
                        userlog.IdAmministrazione = listaAmmin[0].ToString();
                    }
                    else
                    {
                        throw new PisException("APPLICATION_ERROR");
                    }
                }
                if (listaAmmin == null)
                {
                    throw new PisException("APPLICATION_ERROR");
                }
                utente = BusinessLogic.Utenti.UserManager.getUtente(request.UserName, userlog.IdAmministrazione);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("APPLICATION_ERROR");
                }
                string encPass = BusinessLogic.Amministrazione.AmministraManager.GetPasswordUtenteMultiAmm(request.UserName.ToUpper());
                encPass = encPass.Split('^')[0];
                if (DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(System.Text.Encoding.Unicode.GetBytes(request.Password)) != encPass)
                {
                    throw new PisException("APPLICATION_ERROR");
                }


                DocsPaVO.utente.Ruolo ruolo = Utils.GetRuoloPreferito(utente.idPeople);
                if (ruolo == null)
                {
                    //L'utente non ha ruoli
                    throw new PisException("APPLICATION_ERROR");
                }

                DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, ruolo);


                utente.ruoli = new System.Collections.ArrayList();
                utente.ruoli.Add(ruolo);

                response.AuthenticationToken = CreateAuthToken(utente, ruolo);
                DocsPaVO.utente.Corrispondente corr = BusinessLogic.Utenti.UserManager.getCorrispondenteBySystemID(utente.systemId);
                response.User = Utils.GetCorrespondent(corr, infoUtente);

                //response.User = new Domain.Correspondent();
                //response.User.Name = utente.nome;
                //response.User.Surname = utente.cognome;
                //response.User.Location = utente.sede;
                //response.User.Email = utente.email;
                //response.User.Id = utente.systemId;
                //response.User.CorrespondentType = utente.tipoCorrispondente;
                //response.User.Type = "I";
                //response.User.Description = utente.descrizione;
                //response.User.Code = utente.userId;


                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }
            return(response);
        }
Exemple #25
0
        public static Services.Token.GetToken.GetTokenResponse GetToken(Services.Token.GetToken.GetTokenRequest request)
        {
            Services.Token.GetToken.GetTokenResponse response = new Services.Token.GetToken.GetTokenResponse();
            try
            {
                DocsPaVO.utente.Utente utente = null;
                bool sysExt = false;

                if (request == null || string.IsNullOrEmpty(request.CodeAdm))
                {
                    throw new PisException("MISSING_PARAMETER");
                }
                if (string.IsNullOrEmpty(request.UserName) && string.IsNullOrEmpty(request.CodeApplication))
                {
                    throw new PisException("MISSING_PARAMETER");
                }
                if (!string.IsNullOrEmpty(request.CodeApplication) && string.IsNullOrEmpty(request.UserName))
                {
                    sysExt = true;
                }
                string idAmm = BusinessLogic.Amministrazione.OrganigrammaManager.GetIDAmm(request.CodeAdm);
                if (!sysExt)
                {
                    utente = BusinessLogic.Utenti.UserManager.getUtenteByCodice(request.UserName, request.CodeAdm);
                    if (utente == null)
                    {
                        //Utente non trovato
                        throw new PisException("USER_NO_EXIST");
                    }
                    else
                    {
                        string token = null;
                        logger.Debug("Verifico le chiavi di configurazione");
                        if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN")) && DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN").Equals("1"))
                        {
                            logger.Debug("Chiavi di configurazione presenti");
                            token = DocsPaUtils.Security.SSOAuthTokenHelper.Generate(request.UserName.ToUpper());
                            logger.Debug("token generato.");
                        }
                        if (string.IsNullOrEmpty(token))
                        {
                            logger.Error("Errore nella generazione del token.");
                            throw new PisException("APPLICATION_ERROR");
                        }
                        else
                        {
                            response.AuthenticationToken = token;
                            // Devo creare la chiave di sistema per la durata standard del token. Per ora 20 minuti
                            string durataToken = "";
                            if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(idAmm, "BE_PIS_TOKEN_DURATION")))
                            {
                                durataToken = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(idAmm, "BE_PIS_TOKEN_DURATION");
                            }
                            else
                            {
                                durataToken = "20";
                            }
                            response.TokenDuration = durataToken;
                        }


                        response.Success = true;
                    }
                }
                else
                {
                    //string idAmm = BusinessLogic.Amministrazione.OrganigrammaManager.GetIDAmm(request.CodeAdm);
                    logger.Debug("Prelievo del token per il sistema esterno " + request.CodeApplication + " nell'amministrazione " + request.CodeAdm);
                    DocsPaVO.amministrazione.SistemaEsterno sisEsterno = BusinessLogic.Amministrazione.SistemiEsterni.getSistemaEsterno(idAmm, request.CodeApplication);
                    if (sisEsterno == null)
                    {
                        logger.ErrorFormat("Errore: Sistema esterno {0} non trovato nell'amministrazione {1}", request.CodeApplication, request.CodeAdm);
                        throw new Exception(String.Format("Errore: Sistema esterno {0} non trovato nell'amministrazione {1}", request.CodeApplication, request.CodeAdm));
                    }
                    utente = BusinessLogic.Utenti.UserManager.getUtenteByCodice(sisEsterno.UserIdAssociato, request.CodeAdm);
                    if (utente == null)
                    {
                        //Utente non trovato
                        throw new PisException("USER_NO_EXIST");
                    }
                    else
                    {
                        string token = null;
                        logger.Debug("Verifico le chiavi di configurazione");
                        if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN")) && DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_SSOLOGIN").Equals("1"))
                        {
                            logger.Debug("Chiavi di configurazione presenti");
                            token = DocsPaUtils.Security.SSOAuthTokenHelper.Generate(sisEsterno.UserIdAssociato.ToUpper());
                            logger.Debug("token generato.");
                        }
                        if (string.IsNullOrEmpty(token))
                        {
                            logger.Error("Errore nella generazione del token.");
                            throw new PisException("APPLICATION_ERROR");
                        }
                        else
                        {
                            response.AuthenticationToken = token;
                            response.Username            = sisEsterno.UserIdAssociato;
                            response.TokenDuration       = sisEsterno.TokenPeriod.ToString();
                        }

                        response.Success = true;
                    }
                }
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }
            return(response);
        }