Exemplo n.º 1
0
        private void FillSignatureHelperTopaz(string keyData, string signature)
        {
            if (!CheckTopaz())
            {
                return;
            }
            //According to Jeff Robertson from Topaz, the method SetKeyString() should be used to clear out the key string before loading a signature.
            //For that reason, it should only be called with 16 zeros as its arguments. The actual data that the signature will be bound to should be passed
            //to the method SetAutoKeyData().
            sigBox.Visible          = false;
            sigBoxTopaz.Visible     = true;
            labelInvalidSig.Visible = false;
            TopazWrapper.ClearTopaz(sigBoxTopaz);
            TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 0);
            TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 0);
            TopazWrapper.SetTopazKeyString(sigBoxTopaz, "0000000000000000"); //Clear out the key string
            TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);             //high encryption
            TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);            //high compression
            string hashedKeyData;

            switch (_signatureMode)
            {
            case SigMode.TreatPlan:
                hashedKeyData = TreatPlans.GetHashStringForSignature(keyData);                      //Passed in key data has not been hashed yet.
                TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, hashedKeyData);
                break;

            case SigMode.OrthoChart:
                hashedKeyData = OrthoCharts.GetHashStringForSignature(keyData);                      //Passed in key data has not been hashed yet.
                TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, hashedKeyData);
                break;

            case SigMode.Document:
            case SigMode.Default:
            default:
                TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, keyData);
                break;
            }
            TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
            if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
            {
                //Try reading in the signature using the old way that we used to handle signatures.
                FillSignatureTopazOld(keyData, signature);
            }
            //If sig still not showing it must be invalid.
            if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
            {
                labelInvalidSig.Visible = true;
            }
            TopazWrapper.SetTopazState(sigBoxTopaz, 0);
        }
Exemplo n.º 2
0
        ///<summary>This should NOT be used unless GetSigChanged returns true.</summary>
        public string GetSignature(string keyData)
        {
            //Topaz boxes are written in Windows native code.
            if (sigBoxTopaz.Visible)
            {
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    return("");
                }
                TopazWrapper.SetTopazKeyString(sigBoxTopaz, "0000000000000000");               //Clear out key string
                TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, keyData);
                TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);
                TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);
                return(TopazWrapper.GetTopazString(sigBoxTopaz));
            }
            else
            {
                //ProcCur.SigIsTopaz=false;
                if (sigBox.NumberOfTabletPoints() == 0)
                {
                    return("");
                }
                //sigBox.SetSigCompressionMode(0);
                //sigBox.SetEncryptionMode(0);
                //Some places used different logic for keystring and autokeydata in the past.  This must be maintained to keep signatures valid.
                switch (_signatureMode)
                {
                case SigMode.Document:
                case SigMode.TreatPlan:
                case SigMode.OrthoChart:
                    //No auto key data set, only key string.
                    sigBox.SetKeyString(keyData);
                    break;

                case SigMode.Default:
                    sigBox.SetKeyString("0000000000000000");
                    sigBox.SetAutoKeyData(keyData);
                    break;
                }
                //sigBox.SetEncryptionMode(2);
                //sigBox.SetSigCompressionMode(2);
                return(sigBox.GetSigString());
            }
        }
Exemplo n.º 3
0
        ///<summary>Some places used different logic for keystring and autokeydata in the past.  This must be maintained to keep signatures valid.
        ///</summary>
        private void FillSignatureTopazOld(string keyData, string signature)
        {
            string hashedKeyData;

            switch (_signatureMode)
            {
            case SigMode.Document:
                TopazWrapper.SetTopazKeyString(sigBoxTopaz, keyData);
                TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);                       //high encryption
                TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);                      //high compression
                TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                break;

            case SigMode.TreatPlan:
                hashedKeyData = OpenDentBusiness.TreatPlans.GetHashStringForSignature(keyData); //Passed in KeyData still needs to be hashed.
                TopazWrapper.SetTopazKeyString(sigBoxTopaz, hashedKeyData);
                TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);                            //high encryption
                TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);                           //high encryption
                TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                sigBoxTopaz.Refresh();
                //If sig is not showing, then try encryption mode 3 for signatures signed with old SigPlusNet.dll.
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 3);                           //Unknown mode (told to use via TopazSystems)
                    TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                }
                break;

            case SigMode.OrthoChart:
                hashedKeyData = OpenDentBusiness.OrthoCharts.GetHashStringForSignature(keyData); //Passed in KeyData still needs to be hashed.
                TopazWrapper.SetTopazKeyString(sigBoxTopaz, hashedKeyData);
                TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);                             //high encryption
                TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);                            //high compression
                TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                //older items may have been signed with zeros due to a bug.  We still want to show the sig in that case.
                //but if a sig is not showing, then set the key string to try to get it to show.
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, hashedKeyData);
                    TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                }
                //If sig is not showing, then try encryption mode 3 for signatures signed with old SigPlusNet.dll.
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 3);                           //Unknown mode (told to use via TopazSystems)
                    TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                }
                break;

            case SigMode.Default:
                TopazWrapper.SetTopazKeyString(sigBoxTopaz, "0000000000000000");
                TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2);                       //high encryption
                TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2);                      //high compression
                TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                //older items may have been signed with zeros due to a bug.  We still want to show the sig in that case.
                //but if a sig is not showing, then set the key string to try to get it to show.
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, keyData);
                    TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                }
                //If sig is not showing, then try encryption mode 3 for signatures signed with old SigPlusNet.dll.
                if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0)
                {
                    TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 3);                           //Unknown mode (told to use via TopazSystems)
                    TopazWrapper.SetTopazSigString(sigBoxTopaz, signature);
                }
                break;
            }
        }