public static AuthorizationInfoDTO Authenticate(string userName, string password)
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
            AAServiceV2Client aaServiceClient = new AAServiceV2Client();

            try
            {
                AuthorizationInfoDTO _authorizationInfoDTO = aaServiceClient.Authenticate(userName, password, APPLICATION);

                foreach (RoleDTO roleDTO in _authorizationInfoDTO.Roles)
                {
                    roleDTO.ApplicationContexts = roleDTO.ApplicationContexts.Where(item => item.ApplicationContext1 == CONTEXT_ONE || item.ApplicationContext1 == "*").ToList();
                }
                _authorizationInfoDTO.Roles = _authorizationInfoDTO.Roles.Where(item => item.ApplicationContexts.Count > 0).ToList();

                foreach (ScenarioDTO scenarioDTO in _authorizationInfoDTO.Scenarios)
                {
                    scenarioDTO.ApplicationContexts = scenarioDTO.ApplicationContexts.Where(item => item.ApplicationContext1 == CONTEXT_ONE || item.ApplicationContext1 == "*").ToList();
                }
                _authorizationInfoDTO.Scenarios = _authorizationInfoDTO.Scenarios.Where(item => item.ApplicationContexts.Count > 0).ToList();

                return _authorizationInfoDTO;
            }
            catch (Exception e)
            {
                ElmahLogger.Warn("AAService call (with username and password) failed : ", e);
                return null;
            }
        }
Example #2
0
        static void Main(string[] args)
        {

            while (true)
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);

                AAServiceV2Client client = new AAServiceV2Client();
                AuthorizationInfoDTO auazInfo = client.Authenticate("beymen_entegrasyon", "123", "Checkout");
                //AuthorizationInfoDTO auazInfo = client.Authenticate("71234", "123", "ECommerce");

                GlobalHeaderMesages.Instance.AuthenticationToken = auazInfo.Token.TokenString;

                Console.WriteLine("Herhangi bir tusa basınız. Checkout: c, Location: l, Cancellation: I, Stock Update: s, Exit: e");

                var keyInfo = Console.ReadKey();

                if (keyInfo.Key == ConsoleKey.C)
                {
                    Checkout();

                    Console.WriteLine("İşlem tamamlandı.");
                }
                else if (keyInfo.Key == ConsoleKey.L)
                {
                    SuggestLocation();

                    Console.WriteLine("İşlem tamamlandı.");
                }
                else if (keyInfo.Key == ConsoleKey.I)
                {
                    ReportCancelledItems();
                    Console.WriteLine("İşlem tamamlandı.");
                }
                else if(keyInfo.Key == ConsoleKey.S)
                {
                    UpdateStock();
                    Console.WriteLine("İşlem tamamlandı.");
                }

                else if (keyInfo.Key == ConsoleKey.E)
                {
                    return;
                }
                else
                {
                    Console.WriteLine("Geçersiz işlem.");
                }
            }
        }
        public static AuthorizationInfoDTO GetAuthorizationDataFromToken(string tokenString)
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
            AAServiceV2Client aaServiceClient = new AAServiceV2Client();

            TokenDTO token = new TokenDTO();
            token.TokenString = tokenString;
            AuthorizationInfoDTO _authorizationInfoDTO = aaServiceClient.IsAuthenticated(token, APPLICATION);

            foreach (RoleDTO roleDTO in _authorizationInfoDTO.Roles)
            {
                roleDTO.ApplicationContexts = roleDTO.ApplicationContexts.Where(item => item.ApplicationContext1 == CONTEXT_ONE || item.ApplicationContext1 == "*").ToList();
            }
            _authorizationInfoDTO.Roles = _authorizationInfoDTO.Roles.Where(item => item.ApplicationContexts.Count > 0).ToList();

            foreach (ScenarioDTO scenarioDTO in _authorizationInfoDTO.Scenarios)
            {
                scenarioDTO.ApplicationContexts = scenarioDTO.ApplicationContexts.Where(item => item.ApplicationContext1 == CONTEXT_ONE || item.ApplicationContext1 == "*").ToList();
            }
            _authorizationInfoDTO.Scenarios = _authorizationInfoDTO.Scenarios.Where(item => item.ApplicationContexts.Count > 0).ToList();

            return _authorizationInfoDTO;
        }
 private static List<RoleBasicInfoDTO> GetAllRoleBasicInfoForApplication()
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     return aaServiceClient.GetAllRoleBasicInfoForApplication(AuthorizationInfoDTO.Token, APPLICATION);
 }
 internal static void ChangeWelcomeScreenVisibility(bool visibility)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     TokenDTO tokenDTO = AuthorizationInfoDTO.Token;
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     aaServiceClient.SetWelcomeSecreenVisibility(tokenDTO, APPLICATION, visibility);
 }
 private static List<DelegationDTO> GetDelegations(TokenDTO tokenDTO)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     return aaServiceClient.GetDelegations(tokenDTO, AuthorizationInfoDTO.User.UserID, AuthorizationInfoDTO.ApplicationCode).ToList();
 }
 private static SignatureDTO GetSignature(TokenDTO tokenDTO, int userID)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     return aaServiceClient.GetSignature(tokenDTO, userID, APPLICATION);
 }
 private static List<RoleDTO> GetRolesOfUser(TokenDTO tokenDTO, int userID)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     List<RoleDTO> roles = aaServiceClient.GetRolesOfUser(tokenDTO, userID, APPLICATION);
     roles = roles.Where(item => item.ApplicationContexts.Any(q => (q.ApplicationContext1 == "*" || q.ApplicationContext1 == CONTEXT_ONE) &&
                                                                   (q.ApplicationContext2 == "*" || q.ApplicationContext2 == CONTEXT_TWO))).ToList();
     return roles;
 }
 private static List<RoleDTO> GetActiveRoles(TokenDTO tokenDTO)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     return aaServiceClient.GetActiveRoles(tokenDTO, APPLICATION);
 }
 private static List<UserDTO> GetUsersInRole(TokenDTO tokenDTO, string role, bool onlyActives, bool includingDelegations)
 {
     ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
     AAServiceV2Client aaServiceClient = new AAServiceV2Client();
     return aaServiceClient.GetUsersInRole(tokenDTO, role, APPLICATION, CONTEXT_ONE, CONTEXT_TWO, onlyActives, includingDelegations, false);
 }