public static byte[] GetSignedCertificate(AlgParSet parameters, Subj subj) { X509Certificate root = new X509CertificateParser().ReadCertificate(GetRootCertificate()); Cert data = CreateDatabaseInfoFromCertificate(root); var keys = GenerateKeyPair(parameters); string serial = string.Empty; do { serial = BigIntegers.CreateRandomBigInteger(512, new SecureRandom()).ToString(); }while (DatabaseInstance.GetInstance().Certs.FirstOrDefault(elm => elm.SerialNumber_Cert == serial) != null); Cert certificate = new Cert { Ver_Cert = DatabaseInstance.GetInstance().Vers.FirstOrDefault(), SignAlg_Cert = new SignAlg { AlgParSet_SignAlg = parameters, PrivateKey_SignAlg = PrivateKeyInfoFactory.CreatePrivateKeyInfo(keys.Private).ToAsn1Object().GetEncoded(), PublicKey_SignAlg = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(keys.Public).ToAsn1Object().GetEncoded() }, Issuer_Cert = data.Issuer_Cert, Subj_Cert = subj, SerialNumber_Cert = serial, ValidFrom_Cert = DateTime.Now, ValidBy_Cert = DateTimeOffset.Now.AddYears(5).UtcDateTime, SignSerialNumber_Cert = data.SerialNumber_Cert }; var cert = CreateCertificateFromDatabaseInfo(certificate); certificate.SignValue_Cert = string.Join("", BitConverter.ToString(cert.GetSignature()).Split('-')); DatabaseInstance.GetInstance().Certs.Add(certificate); DatabaseInstance.GetInstance().SaveChanges(); return(cert.GetEncoded()); }
public static Queue <RT, A, Unit> Queue <RT, A>() where RT : struct, HasCancel <RT> { var s = new Subj <A>(); var p = Producer.observe <RT, A>(s); return(new Queue <RT, A, Unit>( p, x => { s.OnNext(x); return unit; }, e => { s.OnError(e); return unit; }, () => { s.OnCompleted(); return unit; })); }
public void CreateNodes(PolarTripleStore store) { Subj.CreateNode(store); Pred.CreateNode(store); Obj.CreateNode(store); Graph.CreateNode(store); // GraphIsDataProperty.Sync(o.graph, p.graph); VariableNode sVariableNode = this.Subj as VariableNode; VariableNode pVariableNode = this.Pred as VariableNode; VariableNode oVariableNode = this.Obj as VariableNode; if (sVariableNode != null && sVariableNode.isNew) { sVariableNode.isNew = false; if (pVariableNode != null && pVariableNode.isNew) { pVariableNode.isNew = false; if (oVariableNode != null && oVariableNode.isNew) { oVariableNode.isNew = false; SelectVariableValuesOrFilter = RPackComplexExtensionInt.SPO(store, sVariableNode, pVariableNode, oVariableNode, Graph); } else { SelectVariableValuesOrFilter = RPackComplexExtensionInt.SPo(store, sVariableNode, pVariableNode, this.Obj); } } else { if (oVariableNode != null && oVariableNode.isNew) { SelectVariableValuesOrFilter = RPackComplexExtensionInt.SpO(store, sVariableNode, this.Pred, oVariableNode); } else { SelectVariableValuesOrFilter = RPackComplexExtensionInt.Spo(store, sVariableNode, this.Pred, this.Obj); } } } else { if (pVariableNode != null && pVariableNode.isNew) { pVariableNode.isNew = false; if (oVariableNode != null && oVariableNode.isNew) { SelectVariableValuesOrFilter = RPackComplexExtensionInt.sPO(store, this.Subj, pVariableNode, oVariableNode); oVariableNode.isNew = false; } else { SelectVariableValuesOrFilter = RPackComplexExtensionInt.sPo(store, this.Subj, pVariableNode, this.Obj); } } else { if (oVariableNode != null && oVariableNode.isNew) { SelectVariableValuesOrFilter = RPackComplexExtensionInt.spO(store, this.Subj, this.Pred, oVariableNode); oVariableNode.isNew = false; } else { SelectVariableValuesOrFilter = RPackComplexExtensionInt.spo(store, this.Subj, this.Pred, this.Obj); } } } }