コード例 #1
0
        /// <summary>
        /// Activates a License
        /// the License must be valid and non activated
        /// there can only be one activation of a SerialNumber
        /// If the Activation is successful the SerialNumber and ActivationKey will be inserted into the local database.
        /// It will throw a ActivationFailedException if the ManastoneServer delivers no or an empty Offer.
        /// </summary>
        /// <param name="req">an ActivationRequest containing the SerialNumber and the CPU1 ID</param>
        private void Activate(ActivationRequest req)
        {
            try
            {
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "req " + req.SerialNumber +
                                           " " + req.ProductUUID + " " + req.HardwareId);                                              //DEBUG

                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "Start");
                var activationKey =
                    SocketIoClient.RetrieveSingleValue <ActivationOffer>(_url, "ActivationOffer", "ActivationRequest",
                                                                         req.Serialize(), timeout: _timeout);
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "ActivationOffer " + activationKey.ActivationKey.Length);
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "ActivationOffer " + activationKey.Serialize());

                if (activationKey.ActivationKey.Length == 0)
                {
                    throw new ActivationFailedException("Length == 0");
                }
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "Before SerialInsertion");
                _database.InsertSerialNumber(req.SerialNumber);
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "Before ActivationKeyInsertion");
                _database.InsertActivationKey(req.SerialNumber, activationKey.ActivationKey);
                RetrieveToken(new TokenRequest(activationKey.ActivationKey));
                RetrieveCustomerReference(new CustomerReferenceRequest(activationKey.ActivationKey));
                _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "Activate", "Complete");
                _database.Log.ProcessLogList();
            }
            catch (Exception e)
            {
                _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on ACTIVATE", e.Message);
                _database.Log.ProcessLogList();
                throw new ActivationFailedException();
            }
        }
コード例 #2
0
        /// <summary>
        /// Checks Oif Version
        /// Returns true if Version greater/equal than Server Version
        /// Returns false if Version smaller than Server Version
        /// </summary>
        /// <returns></returns>
        public bool CheckOidVersion(out string oidServerVersion)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "CheckOidVersion");
            if (Config.GetInstance().Directory.TryGetValue("OidVersion", out string instVer))
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                 " CheckOidVersion TryGetValue done");

                var ver = SocketIoClient.RetrieveSingleValue <VersionWrapper>(_url,
                                                                              "OidVersionOffer", "OidVersionRequest", null, timeout: 30000);
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                 "OidVersionOffer received");

                if (System.Version.TryParse(instVer, out Version instVersion) &&
                    System.Version.TryParse(ver.Version, out Version version))
                {
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "before assigning out");

                    oidServerVersion = ver.Version;
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "CheckOidVersion Complete");
                    return(instVersion.CompareTo(version) >= 0);
                }
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.CriticalError, "OpenMPSClient",
                                             "Missing Directory OidVersion Value");
            throw new QueryFailedException();
        }
コード例 #3
0
        /// <summary>
        /// Checks for the minimum openMPS server version
        /// </summary>
        /// <returns></returns>
        private bool CheckMinClientVersion()
        {
            try
            {
                FnLog.GetInstance()
                .AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "CheckMinClientVersion");
                var ver = SocketIoClient.RetrieveSingleValue <VersionWrapper>(_url,
                                                                              "MPSMinClientVersionOffer", "MPSMinClientVersionRequest", null, timeout: 30000);
                var progVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (System.Version.TryParse(progVersion, out Version programVersion) &&
                    System.Version.TryParse(ver.Version, out Version minversion))
                {
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "CheckMinClientVersion Complete");
                    return(programVersion.CompareTo(minversion) >= 0);
                }

                FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "OpenMPSClient",
                                                 "CheckMinClientVersion ResultNullOrNotReceivedException");
                throw new ResultNullOrNotReceivedException();
            }
            catch (Exception e)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "OpenMPSClient",
                                                 "CheckMinClientVersion" + e.Message);
                MessageBox.Show("Could not reach the openMPS Server");
                throw new ResultNullOrNotReceivedException();
            }
        }
コード例 #4
0
        /// <summary>
        /// sends the oid data
        /// </summary>
        /// <param name="data"></param>
        public void SendOidData(List <OidData> data)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "SendOidData");
            var dataStr = JsonConvert.SerializeObject(data, Formatting.Indented).Trim()
                          .Replace(System.Environment.NewLine, "");
            var res = SocketIoClient.RetrieveSingleValue <SimpleResult>(_url,
                                                                        "closer", "SendData", dataStr, timeout: 30000);

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "SendOidData sent");
        }
コード例 #5
0
ファイル: FnLogClient.cs プロジェクト: Fearvel/de.fearvel.net
 /// <summary>
 /// Sends a log
 /// </summary>
 private void Sender()
 {
     try
     {
         SocketIoClient.RetrieveSingleValue <SimpleResult>(_serverUrl,
                                                           "closer", _senderEventName, _logSerialized);
     }
     catch (System.Exception)
     {
         // ignored
     }
 }
コード例 #6
0
        /// <summary>
        /// Downloads and updates the oid table
        /// </summary>
        /// <param name="oidVersion"></param>
        private void DownloadAndUpdateOidTable(string oidVersion)
        {
            ManastoneClient.GetInstance().CheckToken();

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable - " + ManastoneClient.GetInstance().Token);
            var oid = SocketIoClient.RetrieveSingleValue <List <Oid> >(_url,
                                                                       "OidOffer", "OidRequest", new OidRequest(ManastoneClient.GetInstance().Token).Serialize(),
                                                                       timeout: 30000);

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable received" + oid.Count);
            Config.GetInstance().UpdateOids(oidVersion, oid);
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable Complete");
        }
コード例 #7
0
 /// <summary>
 /// Retrieves the Customer Reference from the Manastone Server and saves it to the Local database
 /// </summary>
 /// <param name="req">an CustomerReferenceRequest containing the ActivationKey</param>
 private void RetrieveCustomerReference(CustomerReferenceRequest req)
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "RetrieveCustomerReference", "Start");
         var offer =
             SocketIoClient.RetrieveSingleValue <CustomerReferenceOffer>(_url, "CustomerReferenceOffer",
                                                                         "CustomerReferenceRequest", req.Serialize(), timeout: _timeout);
         _database.InsertCustomerReference(req.ActivationKey, offer.CustomerReference);
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "RetrieveCustomerReference", "Complete");
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on RetrieveCustomerReference", e.Message);
         throw new ManastoneOfferNotReceivedCorrectlyException();
     }
 }
コード例 #8
0
 /// <summary>
 /// Returns the Version of the Manastone Server
 /// if this fails it will throw a ManastoneOfferNotReceivedCorrectlyException
 /// </summary>
 /// <returns></returns>
 private Version RetrieveManastoneServerVersion()
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MinorDrmLog, "RetrieveManastoneServerVersion", "Start");
         var serVer = Version.Parse(SocketIoClient.RetrieveSingleValue <VersionWrapper>(_url, "ManastoneVersion",
                                                                                        "ManastoneVersionRequest", null, timeout: _timeout).Version);
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MinorDrmLog, "RetrieveManastoneServerVersion", "Complete");
         _database.Log.ProcessLogList();
         return(serVer);
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on RetrieveManastoneServerVersion", e.Message);
         _database.Log.ProcessLogList();
         throw new ManastoneOfferNotReceivedCorrectlyException();
     }
 }
コード例 #9
0
 /// <summary>
 /// Checks if the Token is valid
 /// this will contact the Manastone server and check if the token is valid
 /// a token check has to be Online only because the token is to authenticate a program client to a program server or service
 /// if the server doesn't answer it will throw a ManastoneOfferNotReceivedCorrectlyException
 /// </summary>
 /// <param name="req">CheckTokenRequest</param>
 /// <returns></returns>
 public bool CheckToken(CheckTokenRequest req)
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmLog, "CheckToken", "Start");
         var offer = SocketIoClient.RetrieveSingleValue <CheckTokenOffer>(_url, "CheckTokenOffer",
                                                                          "CheckTokenRequest", req.Serialize(), timeout: _timeout);
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmLog, "CheckToken", "Complete");
         _database.Log.ProcessLogList();
         return(offer.IsValid);
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on CheckToken", e.Message);
         _database.Log.ProcessLogList();
         throw new ManastoneOfferNotReceivedCorrectlyException();
     }
 }
コード例 #10
0
 /// <summary>
 /// Returns the DateTime of the Manastone Server
 /// Currently unused, will be used later to locally check the Token expiry date
 /// </summary>
 /// <returns></returns>
 private DateTime RetrieveServerTime()
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MinorDrmLog, "RetrieveServerTime", "Start");
         var serTime = SocketIoClient
                       .RetrieveSingleValue <DateTimeWrapper>(_url, "ServerTime", "ServerTimeRequest", null)
                       .Time;
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MinorDrmLog, "RetrieveServerTime", "Complete");
         _database.Log.ProcessLogList();
         return(serTime);
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on RetrieveServerTime", e.Message);
         _database.Log.ProcessLogList();
         throw new ManastoneOfferNotReceivedCorrectlyException();
     }
 }
コード例 #11
0
 /// <summary>
 /// Retrieves the Token and saves it to the Local database
 /// </summary>
 /// <param name="req">an TokenRequest containing the ActivationKey</param>
 private void RetrieveToken(TokenRequest req)
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "RetrieveToken", "Start");
         var token =
             SocketIoClient.RetrieveSingleValue <TokenOffer>(_url, "TokenOffer", "TokenRequest",
                                                             req.Serialize(), timeout: _timeout);
         if (token.Token.Length == 0)
         {
             throw new FailedToRetrieveTokenException();
         }
         _database.InsertToken(req.ActivationKey, token.Token);
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "RetrieveToken", "Complete");
         _database.Log.ProcessLogList();
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on RetrieveToken", e.Message);
         _database.Log.ProcessLogList();
         throw new ManastoneOfferNotReceivedCorrectlyException();
     }
 }
コード例 #12
0
 /// <summary>
 /// Checks Activation status Online.
 /// this will contact the Manastone server and check if the activation is valid
 /// </summary>
 /// <param name="req">ActivationOnlineCheckRequest</param>
 /// <returns>if valid returns true</returns>
 private bool CheckLicenseStatusOnline(ActivationOnlineCheckRequest req)
 {
     try
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "CheckLicenseStatusOnline", "Start");
         var offer = SocketIoClient.RetrieveSingleValue <ActivationOnlineCheckOffer>(_url,
                                                                                     "ActivationOnlineCheckOffer",
                                                                                     "ActivationOnlineCheckRequest", req.Serialize(), timeout: _timeout);
         if (offer.IsActivated)
         {
             _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "CheckLicenseStatusOnline", "ACTIVATION Confirmed");
             RetrieveCustomerReference(new CustomerReferenceRequest(req.ActivationKey));
         }
         _database.Log.AddToLogList(FnLog.FnLog.LogType.MajorDrmLog, "CheckLicenseStatusOnline", "Complete");
         _database.Log.ProcessLogList();
         return(offer.IsActivated);
     }
     catch (Exception e)
     {
         _database.Log.AddToLogList(FnLog.FnLog.LogType.DrmError, "ERROR on CheckLicenseStatusOnline", e.Message);
         _database.Log.ProcessLogList();
         return(false);
     }
 }
コード例 #13
0
ファイル: FnLogClient.cs プロジェクト: Fearvel/de.fearvel.net
 /// <summary>
 /// testing atm!
 /// retrieves logs from the fnLog server
 /// </summary>
 /// <param name="logRequest"></param>
 /// <param name="serverUrl"></param>
 /// <param name="acceptSelfSigned"></param>
 /// <returns></returns>
 public static List <Log> RetrieveLog(LogRequest logRequest, string serverUrl, bool acceptSelfSigned = true)
 {
     return(SocketIoClient.RetrieveSingleValue <List <Log> >(serverUrl,
                                                             "logRequestResult", "logRequest", logRequest.Serialize()));
 }