Ejemplo n.º 1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            authUrl     = AuthenticationUrl.Get(context);
            authMethod  = AuthenticationMethod.Get(context);
            authBrowser = AuthenticationBrowser.Get(context);
            email       = Email.Get(context);
            if (authMethod != "Manual" && email == null)
            {
                throw new ArgumentException("Email must be supplied with Automatic Authorization");
            }
            passwordInsecure = PasswordInsecure.Get(context);
            if (authMethod == "Insecure" && passwordInsecure == null)
            {
                throw new ArgumentException("Insecure Password must be supplied with Insecure Authentication");
            }
            passwordSecure = PasswordSecure.Get(context);
            if (authMethod == "Secure" && passwordSecure == null)
            {
                throw new ArgumentException("Secure Password must be supplied with Secure Authentication");
            }

            browserLoadTimeout = BrowserLoadTimeout.Get(context);
            if (browserLoadTimeout == 0)
            {
                browserLoadTimeout = BrowserLoadTimeoutDefault;
            }

            BuildDefaultAuthUrl(context);
            BuildUrlAndFilename();
            BuildAuthArguments();

            LoadFileDelegate = new Action(LoadFile);
            return(LoadFileDelegate.BeginInvoke(callback, state));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method used to authenticate to Guardicore Centra API
        /// </summary>
        public void Authenticate()
        {
            AuthenticationResponse response = null;

            try
            {
                response = AuthenticationUrl.PostJsonToUrl(
                    new { username = _config.UserName, password = _config.Password })
                           .FromJson <AuthenticationResponse>();
            } catch (Exception ex)
            {
                throw new Exception("Error authenticating to Guardicore Centra API", ex);
            }
            _accessToken = response.access_token;
        }