Beispiel #1
0
 public override void  Append(ref Dictionary<string,object> variables, Org.Reddragonit.Stringtemplate.Outputs.IOutputWriter writer)
 {
     object obj = Utility.LocateObjectInVariables(_variable, variables);
     _format = (Utility.LocateObjectInVariables(_format, variables) != null ? Utility.LocateObjectInVariables(_format, variables) : _format).ToString();
     if (obj != null)
         writer.Append(((IFormattable)Utility.LocateObjectInVariables(_variable, variables)).ToString(_format, null));
 }
Beispiel #2
0
 public override void Append(ref Dictionary<string, object> variables, Org.Reddragonit.Stringtemplate.Outputs.IOutputWriter writer)
 {
     object obj = Utility.LocateObjectInVariables(val, variables);
     if (obj == null)
         throw new Exception("Unable to locate a variable of the name " + val + " in order to extract the type name");
     writer.Append(obj.GetType().FullName);
 }
Beispiel #3
0
 public bool IsValid(Org.BouncyCastle.Asn1.X509.X509CertificateStructure[] certs)
 {
     if (OnVerifyCertificate != null)
         return OnVerifyCertificate(certs);
     else
         return true;
 }
Beispiel #4
0
  public ACL(
  int perms
,
  Org.Apache.Zookeeper.Data.ZKId id
) {
Perms=perms;
Id=id;
  }
Beispiel #5
0
		public static byte[] ToByteArray(Org.BouncyCastle.Math.BigInteger bigint, int expectedLength)
		{
			byte[] data = bigint.ToByteArray ();
			if (data.Length == expectedLength + 1) {
				return data.Skip (1).Take (expectedLength).ToArray ();
			}
			return data;
		}
 public int AddOrg(string orgCode)
 {
     CQGJModel.Org org = new Org();
     org.OrgCode = orgCode;
     cqgj.AddToOrg(org);
     cqgj.SaveChanges();
     return org.OrgID;
 }
Beispiel #7
0
 public CodelistExporter(string code,Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICodelistObject codelist)
 {
     _codelist = codelist;
     _code = code;
     _xmlDoc = null;
     _dataFilename = string.Empty;
     _dataView = null;
 }
  public GetChildren2Response(
  System.Collections.Generic.IEnumerable<string> children
,
  Org.Apache.Zookeeper.Data.Stat stat
) {
Children=children;
Stat=stat;
  }
Beispiel #9
0
 public static Asn1Set GetAttributeSet(Org.BouncyCastle.Asn1.Cms.AttributeTable attr)
 {
     if (attr != null)
     {
         return new DerSet(attr.ToAsn1EncodableVector());
     }
     return null;
 }
Beispiel #10
0
 /// <summary>
 /// Public constructor for a Pkcs certificate, takes in values to describe it's state.
 /// </summary>
 /// <param name="password">The value used to secure (encrypt) the private key with the certificate</param>
 /// <param name="keypair">An object used for manipulating/accessing the public and private key of a certificate</param>
 /// <param name="cert">An easy to manipulate version of an X509 certificate</param>
 /// <param name="store">A store of Pkcs12 certificates used to store and manipulate certificat chains and key associations</param>
 public PkcsCertificate(string password ,AsymmetricCipherKeyPair keypair, Org.BouncyCastle.X509.X509Certificate cert, Pkcs12Store store)
 {
     this.Password = password;
     this.Keypair = keypair;
     this.X509Certificate = cert;
     this.PkcsStore = store;
     // this is not the best place to do this
 }
Beispiel #11
0
  public GetDataResponse(
  byte[] data
,
  Org.Apache.Zookeeper.Data.Stat stat
) {
Data=data;
Stat=stat;
  }
Beispiel #12
0
  public GetACLResponse(
  System.Collections.Generic.IEnumerable<Org.Apache.Zookeeper.Data.ACL> acl
,
  Org.Apache.Zookeeper.Data.Stat stat
) {
Acl=acl;
Stat=stat;
  }
Beispiel #13
0
 public OrgModel(Org org)
 {
     _org = org;
     Id = org.Id;
     Name = org.Name;
     Remark = org.Remarks;
     Roles = org.GetAllRoles().ToArray();
     Parent = org.Parent;
 }
 public bool CanProcessRequest(HttpRequest request, Org.Reddragonit.EmbeddedWebServer.Interfaces.Site site)
 {
     return request.URL.AbsolutePath == "/resources/scripts/core.js"
         || request.URL.AbsolutePath == "/resources/scripts/setup.js"
         || request.URL.AbsolutePath == "/resources/scripts/user.js"
         || request.URL.AbsolutePath == "/resources/styles/core.css"
         || request.URL.AbsolutePath == "/resources/styles/setup.css"
         || request.URL.AbsolutePath == "/resources/styles/user.css";
 }
Beispiel #15
0
 public static void WritePkcs12(RsaPrivateCrtKeyParameters privKey, Org.BouncyCastle.X509.X509Certificate certificate,
     string password, Stream stream)
 {
     Pkcs12Store store = new Pkcs12Store();
     X509CertificateEntry[] chain = new X509CertificateEntry[1];
     chain[0] = new X509CertificateEntry(certificate);
     store.SetKeyEntry("privateKey", new AsymmetricKeyEntry(privKey), chain);
     store.Save(stream, password.ToCharArray(), new SecureRandom());
 }
		public bool CanLoad(Org.Reddragonit.Stringtemplate.Tokenizers.Token token)
		{
			foreach(char c in _reserved)
			{
				if (token.Content.Contains(c.ToString()))
					return false;
			}
			return true;
		}
        public static void Serialize(string fileName, Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan ip)
        {
            Org.Apache.REEF.Tang.Protobuf.InjectionPlan plan = Serialize(ip);

            using (var file = File.Create(fileName))
            {
                Serializer.Serialize<Org.Apache.REEF.Tang.Protobuf.InjectionPlan>(file, plan);
            }
        }
		public ComponentObjectBaseCore(Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.IComponent componentBean,
				ICodelistObjectBase codeListBean1, IConceptObjectBase conceptSuperBean2) : base(componentBean) {
			this.Icomponent = componentBean;
			this.Icodelist = codeListBean1;
			if (codeListBean1 == null) {
				this.Icodelist = conceptSuperBean2.CoreRepresentation;
			}
			this.IconceptSuper = conceptSuperBean2;
		}
Beispiel #19
0
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM V1 SCHEMA				 //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////
		public ItemCore(
				XmlObject createdFrom,
				SdmxStructureType structureType,
				String id,
				String uri,
				IList<Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.TextType> name,
				IList<Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.TextType> description,
				Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.AnnotationsType annotationsType,
				IIdentifiableObject parent) {
		}
 public void Execute()
 {
     SmartBox.Console.Common.Log4NetHelper.Info("同步统一授权组织机构开始!");
     if (arr != null && arr.Length > 0)
     {
         topOrg = orgService.GetTopOrg();
         SyncOrg(topOrg);
     }
     System.Console.WriteLine("bua单位同步完成!");
     SmartBox.Console.Common.Log4NetHelper.Info("同步统一授权组织机构结束!");
 }
        public OrgTreeItem(Org org)
        {
            name = org.Name;
            parentId = org.Parent != null ? org.Id : "";

            foreach (Org item in org.Childs)
            {
                children = new List<object>();
                children.Add(new OrgTreeItem(item));
            }
            id = org.Id;
        }
Beispiel #22
0
        public static CertificateSecurityInformation VerifyAuth(Org.BouncyCastle.X509.X509Certificate cert, DateTime date, IX509Store certs, IList<CertificateList> crls, IList<BasicOcspResponse> ocsps, bool checkRevocation, bool checkTime)
        {
            CertificateSecurityInformation result = Verify(cert, date, certs, crls, ocsps, checkRevocation, checkTime);

            if (!cert.GetKeyUsage()[0])
            {
                result.securityViolations.Add(CertSecurityViolation.NotValidForUsage);
                trace.TraceEvent(TraceEventType.Warning, 0, "The key usage did not have the correct usage flag set");
            }

            return result;
        }
        public static byte[] GenerateDsaCertificateAsPkcs12(
            string friendlyName,
            string subjectName,
            string country,
            DateTime validStartDate,
            DateTime validEndDate,
            string password,
            Org.BouncyCastle.X509.X509Certificate caCert,
            AsymmetricKeyParameter caPrivateKey)
        {
            var keys = GenerateDsaKeys();

            #region build certificate
            var certGen = new X509V3CertificateGenerator();

            // build name attributes
            var nameOids = new ArrayList();
            nameOids.Add(Org.BouncyCastle.Asn1.X509.X509Name.CN);
            nameOids.Add(X509Name.O);
            nameOids.Add(X509Name.C);

            var nameValues = new ArrayList();
            nameValues.Add(friendlyName);
            nameValues.Add(subjectName);
            nameValues.Add(country);
            var subjectDN = new X509Name(nameOids, nameValues);

            // certificate fields
            certGen.SetSerialNumber(BigInteger.ValueOf(1));
            certGen.SetIssuerDN(caCert.SubjectDN);
            certGen.SetNotBefore(validStartDate);
            certGen.SetNotAfter(validEndDate);
            certGen.SetSubjectDN(subjectDN);
            certGen.SetPublicKey(keys.Public);
            certGen.SetSignatureAlgorithm("SHA1withDSA");

            // extended information
            certGen.AddExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert.GetPublicKey()));
            certGen.AddExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(keys.Public));
            #endregion

            // generate x509 certificate
            var cert = certGen.Generate(caPrivateKey);
            //ert.Verify(caCert.GetPublicKey());

            var chain = new Dictionary<string, Org.BouncyCastle.X509.X509Certificate>();
            //chain.Add("CertiFirmas CA", caCert);
            var caCn = caCert.SubjectDN.GetValues(X509Name.CN)[0].ToString();
            chain.Add(caCn, caCert);

            // store the file
            return GeneratePkcs12(keys, cert, friendlyName, password, chain);
        }
Beispiel #24
0
        public void TestChildAddParentFaile()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};
            var child1Child = new Org(Guid.NewGuid()) {Name = "child1child"};
            var child1Child_Chidl = new Org(Guid.NewGuid()) {Name = "child1child"};

            parent.Add(child1);
            child1.Add(child1Child);
            child1Child.Add(child1Child_Chidl);

            child1Child_Chidl.Add(parent);
        }
Beispiel #25
0
        public Code(Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode _code)
        {
            _id = _code.Id;

            _parentCode = _code.ParentCode;

            _names = new List<TextTypeWrapper>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.ITextTypeWrapper text in _code.Names)
                _names.Add(new TextTypeWrapper(text.Locale, text.Value));
            _descriptions = new List<TextTypeWrapper>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Base.ITextTypeWrapper text in _code.Descriptions)
                _descriptions.Add(new TextTypeWrapper(text.Locale, text.Value));
        }
        public void ProcessRequest(HttpRequest request, Org.Reddragonit.EmbeddedWebServer.Interfaces.Site site)
        {
            bool isComplete = false;
            try
            {
                if (Domain.AllDomainNames.Count == 0)
                    throw new Exception("No Domains have been created");

                if (Context.AllContextNames.Count < 2)
                    throw new Exception("You need a minimum of 2 contexts");

                if (SipProfile.AllSipProfileNames.Count < 2)
                    throw new Exception("You need a minimum of 2 sip profiles");

                User usr = User.Create(request.Parameters["UserName"],
                    request.Parameters["FirstName"],
                    request.Parameters["LastName"],
                    request.Parameters["Password"],
                    null,
                    null,
                    UserRight.All.ToArray());
                if (usr == null)
                    throw new Exception("Unable to create primary user");
                else
                {
                    usr.AllowedDomains = Domain.LoadAll().ToArray();
                    usr.Update();
                }

                foreach (string c in Context.AllContextNames)
                    CoreGenerator.RegenerateContextFile(c);
                foreach (SipProfile sp in SipProfile.LoadAll())
                    CoreGenerator.RegenerateSIPProfile(sp);
                foreach (Domain d in Domain.LoadAll())
                    CoreGenerator.RegenerateDomainFile(d);

                isComplete = true;
            }
            catch (Exception e)
            {
                request.ResponseWriter.WriteLine(e.Message);
            }
            if (!isComplete)
                request.ResponseStatus = HttpStatusCodes.Forbidden;
            else
            {
                request.ResponseStatus = HttpStatusCodes.OK;
                EventController.TriggerEvent(new SetupCompleteEvent());
            }
            request.SendResponse();
        }
Beispiel #27
0
        public void TestLevelDown()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};
            var child2 = new Org(Guid.NewGuid()) {Name = "child2"};
            var child3 = new Org(Guid.NewGuid()) {Name = "child2"};

            parent.Add(child1);
            parent.Add(child2);
            parent.Add(child3);

            Assert.IsTrue(child2.LevelDown(child3));

            Assert.AreEqual(child3, child2.Parent);
        }
 /// <summary>
 /// Adds an
 /// <see cref="Org.Apache.Http.Cookie.Cookie">HTTP cookie</see>
 /// , replacing any existing equivalent cookies.
 /// If the given cookie has already expired it will not be added, but existing
 /// values will still be removed.
 /// </summary>
 /// <param name="cookie">
 /// the
 /// <see cref="Org.Apache.Http.Cookie.Cookie">cookie</see>
 /// to be added
 /// </param>
 /// <seealso cref="AddCookies(Org.Apache.Http.Cookie.Cookie[])">AddCookies(Org.Apache.Http.Cookie.Cookie[])
 ///     </seealso>
 public virtual void AddCookie(Org.Apache.Http.Cookie.Cookie cookie)
 {
     lock (this)
     {
         if (cookie != null)
         {
             // first remove any old cookie that is equivalent
             cookies.Remove(cookie);
             if (!cookie.IsExpired(new DateTime()))
             {
                 cookies.AddItem(cookie);
             }
         }
     }
 }
Beispiel #29
0
 public int EditOrg(string orgCode, string NewCode)
 {
     CQGJModel.Org org = new Org();
     try
     {
         org = (from o in cqgj.Org where o.OrgCode == orgCode select o).First();
         org.OrgCode = NewCode;
         cqgj.SaveChanges();
         return org.OrgID;
     }
     catch
     {
     }
     return 1;
 }
Beispiel #30
0
        /// <summary>
        /// 添加教师
        /// </summary>
        public void AddTeacher()
        {
            SchoolAddTeacherViewData viewData = new SchoolAddTeacherViewData();

            Teacher teacher = new Teacher();
            if (GetString("teacherName") != "")
            {
                teacher.TeacherName = GetString("teacherName");
                teacher.Cellphone = GetString("Cellphone");
                teacher.Address = GetString("Address");
                teacher.Edu = GetString("Edu");
                teacher.Gender = GetString("Gender");
                teacher.Nation = GetString("Nation");
                teacher.IDCard = GetString("IDCard");
                teacher.Political = GetString("Political");
                teacher.Status = 1;
                if (HttpContext.Session["Photo"] != null && HttpContext.Session["PhotoType"] != null)
                {
                    teacher.PhotoType = HttpContext.Session["PhotoType"].ToString();
                    teacher.Photo = (byte[])HttpContext.Session["Photo"];

                }
                string schoolcode = GetString("OrgCode");
                //判断只添加teacher 或是添加org和teacher
                List<Org> lsOrg = (from c in CQGJ.Org
                                   where c.OrgCode == schoolcode
                                   select c).ToList();
                if (lsOrg.Count == 0)
                {
                    Org org = new Org();
                    org.OrgCode = schoolcode;
                    //老师和施教机对构是多对-
                    teacher.Org = org;
                    CQGJ.AddToOrg(org);
                }
                else
                {
                    Org org = lsOrg.First();
                    teacher.Org = org;
                }
                CQGJ.AddToTeacher(teacher);
                CQGJ.SaveChanges();
                RedirectToAction("teacherlist", "school");
            }

            viewData.Schools = cqgjPassport.GetSchoolOrglist().ToList();
            RenderView("AddTeacher", viewData);
        }
Beispiel #31
0
        protected override void Up()
        {
            this.RunCode(db =>
            {
                //由于本类没有支持 Down 操作,所以这里面的 Up 需要防止重入。
                var orgRepository = RF.Concrete <OrgRepository>();
                var list          = orgRepository.GetAll();
                if (list.Count == 0)
                {
                    using (var tran = RF.TransactionScope(orgRepository))
                    {
                        //Position
                        var pos  = new Position();
                        pos.Code = "01";
                        pos.Name = "系统管理员";
                        RF.Save(pos);

                        //User
                        var admin  = new User();
                        admin.Code = "admin";
                        admin.Name = "admin";
                        RF.Save(admin);

                        //Org
                        var org = new Org
                        {
                            TreeIndex       = "001.",
                            Name            = "IT系统管理部",
                            OrgPositionList =
                            {
                                new OrgPosition
                                {
                                    Position            = pos,
                                    OrgPositionUserList =
                                    {
                                        new OrgPositionUser
                                        {
                                            User = admin
                                        }
                                    }
                                }
                            }
                        };
                        orgRepository.Save(org);

                        tran.Complete();
                    }

                    ////User
                    //var userRepo = RF.Concreate<UserRepository>();
                    //for (int i = 0; i < 100; i++)
                    //{
                    //    var user = new User();
                    //    user.Code = "testUserCode" + i;
                    //    user.Name = "testUserName" + i;
                    //    userRepo.Save(user);
                    //}

                    ////Position
                    //var pRepo = RF.Concreate<PositionRepository>();
                    //for (int i = 0; i < 100; i++)
                    //{
                    //    var p = new Position();
                    //    p.Code = "01" + i;
                    //    p.Name = "系统管理员" + i;
                    //    pRepo.Save(p);
                    //}
                }
            });
        }