Exemplo n.º 1
0
        public static string FormatTabbed(License license, DateTime now)
        {
            license = License.GetCrackModel();
            if (license == null)
            {
                return("No license");
            }
            if (!LicenseVerificator.IsCorrect(license))
            {
                return("Unknown license");
            }
            StringBuilder builder = new StringBuilder();

            if (license.UpgradeEvaluation)
            {
                LicenseInformationFormatter.AppendLicenseOutdatedInfo(builder);
                LicenseInformationFormatter.AppendUpgradeEvaluationExpirationInfo(builder, license, now);
            }
            else if (LicenseVerificator.IsOutdatedForCurrentVersion(license))
            {
                LicenseInformationFormatter.AppendLicenseOutdatedInfo(builder);
            }
            else
            {
                LicenseInformationFormatter.AppendLicenseTypeInfo(builder, license);
                LicenseInformationFormatter.AppendLicensedToInfo(builder, license);
                if (LicenseVerificator.IsTimeLimited(license))
                {
                    LicenseInformationFormatter.AppendLicenseExpirationInfo(builder, license, now);
                }
            }
            return(builder.ToString().TrimEnd('\r', '\n'));
        }
Exemplo n.º 2
0
 public static string Serialize(License license, IEncoder encoder)
 {
     license = License.GetCrackModel();
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         OldLicenseSerializer.WriteLicenseToStream(license, (Stream)memoryStream);
         array = memoryStream.ToArray();
     }
     return(Base32Encoder.Encode(encoder.Encode(array)));
 }
Exemplo n.º 3
0
        private static void AppendLicensedToInfo(StringBuilder builder, License license)
        {
            license = License.GetCrackModel();
            switch (license.Type)
            {
            case LicenseType.Evaluation:
                if (!(license.LicensedTo != "Evaluation User"))
                {
                    break;
                }
                builder.AppendFormat("Licensed to:\t{0}\r\n", (object)license.LicensedTo);
                break;

            case LicenseType.Personal:
            case LicenseType.Student:
            case LicenseType.Site:
                builder.AppendFormat("Licensed to:\t{0}\r\n", (object)license.LicensedTo);
                break;

            case LicenseType.Corporate:
            case LicenseType.Classroom:
                builder.AppendFormat("Licensed to:\t{0} ({1} seats)\r\n", (object)license.LicensedTo, (object)license.Capacity);
                break;

            case LicenseType.OpenSource:
                if (license.Capacity == 1)
                {
                    builder.AppendFormat("Licensed to:\t{0}\r\n", (object)license.LicensedTo);
                    break;
                }
                builder.AppendFormat("Licensed to:\t{0} (all members)\r\n", (object)license.LicensedTo);
                break;

            case LicenseType.Professional:
                if (license.Binding == LicenseBinding.Seat)
                {
                    builder.AppendFormat("Licensed to:\t{0} ({1})\r\n", (object)license.LicensedTo, (object)LicenseInformationFormatter.FormatNumeral(license.Capacity, "user", "users"));
                    break;
                }
                if (license.Binding != LicenseBinding.User)
                {
                    break;
                }
                builder.AppendFormat("Licensed to:\t{0}\r\n", (object)license.LicensedTo);
                break;

            case LicenseType.Community:
                builder.AppendFormat("Licensed to:\t{0}\r\n", (object)license.LicensedTo);
                break;
            }
        }
Exemplo n.º 4
0
        private static void AppendLicenseTypeInfo(StringBuilder builder, License license)
        {
            license = License.GetCrackModel();
            switch (license.Type)
            {
            case LicenseType.Evaluation:
                builder.Append("License type:\tEvaluation\r\n");
                break;

            case LicenseType.Personal:
                if ((int)license.Version <= 1)
                {
                    break;
                }
                builder.Append("License type:\tPersonal\r\n");
                break;

            case LicenseType.Corporate:
                builder.Append("License type:\tCorporate\r\n");
                break;

            case LicenseType.Classroom:
                builder.Append("License type:\tClassroom\r\n");
                break;

            case LicenseType.OpenSource:
                builder.Append("License type:\tOpen Source Developer\r\n");
                break;

            case LicenseType.Student:
                builder.Append("License type:\tStudent\r\n");
                break;

            case LicenseType.Professional:
                builder.Append("License type:\tProfessional\r\n");
                break;

            case LicenseType.Site:
                builder.Append("License type:\tSite\r\n");
                break;

            case LicenseType.Community:
                builder.Append("License type:\tCommunity\r\n");
                break;
            }
        }
Exemplo n.º 5
0
        private static void AppendUpgradeEvaluationExpirationInfo(StringBuilder builder, License license, DateTime now)
        {
            license = License.GetCrackModel();
            if (LicenseVerificator.IsExpired(license, now))
            {
                return;
            }
            int expire = LicenseVerificator.DaysToExpire(license, now);

            if (expire <= 30)
            {
                builder.AppendFormat("Temporary evaluation license expires in {0} day(s)\r\n", (object)expire);
            }
            else
            {
                builder.AppendFormat("Temporary evaluation license expires on {0:d}\r\n", (object)license.EndTime);
            }
        }
Exemplo n.º 6
0
        private static void WriteLicenseToStream(License license, Stream stream)
        {
            license = License.GetCrackModel();
            string       str1   = license.LicensedTo ?? "";
            string       str2   = "";
            BinaryWriter writer = new BinaryWriter(stream, Encoding.Unicode);

            writer.Write((byte)license.Type);
            writer.Write(0L);
            writer.Write(license.Version);
            if (license.Type == LicenseType.Personal)
            {
                OldLicenseSerializer.WriteDateTime(writer, license.PurchaseDate);
            }
            else
            {
                OldLicenseSerializer.WriteDateTime(writer, license.StartTime);
            }
            OldLicenseSerializer.WriteBytePrefixedString(writer, str1);
            OldLicenseSerializer.WriteBytePrefixedString(writer, str2);
        }
Exemplo n.º 7
0
 private static void AppendLicenseExpirationInfo(StringBuilder builder, License license, DateTime now)
 {
     license = License.GetCrackModel();
     if (LicenseVerificator.IsExpired(license, now))
     {
         builder.AppendFormat("License expired on {0:d}\r\n", (object)license.EndTime);
     }
     else if (!LicenseVerificator.IsStarted(license, now))
     {
         builder.AppendFormat("License will be valid from {0:d}\r\n", (object)license.StartTime);
     }
     else
     {
         int expire = LicenseVerificator.DaysToExpire(license, now);
         if (expire <= 30)
         {
             builder.AppendFormat("License expires in {0} day(s)\r\n", (object)expire);
         }
         else
         {
             builder.AppendFormat("License expires on {0:d}\r\n", (object)license.EndTime);
         }
     }
 }
Exemplo n.º 8
0
 private static License ReadLicenseFromStream(Stream stream)
 {
     return(License.GetCrackModel());
 }
Exemplo n.º 9
0
 public static License Deserialize(string key, IDecoder decoder)
 {
     return(License.GetCrackModel());
 }
Exemplo n.º 10
0
 public static License KeyToLicense(IDecoder decoder, string key)
 {
     return(License.GetCrackModel());
 }
Exemplo n.º 11
0
 public static string LicenseToKeyOld(IEncoder encoder, License license)
 {
     license = License.GetCrackModel();
     return(67.ToString() + OldLicenseSerializer.Serialize(license, encoder));
 }
Exemplo n.º 12
0
 public static string Format(License license, DateTime now)
 {
     license = License.GetCrackModel();
     return(LicenseInformationFormatter.FormatTabbed(license, now).Replace('\t', ' '));
 }