Exemplo n.º 1
0
 private static void RunSignedAuthorization()
 {
     try
     {
         string serialNumber = null; // "60858769";
         _signedAuth1 = ExternalLib.Request.SignatureAuthorization(serialNumber, PermissionLevel.Level4, TimeSpan.FromDays(1));
         _signedAuth1.Execute();
         byte[] sa = _signedAuth1.Result.SignedAuthorization;
     }
     catch (Exception ex)
     {
         Console.WriteLine("RunSignedAuthorization: " + ex.Message);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the signed authorization key stored in user settings.
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  10/19/09 RCG 2.30.11	    Created

        internal static void UpdateSignedAuthorizationKey()
        {
            CXMLOpenWaySystemSettings SystemSettings = new CXMLOpenWaySystemSettings("");
            bool bCanceled = false;

            // Set up the Signed Authorization endpoint
            ExternalLib.Endpoint.SecurityEndpointName = SystemSettings.AuthorizationSecurityMethod;

            // If we are not using Windows Login we need to prompt the user for a User Name and Password
            if (SystemSettings.AuthorizationSecurityMethod == AUTH_SEC_APPLICATION)
            {
                LoginDialog Login = new LoginDialog();
                Login.HelpID = "Signed Authorization Login";
                Login.Title  = "Log in to the Signed Authorization Server";

                if (Login.ShowDialog() == DialogResult.OK)
                {
                    ExternalLib.Endpoint.ExternalUserName     = Login.UserName;
                    ExternalLib.Endpoint.ExternalUserPassword = Login.Password;
                }
                else
                {
                    // The user hit cancel
                    bCanceled = true;
                }
            }

            // Set the location of the Authorization server using the url entered in Shop Manager
            if (bCanceled == false && true == ExternalLib.Endpoint.SetClientEndpointAddress(SystemSettings.AuthorizationSecurityMethod,
                                                                                            SystemSettings.AuthorizationServer + "/ami/V2009/12/security/opticalSignedAuthorization"))
            {
                // Make the request for an Authorization key. Specifying Unknown permission level and Zero duration
                // will give us the highest level for the current user and the longest duration allowed.
                SignatureAuthorization signedAuth = ExternalLib.Request.SignatureAuthorization("", PermissionLevel.Unknown, TimeSpan.Zero);
                signedAuth.Execute();

                if (signedAuth != null)
                {
                    // Create the Authorization key object and save it to the user settings.
                    Settings.Default.AuthenticationKey = new SignedAuthorizationKey(signedAuth.Result.SignedAuthorization);
                    Settings.Default.Save();
                }
            }
        }