Esempio n. 1
0
        public VtDocsWS.Services.Token.GetAuthenticationToken.GetAuthenticationTokenResponse GetAuthenticationToken(VtDocsWS.Services.Token.GetAuthenticationToken.GetAuthenticationTokenRequest request)
        {
            logger.Info("BEGIN");

            Services.Token.GetAuthenticationToken.GetAuthenticationTokenResponse response = Manager.TokenManager.GetAuthenticationToken(request);

            //log
            //DocsPaVO.Logger.CodAzione.Esito esito = (response != null && response.Success ? DocsPaVO.Logger.CodAzione.Esito.OK : DocsPaVO.Logger.CodAzione.Esito.KO);
            //DocsPaVO.utente.InfoUtente infoUtente = Utils.CheckAuthentication(request);
            //BusinessLogic.UserLog.UserLog.getInstance().WriteLog(infoUtente, "GETAUTHENTICATIONTOKEN ", request.UserName, "Prelievo del token per l'utente " + request.UserName, esito);
            // Utilizzo questa forma per evitare che esegua il login.
            logger.Info("Metodo GetAuthenticationToken nei WS PIS: Prelievo del token per l'utente " + request.UserName);
            logger.Info("END");

            Utils.CheckFaultException(response);

            return(response);
        }
Esempio n. 2
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);
        }