Ejemplo n.º 1
0
 public IDictionary <string, object> AsKeyValuePairs()
 {
     return(new Dictionary <string, object>
     {
         ["Date Earned"] = DateEarned.HasValue() ? DateEarned.YMDString() : null,
         ["Flight ID"] = FlightID.ToString(CultureInfo.InvariantCulture),
         ["Checkride Type"] = CheckrideType.ToString(),
         ["Privilege"] = Privilege,
         ["License Kind"] = LicenseKind.ToString(),
         ["Level"] = Level.ToString()
     });
 }
Ejemplo n.º 2
0
        internal PilotLicense(Checkride cr) : this()
        {
            if (cr != null)
            {
                LicenseKind = cr.LicenseKind;

                // Merge all CFII/MEI into CFI
                if (cr.LicenseKind == LicenseKind.CFII || cr.LicenseKind == LicenseKind.MEI)
                {
                    LicenseKind = LicenseKind.CFI;
                }
            }
        }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = -1114257941;
                hashCode = hashCode * -1521134295 + DateEarned.GetHashCode();
                hashCode = hashCode * -1521134295 + FlightID.GetHashCode();
                hashCode = hashCode * -1521134295 + CheckrideType.GetHashCode();
                hashCode = hashCode * -1521134295 + LicenseKind.GetHashCode();
                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(LicenseName);

                hashCode = hashCode * -1521134295 + CheckrideProperty.GetHashCode();
                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Privilege);

                hashCode = hashCode * -1521134295 + Level.GetHashCode();
                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DisplayString);

                return(hashCode);
            }
        }
Ejemplo n.º 4
0
        public static string Name(this LicenseKind lk)
        {
            switch (lk)
            {
            default:
                throw new MyFlightbookException("Unknown kind of license");

            case LicenseKind.Unknown:
                return(string.Empty);

            case LicenseKind.ATP:
                return(Resources.Achievements.LicenseATP);

            case LicenseKind.CFI:
                return(Resources.Achievements.LicenseCFI);

            case LicenseKind.CFII:
                return(Resources.Achievements.LicenseCFII);

            case LicenseKind.Commercial:
                return(Resources.Achievements.LicenseCommercial);

            case LicenseKind.Instrument:
                return(Resources.Achievements.LicenseInstrument);

            case LicenseKind.MEI:
                return(Resources.Achievements.LicenseMEI);

            case LicenseKind.Night:
                return(Resources.Achievements.LicenseNight);

            case LicenseKind.Private:
                return(Resources.Achievements.LicensePPL);

            case LicenseKind.Recreational:
                return(Resources.Achievements.LicenseRecreational);

            case LicenseKind.Sport:
                return(Resources.Achievements.LicenseSport);
            }
        }
Ejemplo n.º 5
0
        internal static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, IDictionary <string, string> attributes,
                                                   LicenseKind licenseKind)
        {
            var doc = new XmlDocument();

            var license = doc.CreateElement(LicensingSR.License);

            doc.AppendChild(license);

            var idAttr = doc.CreateAttribute(LicensingSR.LicenseId);

            license.Attributes.Append(idAttr);
            idAttr.Value = id.ToString();

            var expirDateAttr = doc.CreateAttribute(LicensingSR.LicenseExpiration);

            license.Attributes.Append(expirDateAttr);
            expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture);

            var licenseAttr = doc.CreateAttribute(LicensingSR.LicenseKind);

            license.Attributes.Append(licenseAttr);
            licenseAttr.Value = licenseKind.ToString();

            var nameEl = doc.CreateElement(LicensingSR.LicenseName);

            license.AppendChild(nameEl);
            nameEl.InnerText = name;

            foreach (var attribute in attributes)
            {
                var attrib = doc.CreateAttribute(attribute.Key);
                attrib.Value = attribute.Value;
                license.Attributes.Append(attrib);
            }

            return(doc);
        }
Ejemplo n.º 6
0
 public PilotLicense(LicenseKind lk, string szPriv = null) : this()
 {
     LicenseKind = lk;
     AddPrivilege(szPriv);
 }
Ejemplo n.º 7
0
 public PilotLicense()
 {
     LicenseKind = LicenseKind.Unknown;
     m_privs     = new List <string>();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 새로운 라이선스를 생성합니다.
        /// </summary>
        /// <param name="privateKey">제품의 Private Key</param>
        /// <param name="name">라이선스 소유자 명</param>
        /// <param name="id">라이선스 소유자 Id</param>
        /// <param name="expirationDate">라이선스 유효기간</param>
        /// <param name="attributes">라이선스 속성</param>
        /// <param name="licenseKind">라이선스 종류</param>
        /// <returns>라이선스 내용</returns>
        public static string GenerateLicense(string privateKey, string name, Guid id, DateTime expirationDate,
                                             IDictionary<string, string> attributes, LicenseKind licenseKind) {
            if(IsDebugEnabled)
                log.Debug(
                    "Floating License를 생성합니다... privateKey=[{0}], name=[{1}], id=[{2}], expirationDate=[{3}], attributes=[{4}], licenseKind=[{5}]",
                    name, id, expirationDate, attributes, licenseKind);

            using(var rsa = new RSACryptoServiceProvider()) {
                rsa.FromXmlString(privateKey);
                var doc = CreateDocument(id, name, expirationDate, attributes, licenseKind);

                var signatureElement = GetXmlDigitalSignature(doc, rsa);
                doc.FirstChild.AppendChild(doc.ImportNode(signatureElement, true));

                using(var ms = new MemoryStream())
                using(var xw = XmlWriter.Create(ms, new XmlWriterSettings
                                                    {
                                                        Indent = true,
                                                        Encoding = Encoding.UTF8
                                                    })) {
                    doc.Save(xw);
                    ms.Position = 0;
                    return new StreamReader(ms).ReadToEnd();
                }
            }
        }
Ejemplo n.º 9
0
        internal static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, IDictionary<string, string> attributes,
                                                   LicenseKind licenseKind) {
            var doc = new XmlDocument();

            var license = doc.CreateElement(LicensingSR.License);
            doc.AppendChild(license);

            var idAttr = doc.CreateAttribute(LicensingSR.LicenseId);
            license.Attributes.Append(idAttr);
            idAttr.Value = id.ToString();

            var expirDateAttr = doc.CreateAttribute(LicensingSR.LicenseExpiration);
            license.Attributes.Append(expirDateAttr);
            expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture);

            var licenseAttr = doc.CreateAttribute(LicensingSR.LicenseKind);
            license.Attributes.Append(licenseAttr);
            licenseAttr.Value = licenseKind.ToString();

            var nameEl = doc.CreateElement(LicensingSR.LicenseName);
            license.AppendChild(nameEl);
            nameEl.InnerText = name;

            foreach(var attribute in attributes) {
                var attrib = doc.CreateAttribute(attribute.Key);
                attrib.Value = attribute.Value;
                license.Attributes.Append(attrib);
            }

            return doc;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 새로운 라이선스를 생성합니다.
 /// </summary>
 /// <param name="name">라이선스 소유자 명</param>
 /// <param name="id">라이선스 소유자 Id</param>
 /// <param name="expirationDate">라이선스 유효기간</param>
 /// <param name="attributes">라이선스 속성</param>
 /// <param name="licenseKind">라이선스 종류</param>
 /// <returns>라이선스 내용</returns>
 public string Generate(string name, Guid id, DateTime expirationDate, IDictionary <string, string> attributes,
                        LicenseKind licenseKind)
 {
     return(LicenseTool.GenerateLicense(_privateKey, name, id, expirationDate, attributes, licenseKind));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 새로운 라이선스를 생성합니다.
 /// </summary>
 /// <param name="name">라이선스 소유자 명</param>
 /// <param name="id">라이선스 소유자 Id</param>
 /// <param name="expirationDate">라이선스 유효기간</param>
 /// <param name="licenseKind">라이선스 종류</param>
 /// <returns>라이선스 내용</returns>
 public string Generate(string name, Guid id, DateTime expirationDate, LicenseKind licenseKind)
 {
     return(Generate(name, id, expirationDate, EmptyAttributes, licenseKind));
 }
Ejemplo n.º 12
0
 /// <summary>
 ///  開発者情報を指定して、新しいインスタンスを生成します。
 /// </summary>
 /// <param name="name">開発者の名前です。</param>
 /// <param name="copyright">著作権情報です。省略できます。</param>
 /// <param name="license">プログラムのライセンスです。限定値は、<c>"LGPLv3"</c>です。</param>
 public AuthorAttribute(string name, string copyright = "", LicenseKind license = LicenseKind.LGPLv3)
 {
     this.Name      = name;
     this.Copyright = copyright;
     this.License   = license;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 새로운 라이선스를 생성합니다.
 /// </summary>
 /// <param name="name">라이선스 소유자 명</param>
 /// <param name="id">라이선스 소유자 Id</param>
 /// <param name="expirationDate">라이선스 유효기간</param>
 /// <param name="attributes">라이선스 속성</param>
 /// <param name="licenseKind">라이선스 종류</param>
 /// <returns>라이선스 내용</returns>
 public string Generate(string name, Guid id, DateTime expirationDate, IDictionary<string, string> attributes,
                        LicenseKind licenseKind) {
     return LicenseTool.GenerateLicense(_privateKey, name, id, expirationDate, attributes, licenseKind);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 새로운 라이선스를 생성합니다.
 /// </summary>
 /// <param name="name">라이선스 소유자 명</param>
 /// <param name="id">라이선스 소유자 Id</param>
 /// <param name="expirationDate">라이선스 유효기간</param>
 /// <param name="licenseKind">라이선스 종류</param>
 /// <returns>라이선스 내용</returns>
 public string Generate(string name, Guid id, DateTime expirationDate, LicenseKind licenseKind) {
     return Generate(name, id, expirationDate, EmptyAttributes, licenseKind);
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            // バージョン情報表示
            CurrentVersion.ShowInConsole();
            CurrentVersion.ShowInConsole(typeof(Program).Assembly);
            Console.ReadLine();

            #region パスワード入力プログラムの実験
#if !NO_PASSWORD_TEST
            // 起動パスワード確認
            Console.WriteLine();
pwprompt:
            Console.Write("このライブラリの名前を入力:");
            SecureString pass = ConsoleUtils.ReadPassword();
            string       pw   = Marshal.PtrToStringUni(Marshal.SecureStringToGlobalAllocUnicode(pass));
            if (pw == "DotnetExlib")
            {
                ConsoleUtils.Pause();
            }
            else
            {
                goto pwprompt;
            }
            Console.WriteLine();
#endif
            #endregion

            #region 開発者情報に不正が存在しないかチェック
#if !NO_DEV_CHECK
            Console.WriteLine("開発者情報のチェック");

            try {
                List <(string name, string copyright)> devs  = new List <(string name, string copyright)>();
                List <(string name, string copyright)> devs2 = new List <(string name, string copyright)>();
                Assembly           asm     = typeof(CurrentVersion).Assembly;
                List <LicenseKind> dev_lic = new List <LicenseKind>();

                foreach (var dev_class in asm.GetTypes())
                {
                    // <PrivateImplementationDetails>を除外
                    if (dev_class.Name == "<PrivateImplementationDetails>")
                    {
                        continue;
                    }
                    // このループで全てのクラスから、開発者情報を取得する。
                    foreach (var dev_class_author in AuthorAttribute.GetAuthors(dev_class))
                    {
                        // もし、おかしなライセンスだったら
                        if (dev_class_author.License == LicenseKind.Developer)
                        {
                            throw new Exception(
                                      "開発者情報チェックでエラーが発生しました。ライセンスがdeveloperになっています。クラス:"
                                      + dev_class.ToString());
                        }
                        dev_lic.Add(dev_class_author.License);
                        // 同じ人を追加しない様にする。
                        if (!devs.Contains((dev_class_author.Name, dev_class_author.Copyright)))
                        {
                            devs.Add((dev_class_author.Name, dev_class_author.Copyright));
                        }
                    }
                    // ライセンスが重複していないか?
                    bool        a  = true;
                    LicenseKind lk = dev_lic?[0] == null ? LicenseKind.NoLicense : dev_lic[0];
                    foreach (var dev_lic_item in dev_lic)
                    {
                        a &= lk == dev_lic_item;
                    }
                    // もし、重複していたらエラー。
                    if (!a)
                    {
                        throw new Exception(
                                  "開発者情報チェックでエラーが発生しました。ライセンスが重複しています。クラス:"
                                  + dev_class.ToString());
                    }
                    dev_lic.Clear();
                }

                foreach (var dev_item in AuthorAttribute.GetAuthors(asm))
                {
                    if (!devs.Contains((dev_item.Name, dev_item.Copyright)))
                    {
                        throw new Exception(
                                  "開発者情報チェックでエラーが発生しました。開発者情報がクラスに存在しません。開発者:"
                                  + dev_item.Name);
                    }
                    else
                    {
                        devs2.Add((dev_item.Name, dev_item.Copyright));
                    }

                    if (dev_item.License != LicenseKind.Developer)
                    {
                        throw new Exception(
                                  "開発者情報チェックでエラーが発生しました。ライセンス設定が不正です。開発者:"
                                  + dev_item.Name);
                    }
                }
Ejemplo n.º 16
0
        /// <summary>
        /// 새로운 라이선스를 생성합니다.
        /// </summary>
        /// <param name="privateKey">제품의 Private Key</param>
        /// <param name="name">라이선스 소유자 명</param>
        /// <param name="id">라이선스 소유자 Id</param>
        /// <param name="expirationDate">라이선스 유효기간</param>
        /// <param name="attributes">라이선스 속성</param>
        /// <param name="licenseKind">라이선스 종류</param>
        /// <returns>라이선스 내용</returns>
        public static string GenerateLicense(string privateKey, string name, Guid id, DateTime expirationDate,
                                             IDictionary <string, string> attributes, LicenseKind licenseKind)
        {
            if (IsDebugEnabled)
            {
                log.Debug(
                    "Floating License를 생성합니다... privateKey=[{0}], name=[{1}], id=[{2}], expirationDate=[{3}], attributes=[{4}], licenseKind=[{5}]",
                    name, id, expirationDate, attributes, licenseKind);
            }

            using (var rsa = new RSACryptoServiceProvider()) {
                rsa.FromXmlString(privateKey);
                var doc = CreateDocument(id, name, expirationDate, attributes, licenseKind);

                var signatureElement = GetXmlDigitalSignature(doc, rsa);
                doc.FirstChild.AppendChild(doc.ImportNode(signatureElement, true));

                using (var ms = new MemoryStream())
                    using (var xw = XmlWriter.Create(ms, new XmlWriterSettings
                    {
                        Indent = true,
                        Encoding = Encoding.UTF8
                    })) {
                        doc.Save(xw);
                        ms.Position = 0;
                        return(new StreamReader(ms).ReadToEnd());
                    }
            }
        }