コード例 #1
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);
        }
コード例 #2
0
        public Services.Authentication.Authenticate.AuthenticateResponse Authenticate(Services.Authentication.Authenticate.AuthenticateRequest request)
        {
            logger.Info("BEGIN");
            Services.Authentication.Authenticate.AuthenticateResponse response = Manager.AuthenticationManager.Authenticate(request);

            Utils.CheckFaultException(response);
            logger.Info("END");
            return(response);
        }