/// <summary> /// Metodo di login /// </summary> /// <param name="request"></param> /// <returns>Response</returns> public Services.Authentication.LogIn.LogInResponse LogIn(Services.Authentication.LogIn.LogInRequest request) { logger.Info("BEGIN"); Services.Authentication.LogIn.LogInResponse response = Manager.AuthenticationManager.LogIn(request); Utils.CheckFaultException(response); logger.Info("END"); return(response); }
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); }