Ejemplo n.º 1
0
		internal Pkcs9ContentType (string contentType) 
		{
			(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
			_contentType = new Oid (contentType);
			RawData = Encode ();
			_encoded = null;
		}
 private static void CreateTestProject(bool useOAuthEndpoints)
 {
     V1Connector connector;
     if (useOAuthEndpoints)
     {
         connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
             .WithUserAgentHeader("IntegrationTests", "1.0")
             .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
             .UseOAuthEndpoints()
             .Build();
     }
     else
     {
         connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
             .WithUserAgentHeader("IntegrationTests", "1.0")
             .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
             .Build();
     }
     var services = new Services(connector);
     var assetType = services.Meta.GetAssetType("Scope");
     var nameAttribute = assetType.GetAttributeDefinition("Name");
     var projectId = services.GetOid("Scope:0");
     var newAsset = services.New(assetType, projectId);
     newAsset.SetAttributeValue(nameAttribute, TestProjectName);
     services.Save(newAsset);
     _testProjectId = newAsset.Oid.Momentless;
 }
Ejemplo n.º 3
0
		public object run()
		{
			try {				
				Oid krb5Oid = new Oid (_mech);
				GSSManager manager = GSSManager.getInstance ();
				GSSName clientName = 
					manager.createName(_clientName, GSSName__Finals.NT_USER_NAME);
				GSSCredential clientCreds =
					manager.createCredential(clientName,
					GSSContext__Finals.INDEFINITE_LIFETIME,
					krb5Oid,
					GSSCredential__Finals.INITIATE_ONLY);

//				try {
					GSSName serverName = manager.createName (_name, GSSName__Finals.NT_HOSTBASED_SERVICE, krb5Oid);
					GSSContext context = manager.createContext (serverName, krb5Oid, clientCreds, GSSContext__Finals.INDEFINITE_LIFETIME);

					context.requestMutualAuth(true);  
					context.requestConf (_encryption);
					if (!_encryption || _signing)
						context.requestInteg (!_encryption || _signing); 
					context.requestCredDeleg (_delegation);

					return context;
//				}
//				finally {
//					// Calling this throws GSSException: Operation unavailable...
//					clientCreds.dispose();
//				}
			}
			catch (GSSException e) {
				throw new PrivilegedActionException (e);
			}
		}
Ejemplo n.º 4
0
        public static void TestStrStrConstructor()
        {
            Oid oid;

            // No validation at all.
            oid = new Oid((string)null, (string)null);
            Assert.Equal(null, oid.FriendlyName);
            Assert.Equal(null, oid.Value);

            // Can omit friendly-name - FriendlyName property demand-computes it.
            oid = new Oid(SHA1_Oid, (string)null);
            Assert.Equal(SHA1_Name, oid.FriendlyName);
            Assert.Equal(SHA1_Oid, oid.Value);

            oid = new Oid(SHA1_Oid, "BOGUS-NAME");
            Assert.Equal("BOGUS-NAME", oid.FriendlyName);
            Assert.Equal(SHA1_Oid, oid.Value);

            // Can omit oid, Value property does no on-demand conversion.
            oid = new Oid((string)null, SHA1_Name);
            Assert.Equal(SHA1_Name, oid.FriendlyName);
            Assert.Equal(null, oid.Value);

            oid = new Oid("BOGUS-OID", SHA1_Name);
            Assert.Equal(SHA1_Name, oid.FriendlyName);
            Assert.Equal("BOGUS-OID", oid.Value);


            return;
        }
Ejemplo n.º 5
0
		public Pkcs9AttributeObject (Oid oid, byte[] encodedData) 
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");
			base.Oid = oid;
			RawData = encodedData;
		}
Ejemplo n.º 6
0
 public ObjectViewModel(object obj, FieldViewModel parentView, int arrayIndex, bool encodedOid, SessionBase session)
   : base(parentView, true)
 {
   m_session = session;
   if (encodedOid)
   {
     if (obj.GetType() == typeof(UInt64))
     {
       m_objectId = (UInt64)obj;
       m_objectAsString = "[" + arrayIndex.ToString() + "] " + new Oid(m_objectId).ToString();
     }
     else
     {
       Oid oid = new Oid(parentView.ParentId);
       oid = new Oid(oid.Database, (UInt32)obj);
       m_objectId = oid.Id;
       m_objectAsString = "[" + arrayIndex.ToString() + "] " + new OidShort(oid.IdShort).ToString();
     }
   }
   else
   {
     IOptimizedPersistable pObj = obj as IOptimizedPersistable;
     if (pObj == null)
       session.GlobalObjWrapperGet(obj, out pObj);
     if (pObj != null)
       m_objectId = pObj.Id;
     m_session = session;
     if (pObj != null && pObj.WrappedObject != obj)
       m_objectAsString = "[" + arrayIndex.ToString() + "] " + pObj.WrappedObject.ToString() + " " + new Oid(pObj.Id);
     else
       m_objectAsString = "[" + arrayIndex.ToString() + "] " + obj.ToString();
   }
 }
 /// <summary>
 /// Initializes a new instance of the 'SearchIntermediaNodeDataEventArgs' class.
 /// </summary>
 /// <param name="parentNodeOid">Parent node Oid.</param>
 /// <param name="nodeId">Node identifier.</param>
 /// <param name="completeOidPath">Oids list and its Ids of the complete path for a node.</param>
 public SearchIntermediaNodeDataEventArgs(Oid parentNodeOid, string nodeId, List<KeyValuePair<string, Oid>> completeOidPath)
 {
     mParentNodeOid = parentNodeOid;
     mNodeId = nodeId;
     mCompleteOidPath = completeOidPath;
     mLastBlock = true;
 }
Ejemplo n.º 8
0
 public PublicKey(Oid oid, AsnEncodedData parameters, AsnEncodedData keyValue)
 {
     _oid = new Oid(oid);
     EncodedParameters = new AsnEncodedData(parameters);
     EncodedKeyValue = new AsnEncodedData(keyValue);
     return;
 }
Ejemplo n.º 9
0
        public static void LookupOidByFriendlyName_Ctor(string oidValue, string friendlyName)
        {
            Oid oid = new Oid(friendlyName);

            Assert.Equal(oidValue, oid.Value);
            Assert.Equal(friendlyName, oid.FriendlyName);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Fills and return a DataSet processing the data set file and starting with the oid.
        /// </summary>
        /// <param name="oid">Oid of the instance.</param>
        /// <param name="dataSetFile">Path of the data set file.</param>
        /// <returns>A DataSet object with the suitable data.</returns>
        public static DataSet GetData(Oid oid, string dataSetFile)
        {
            DataSet lDataSet = new DataSet();
            try
            {
                lDataSet.ReadXmlSchema(dataSetFile);
            }
            catch (Exception e)
            {
                object[] lArgs = new object[1];
                lArgs[0] = dataSetFile;
                string lErrorMessage = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ERROR_DATASET_GENERICLOAD, LanguageConstantValues.L_ERROR_DATASET_GENERICLOAD, lArgs);

                Exception newException = new Exception(lErrorMessage, e);
                throw newException;
            }

            // Analize the Tables in the DataSet.
            DataTable lStartingClass = GetDataTable(lDataSet, oid.ClassName);

            string lDisplaySet = GetDisplaySet(lStartingClass);
            DataTable rootInstance = Logics.Logic.ExecuteQueryInstance(Logics.Logic.Agent, oid, lDisplaySet);
            // Add data to DataSet.
            lStartingClass.Merge(rootInstance);

            // Process Table relationships.
            ProcessTableRelationships(lDataSet, lStartingClass, oid);

            return lDataSet;
        }
Ejemplo n.º 11
0
		public X509KeyUsageExtension (X509KeyUsageFlags keyUsages, bool critical)
		{
			_oid = new Oid (oid, friendlyName);
			base.Critical = critical;
			_keyUsages = GetValidFlags (keyUsages);
			RawData = Encode ();
		}
Ejemplo n.º 12
0
        public static void LookupUnknownOid()
        {
            Oid oid = new Oid(Bogus_Name);

            Assert.Equal(Bogus_Name, oid.Value);
            Assert.Null(oid.FriendlyName);
        }
 /// <summary>
 /// Initializes a new instance of the 'GetNextNodeDataBlockEventArgs' class.
 /// </summary>
 /// <param name="nodeId">Node identifier.</param>
 /// <param name="lastOid">Last Oid.</param>
 /// <param name="completeOidPath">Oids list and its Ids of the complete path for a node.</param>
 public GetNextNodeDataBlockEventArgs(string nodeId, Oid lastOid, List<KeyValuePair<string, Oid>> completeOidPath)
 {
     NodeId = nodeId;
     mLastOid = lastOid;
     mCompleteOidPath = completeOidPath;
     mLastBlock = true;
 }
Ejemplo n.º 14
0
        public void TestFollowNonReference(){
            var id = new Oid("BAD067c30a57000000008ecb");
            var rf = new DBRef("refs", id);

            var target = DB.FollowReference(rf);
            Assert.IsNull(target, "FollowReference returned wasn't null");
        }
Ejemplo n.º 15
0
        public void TestFormatJ()
        {
            const string hex = "4a7067c30a57000000008ecb";
            var oid = new Oid(hex);

            Assert.AreEqual("\"" + hex + "\"", oid.ToString("J"));
        }
Ejemplo n.º 16
0
        public void TestDecode()
        {
            const string hex = "4a7067c30a57000000008ecb";
            var oid = new Oid(hex);

            Assert.AreEqual(hex, oid.ToString());
        }
Ejemplo n.º 17
0
 public void TestDate()
 {
     const string hex = "4B458B95D114BE541B000000";
     var oid = new Oid(hex);
     //Expected: 2010-01-07 02:24:56.633
     var expected = new DateTime(2010, 1, 7, 7, 21, 57, DateTimeKind.Utc);
     Assert.AreEqual(expected, oid.Created);
 }
Ejemplo n.º 18
0
        public static string DataRequest(Oid TheOID, object ExcelDocument)
        {
            object[] Parameters;
            Parameters = new Object[1];
            Parameters[0] = OIDFields(TheOID, ExcelDocument);

            return (string)ExcelDocument.GetType().InvokeMember("DataRequest", BindingFlags.InvokeMethod, null, ExcelDocument, Parameters);
        }
Ejemplo n.º 19
0
        public static string DataRequest(Oid TheOID, string PathTemplate)
        {
            string rslt;
            object ExcelObject = GetExcel();
            rslt = DataRequest(TheOID, GetExcelTemplate(GetExcelWorkbooks(ExcelObject), PathTemplate));

            return rslt;
        }
Ejemplo n.º 20
0
        public ActionResult Delete(string id)
        {
            var oid = new Oid(id);
            _repository.DeleteById(oid);

            TempData["notice"] = "Note deleted";
            return RedirectToAction("Index");
        }
		public X509EnhancedKeyUsageExtension (AsnEncodedData encodedEnhancedKeyUsages, bool critical)
		{
			// ignore the Oid provided by encodedKeyUsage (our rules!)
			_oid = new Oid (oid, friendlyName);
			_raw = encodedEnhancedKeyUsages.RawData;
			base.Critical = critical;
			_status = Decode (this.RawData);
		}
 public void Setup()
 {
     var environment = new EnvironmentContext();
     _metaModel = environment.MetaModel;
     _services = environment.Services;
     _storyAssetType = _metaModel.GetAssetType("Story");
     _projectId = LegacyIntegrationTestHelper.ProjectId;
 }
Ejemplo n.º 23
0
        public static void Oid_StringString_NullFriendlyName(string oidValue, string expectedFriendlyName)
        {
            // Can omit friendly-name - FriendlyName property demand-computes it.
            Oid oid = new Oid(oidValue, null);

            Assert.Equal(oidValue, oid.Value);
            Assert.Equal(expectedFriendlyName, oid.FriendlyName);
        }
Ejemplo n.º 24
0
        public static void Oid_StringString_NullValue(string friendlyName)
        {
            // Can omit oid, Value property does no on-demand conversion.
            Oid oid = new Oid(null, friendlyName);

            Assert.Null(oid.Value);
            Assert.Equal(friendlyName, oid.FriendlyName);
        }
Ejemplo n.º 25
0
        public static void Oid_StringString_BothNull()
        {
            // No validation at all.
            Oid oid = new Oid(null, null);

            Assert.Null(oid.Value);
            Assert.Null(oid.FriendlyName);
        }
Ejemplo n.º 26
0
		public X509Extension (Oid oid, byte[] rawData, bool critical)
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");
			Oid = oid;
			RawData = rawData;
			_critical = critical;
		}
		public X509SubjectKeyIdentifierExtension (AsnEncodedData encodedSubjectKeyIdentifier, bool critical)
		{
			// ignore the Oid provided by encodedKeyUsage (our rules!)
			_oid = new Oid (oid, friendlyName);
			_raw = encodedSubjectKeyIdentifier.RawData;
			base.Critical = critical;
			_status = Decode (this.RawData);
		}
Ejemplo n.º 28
0
 public bool IsCurveValid(Oid oid)
 {
     if (!string.IsNullOrEmpty(oid.Value))
     {
         // Value is passed before FriendlyName
         return IsValueOrFriendlyNameValid(oid.Value);
     }
     return IsValueOrFriendlyNameValid(oid.FriendlyName);
 }
Ejemplo n.º 29
0
 public void TestBase64Roundtrip()
 {
     Oid a = Oid.NewOid();
     string val = a.ToBase64String();
     string val2 = a.ToString("b", null);
     Assert.That(val, Is.EqualTo(val2));
     Oid b = new Oid(val, "b");
     Assert.That(b, Is.EqualTo(a));
 }
Ejemplo n.º 30
0
		// constructors

		public CmsSigner () 
		{
			_signer = SubjectIdentifierType.IssuerAndSerialNumber;
			_digest = new Oid ("1.3.14.3.2.26");
			_options = X509IncludeOption.ExcludeRoot;
			_signed = new CryptographicAttributeObjectCollection ();
			_unsigned = new CryptographicAttributeObjectCollection ();
			_coll = new X509Certificate2Collection ();
		}
Ejemplo n.º 31
0
        public static AlgorithmIdentifier ToAlgorithmIdentifier(this CRYPT_ALGORITHM_IDENTIFIER cryptAlgorithmIdentifer)
        {
            string oidValue = cryptAlgorithmIdentifer.pszObjId.ToStringAnsi();
            AlgId  algId    = oidValue.ToAlgId();

            int keyLength;

            switch (algId)
            {
            case AlgId.CALG_RC2:
            {
                if (cryptAlgorithmIdentifer.Parameters.cbData == 0)
                {
                    keyLength = 0;
                }
                else
                {
                    CRYPT_RC2_CBC_PARAMETERS rc2Parameters;
                    unsafe
                    {
                        int cbSize = sizeof(CRYPT_RC2_CBC_PARAMETERS);
                        if (!Interop.Crypt32.CryptDecodeObject(CryptDecodeObjectStructType.PKCS_RC2_CBC_PARAMETERS, cryptAlgorithmIdentifer.Parameters.pbData, (int)(cryptAlgorithmIdentifer.Parameters.cbData), &rc2Parameters, ref cbSize))
                        {
                            throw Marshal.GetLastWin32Error().ToCryptographicException();
                        }
                    }

                    switch (rc2Parameters.dwVersion)
                    {
                    case CryptRc2Version.CRYPT_RC2_40BIT_VERSION:
                        keyLength = KeyLengths.Rc2_40Bit;
                        break;

                    case CryptRc2Version.CRYPT_RC2_56BIT_VERSION:
                        keyLength = KeyLengths.Rc2_56Bit;
                        break;

                    case CryptRc2Version.CRYPT_RC2_64BIT_VERSION:
                        keyLength = KeyLengths.Rc2_64Bit;
                        break;

                    case CryptRc2Version.CRYPT_RC2_128BIT_VERSION:
                        keyLength = KeyLengths.Rc2_128Bit;
                        break;

                    default:
                        keyLength = 0;
                        break;
                    }
                }
                break;
            }

            case AlgId.CALG_RC4:
            {
                int saltLength = 0;
                if (cryptAlgorithmIdentifer.Parameters.cbData != 0)
                {
                    using (SafeHandle sh = Interop.Crypt32.CryptDecodeObjectToMemory(CryptDecodeObjectStructType.X509_OCTET_STRING, cryptAlgorithmIdentifer.Parameters.pbData, (int)cryptAlgorithmIdentifer.Parameters.cbData))
                    {
                        unsafe
                        {
                            DATA_BLOB *pDataBlob = (DATA_BLOB *)(sh.DangerousGetHandle());
                            saltLength = (int)(pDataBlob->cbData);
                        }
                    }
                }

                // For RC4, keyLength = 128 - (salt length * 8).
                keyLength = KeyLengths.Rc4Max_128Bit - saltLength * 8;
                break;
            }

            case AlgId.CALG_DES:
                // DES key length is fixed at 64 (or 56 without the parity bits).
                keyLength = KeyLengths.Des_64Bit;
                break;

            case AlgId.CALG_3DES:
                // 3DES key length is fixed at 192 (or 168 without the parity bits).
                keyLength = KeyLengths.TripleDes_192Bit;
                break;

            default:
                // We've exhausted all the algorithm types that the desktop used to set the KeyLength for. Key lengths are not a viable way of
                // identifying algorithms in the long run so we will not extend this list any further.
                keyLength = 0;
                break;
            }

            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(Oid.FromOidValue(oidValue, OidGroup.All), keyLength);

            return(algorithmIdentifier);
        }
Ejemplo n.º 32
0
 public IndexData AddObject(IndexData indexData, Oid obj, QueryParameters queryParameters)
 {
     FieldInfo[] objFields   = obj.GetType().GetFields();
     String[]    attribiutes = objFields.Select(p => p.Name).ToArray();
     return(AddObject(indexData, obj, attribiutes, queryParameters));
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Execute a query related with other instance.
        /// </summary>
        /// <param name="agent">Application agent.</param>
        /// <param name="linkItems">List of related instance oids (path - role).</param>
        /// <param name="displaySet">List of attributes to return.</param>
        /// <param name="orderCriteria">Order criteria name.</param>
        /// <param name="lastOid">Oid from which to search (not included).</param>
        /// <param name="blockSize">Number of instances to return (0 for all population).</param>
        /// <param name="lastBlock">Indicates if it is last block.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryRelated(Oid agent, Dictionary <string, Oid> linkItems, string displaySet, string orderCriteria, NavigationalFiltering navigationalFiltering, Oid lastOid, int blockSize, ref bool lastBlock)
        {
            DataTable lDataTable = Logic.Adaptor.ExecuteQueryRelated(agent, "Revision", linkItems, displaySet, orderCriteria, navigationalFiltering, lastOid, blockSize);

            // Last block
            if (lDataTable.ExtendedProperties.Contains("LastBlock"))
            {
                lastBlock = (bool)lDataTable.ExtendedProperties["LastBlock"];
            }
            else
            {
                lastBlock = false;
            }

            return(lDataTable);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Creates an extension from ASN.1 encoded data.
 /// </summary>
 public X509AuthorityKeyIdentifierExtension(Oid oid, byte[] rawData, bool critical)
     :
     base(oid, rawData, critical)
 {
     Parse(rawData);
 }
Ejemplo n.º 35
0
        internal SignerInfoAsn Sign(
            ReadOnlyMemory <byte> data,
            string?contentTypeOid,
            bool silent,
            out X509Certificate2Collection chainCerts)
        {
            HashAlgorithmName hashAlgorithmName = PkcsHelpers.GetDigestAlgorithm(DigestAlgorithm);
            IncrementalHash   hasher            = IncrementalHash.CreateHash(hashAlgorithmName);

            hasher.AppendData(data.Span);
            byte[] dataHash = hasher.GetHashAndReset();

            SignerInfoAsn newSignerInfo = default;

            newSignerInfo.DigestAlgorithm.Algorithm = DigestAlgorithm.Value !;

            // If the user specified attributes (not null, count > 0) we need attributes.
            // If the content type is null we're counter-signing, and need the message digest attr.
            // If the content type is otherwise not-data we need to record it as the content-type attr.
            if (SignedAttributes?.Count > 0 || contentTypeOid != Oids.Pkcs7Data)
            {
                List <AttributeAsn> signedAttrs = BuildAttributes(SignedAttributes);

                AsnWriter writer = new AsnWriter(AsnEncodingRules.DER);
                writer.WriteOctetString(dataHash);

                signedAttrs.Add(
                    new AttributeAsn
                {
                    AttrType   = Oids.MessageDigest,
                    AttrValues = new[] { new ReadOnlyMemory <byte>(writer.Encode()) },
                });

                if (contentTypeOid != null)
                {
                    writer.Reset();
                    writer.WriteObjectIdentifierForCrypto(contentTypeOid);

                    signedAttrs.Add(
                        new AttributeAsn
                    {
                        AttrType   = Oids.ContentType,
                        AttrValues = new[] { new ReadOnlyMemory <byte>(writer.Encode()) },
                    });
                }

                // Use the serializer/deserializer to DER-normalize the attribute order.
                SignedAttributesSet signedAttrsSet = default;
                signedAttrsSet.SignedAttributes = PkcsHelpers.NormalizeAttributeSet(
                    signedAttrs.ToArray(),
                    normalized => hasher.AppendData(normalized));

                // Since this contains user data in a context where BER is permitted, use BER.
                // There shouldn't be any observable difference here between BER and DER, though,
                // since the top level fields were written by NormalizeSet.
                AsnWriter attrsWriter = new AsnWriter(AsnEncodingRules.BER);
                signedAttrsSet.Encode(attrsWriter);
                newSignerInfo.SignedAttributes = attrsWriter.Encode();

                dataHash = hasher.GetHashAndReset();
            }

            switch (SignerIdentifierType)
            {
            case SubjectIdentifierType.IssuerAndSerialNumber:
                byte[] serial = Certificate !.GetSerialNumber();
                Array.Reverse(serial);

                newSignerInfo.Sid.IssuerAndSerialNumber = new IssuerAndSerialNumberAsn
                {
                    Issuer       = Certificate.IssuerName.RawData,
                    SerialNumber = serial,
                };

                newSignerInfo.Version = 1;
                break;

            case SubjectIdentifierType.SubjectKeyIdentifier:
                newSignerInfo.Sid.SubjectKeyIdentifier = PkcsPal.Instance.GetSubjectKeyIdentifier(Certificate !);
                newSignerInfo.Version = 3;
                break;

            case SubjectIdentifierType.NoSignature:
                newSignerInfo.Sid.IssuerAndSerialNumber = new IssuerAndSerialNumberAsn
                {
                    Issuer       = SubjectIdentifier.DummySignerEncodedValue,
                    SerialNumber = new byte[1],
                };
                newSignerInfo.Version = 1;
                break;

            default:
                Debug.Fail($"Unresolved SignerIdentifierType value: {SignerIdentifierType}");
                throw new CryptographicException();
            }

            if (UnsignedAttributes != null && UnsignedAttributes.Count > 0)
            {
                List <AttributeAsn> attrs = BuildAttributes(UnsignedAttributes);

                newSignerInfo.UnsignedAttributes = PkcsHelpers.NormalizeAttributeSet(attrs.ToArray());
            }

            bool signed;
            Oid? signatureAlgorithm;
            ReadOnlyMemory <byte> signatureValue;

            if (SignerIdentifierType == SubjectIdentifierType.NoSignature)
            {
                signatureAlgorithm = new Oid(Oids.NoSignature, null);
                signatureValue     = dataHash;
                signed             = true;
            }
            else
            {
                signed = CmsSignature.Sign(
                    dataHash,
                    hashAlgorithmName,
                    Certificate !,
                    PrivateKey,
                    silent,
                    out signatureAlgorithm,
                    out signatureValue);
            }

            if (!signed)
            {
                throw new CryptographicException(SR.Cryptography_Cms_CannotDetermineSignatureAlgorithm);
            }

            newSignerInfo.SignatureValue = signatureValue;
            newSignerInfo.SignatureAlgorithm.Algorithm = signatureAlgorithm !.Value !;

            X509Certificate2Collection certs = new X509Certificate2Collection();

            certs.AddRange(Certificates);

            if (SignerIdentifierType != SubjectIdentifierType.NoSignature)
            {
                if (IncludeOption == X509IncludeOption.EndCertOnly)
                {
                    certs.Add(Certificate !);
                }
                else if (IncludeOption != X509IncludeOption.None)
                {
                    X509Chain chain = new X509Chain();
                    chain.ChainPolicy.RevocationMode    = X509RevocationMode.NoCheck;
                    chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;

                    if (!chain.Build(Certificate !))
                    {
                        foreach (X509ChainStatus status in chain.ChainStatus)
                        {
                            if (status.Status == X509ChainStatusFlags.PartialChain)
                            {
                                throw new CryptographicException(SR.Cryptography_Cms_IncompleteCertChain);
                            }
                        }
                    }

                    X509ChainElementCollection elements = chain.ChainElements;
                    int count = elements.Count;
                    int last  = count - 1;

                    if (last == 0)
                    {
                        // If there's always one cert treat it as EE, not root.
                        last = -1;
                    }

                    for (int i = 0; i < count; i++)
                    {
                        X509Certificate2 cert = elements[i].Certificate;

                        if (i == last &&
                            IncludeOption == X509IncludeOption.ExcludeRoot &&
                            cert.SubjectName.RawData.AsSpan().SequenceEqual(cert.IssuerName.RawData))
                        {
                            break;
                        }

                        certs.Add(cert);
                    }
                }
            }

            chainCerts = certs;
            return(newSignerInfo);
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Execute a query to retrieve an instance.
 /// </summary>
 /// <param name="agent">Application agent.</param>
 /// <param name="oid">Specific 'PasajeroAeronaveOid' Oid of the instance to be searched.</param>
 /// <param name="displaySet">Display set that will be retrieved.</param>
 /// <returns>A DataTable with the instance searched.</returns>
 public static DataTable ExecuteQueryInstance(Oid agent, PasajeroAeronaveOid oid, string displaySet)
 {
     return(Logic.Adaptor.ExecuteQueryInstance(agent, "PasajeroAeronave", string.Empty, oid, displaySet));
 }
Ejemplo n.º 37
0
        public void CreateRequest(V1Connector CurrentV1Connection, List <Message> CurrentEmails)
        {
            V1XMLHelper  V1XML        = new V1XMLHelper();
            V1Logging    Logs         = new V1Logging();
            string       ProjectScope = "Something for Testing";
            string       EmailBody;
            MessagePart  MessageParts;
            SMTPResponse V1Response = new SMTPResponse();
            MailChecker  MailCheck  = new MailChecker();

            IServices services = new Services(CurrentV1Connection);


            try
            {
                foreach (Message MailItem in CurrentEmails)
                {
                    for (int ToCtr = 0; ToCtr < MailItem.Headers.To.Count; ToCtr++)
                    {
                        ProjectScope = V1XML.GetProjectScope(MailItem.Headers.To[ToCtr].Address);
                        if (ProjectScope != null)
                        {
                            Oid                  projectId     = services.GetOid(ProjectScope);
                            IAssetType           requestType   = services.Meta.GetAssetType("Request");
                            Asset                NewRequest    = services.New(requestType, projectId);
                            IAttributeDefinition nameAttribute = requestType.GetAttributeDefinition("Name");
                            NewRequest.SetAttributeValue(nameAttribute, MailItem.Headers.Subject.ToString());

                            MessageParts = MailItem.FindFirstHtmlVersion();
                            if (MessageParts == null)
                            {
                                MessageParts = MailItem.FindFirstPlainTextVersion();
                            }
                            EmailBody = MessageParts.GetBodyAsText();

                            Logs.LogEvent("Operation - Creating Request for " + MailItem.Headers.To[ToCtr].Address);

                            IAttributeDefinition descriptionAttribute = requestType.GetAttributeDefinition("Description");
                            NewRequest.SetAttributeValue(descriptionAttribute, EmailBody);
                            IAttributeDefinition RequestedByAttribute = requestType.GetAttributeDefinition("RequestedBy");
                            NewRequest.SetAttributeValue(RequestedByAttribute, MailItem.Headers.From.ToString());
                            services.Save(NewRequest);

                            IAttributeDefinition RequestIDAttribute = requestType.GetAttributeDefinition("Number");
                            Query IDQuery = new Query(NewRequest.Oid);
                            IDQuery.Selection.Add(RequestIDAttribute);
                            QueryResult ResultID = services.Retrieve(IDQuery);
                            Asset       Request  = ResultID.Assets[0];

                            //NewRequest.GetAttribute(RequestIDAttribute).Value
                            Logs.LogEvent("Operation - Sending Response to Request Sender.");
                            //Commented out the Response back to the Sender per John Waedekin
                            //V1Response.SendResponse(MailItem, Request.GetAttribute(RequestIDAttribute).Value + " " + NewRequest.GetAttribute(nameAttribute).Value, ProjectScope);
                            MailCheck.DeleteMessagesOnServer(MailItem, ProjectScope);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logs.LogEvent("ERROR - Creating Request - " + ex.InnerException.Message);
            }
        }
Ejemplo n.º 38
0
 /// <inheritdoc/>
 protected X509CrlDistributionPointsExtension(Oid oid, byte[] rawData,
                                              bool critical) : base(oid, rawData, critical)
 {
     Parse(rawData);
 }
Ejemplo n.º 39
0
 public override string ToString()
 {
     return(UserName + " " + Oid.ToString());
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Creates an extension from ASN.1 encoded data.
 /// </summary>
 public X509SubjectAltNameExtension(Oid oid, byte[] rawData, bool critical)
     :
     base(oid, rawData, critical)
 {
     Parse(rawData);
 }
Ejemplo n.º 41
0
 public IndexData RemoveObject(IndexData indexData, Oid obj)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Execute a query to retrieve an instance.
 /// </summary>
 /// <param name="agent">Application agent.</param>
 /// <param name="oid">Specific 'RevisionOid' Oid of the instance to be searched.</param>
 /// <param name="displaySet">Display set that will be retrieved.</param>
 /// <returns>A DataTable with the instance searched.</returns>
 public static DataTable ExecuteQueryInstance(Oid agent, RevisionOid oid, string displaySet)
 {
     return(Logic.Adaptor.ExecuteQueryInstance(agent, "Revision", string.Empty, oid, displaySet));
 }
Ejemplo n.º 43
0
 public IndexData RemoveDynamicRole(IndexData indexData, Oid obj, DynamicRole role, string[] attributes)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 44
0
        public bool Sign(ReadOnlySpan <byte> dataHash, HashAlgorithmName hashAlgorithmName, X509Certificate2 certificate, AsymmetricAlgorithm key, bool silent, out Oid oid, out ReadOnlyMemory <byte> signatureValue)
        {
            var result = _beIDCardConnector.SignWithAuthenticationCertificate(dataHash.ToArray(), GetDigest(hashAlgorithmName), _pin);

            oid            = new Oid(Medikit.Security.Cryptography.Oids.RsaPkcs1Sha256);
            signatureValue = result;
            return(true);
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Method that solves the execution of 'delete_instance' service.
 /// </summary>
 /// <param name="agent">Application agent.</param>
 /// <param name="argumentValues">Inbound argument values.</param>
 /// <returns>Outbound argument values.</returns>
 public static Dictionary <string, object> ExecuteService(Oid agent, Dictionary <string, object> argumentValues)
 {
     return(ExecuteService(agent, argumentValues["p_thisRevisarAeronave"] as List <Oid>));
 }
 public AlgorithmIdentifier(Oid algorithm)
     : base(new ObjectIdentifier(algorithm), new Asn1Null())
 {
 }
Ejemplo n.º 47
0
 public override string ToString()
 {
     return(m_name + " " + Oid.ToString());
 }
Ejemplo n.º 48
0
 public void ConstructorOidArrayNull()
 {
     Oid o = new Oid(defaultOid);
     Pkcs9AttributeObject a = new Pkcs9AttributeObject(o, null);
 }
Ejemplo n.º 49
0
 private static byte[] EncodeBagValue(Oid secretTypeOid, in ReadOnlyMemory <byte> secretValue)
Ejemplo n.º 50
0
 public IndexData RemoveObject(IndexData indexData, Oid obj, QueryParameters parameters)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 51
0
 public EnvelopedCms(ContentInfo contentInfo)
     : this(contentInfo, new AlgorithmIdentifier(Oid.FromOidValue(Oids.TripleDesCbc, OidGroup.EncryptionAlgorithm)))
 {
 }
Ejemplo n.º 52
0
 public IndexData RemoveObject(IndexData indexData, Oid obj, string[] attributes)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Solves the validation of the 'p_atrId_Aeronave' inbound argument.
 /// </summary>
 /// <param name="agent">Application agent</param>
 /// <param name="argumentValue">Value of the inbound argument to validate</param>
 public static void ExecuteValidateValuep_atrId_Aeronave(Oid agent, string argumentValue)
 {
     // TODO: Validate value
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Execute a query to retrieve a set of instances, without any condition.
 /// </summary>
 /// <param name="agent">Application agent.</param>
 /// <param name="displaySet">List of attributes to return.</param>
 /// <param name="orderCriteria">Order criteria name.</param>
 /// <param name="lastOid">Oid from which to search (not included).</param>
 /// <param name="blockSize">Number of instances to return (0 for all population).</param>
 /// <returns>A DataTable with the instances searched.</returns>
 public static DataTable ExecuteQueryPopulation(Oid agent, string displaySet, string orderCriteria, RevisionOid lastOid, int blockSize, ref bool lastBlock)
 {
     return(ExecuteQueryRelated(agent, new Dictionary <string, Oid>(), displaySet, orderCriteria, lastOid, blockSize, ref lastBlock));
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Solves the validation of the 'p_thisRevisarAeronave' inbound argument.
 /// </summary>
 /// <param name="agent">Application agent</param>
 /// <param name="argumentValue">Value of the inbound argument to validate</param>
 public static void ExecuteValidateValuep_thisRevisarAeronave(Oid agent, List <Oid> argumentValue)
 {
     // TODO: Validate value
 }
Ejemplo n.º 56
0
 public void ConstructorOidNullArray()
 {
     Oid o = null;
     Pkcs9AttributeObject a = new Pkcs9AttributeObject(o, new byte[0]);
 }
Ejemplo n.º 57
0
 public static byte[] ValueAsAscii(this Oid oid)
 {
     return(Encoding.ASCII.GetBytes(oid.Value));
 }
Ejemplo n.º 58
0
 public override string ToString()
 {
     return($"Oid={Oid.ToString()},Date={Date.ToString()}, ClockIn={ClockIn.ToString()}, ClockOut={ClockOut.ToString()} TotalHours={ TotalHours.ToString()}, HourlyRate={HourlyRate.ToString()} | ");
 }
Ejemplo n.º 59
0
        /// <summary>
        /// Execute a query related with other instance.
        /// </summary>
        /// <param name="context">Current context.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryRelated(IUQueryContext context)
        {
            try
            {
                ExchangeInfo lExchangeInfo = context.ExchangeInformation;

                if (lExchangeInfo.ExchangeType != ExchangeType.Navigation || lExchangeInfo.SelectedOids.Count == 0)
                {
                    return(null);
                }

                IUPopulationContext lIUContext = context as IUPopulationContext;
                int blockSize = 1;
                if (lIUContext != null)
                {
                    blockSize = lIUContext.BlockSize;
                }
                ExchangeInfoNavigation lNavInfo = lExchangeInfo as ExchangeInfoNavigation;
                // Specific case. No role name indicates Query by Instance.
                if (lNavInfo.RolePath == "")
                {
                    if (lIUContext != null)
                    {
                        lIUContext.LastBlock = true;
                    }

                    RevisionOid lOidInstance = new RevisionOid(lNavInfo.SelectedOids[0]);
                    return(ExecuteQueryInstance(context.Agent, lOidInstance, context.DisplaySetAttributes));
                }

                // Get link items.
                Oid lOid = lNavInfo.SelectedOids[0];
                Dictionary <string, Oid> lLinkItems = new Dictionary <string, Oid>(StringComparer.CurrentCultureIgnoreCase);
                lLinkItems.Add(lNavInfo.RolePath, lOid);

                bool        lLastBlock     = true;
                RevisionOid lLastOid       = null;
                string      lOrderCriteria = string.Empty;

                // Get population members.
                if (lIUContext != null)
                {
                    if (lIUContext.LastOid != null)
                    {
                        lLastOid = new RevisionOid(lIUContext.LastOid);
                    }
                    lOrderCriteria = lIUContext.OrderCriteriaNameSelected;
                }
                NavigationalFiltering navigationalFiltering = NavigationalFiltering.GetNavigationalFiltering(context);
                DataTable             lDataTable            = ExecuteQueryRelated(context.Agent, lLinkItems, context.DisplaySetAttributes, lOrderCriteria, navigationalFiltering, lLastOid, blockSize, ref lLastBlock);

                if (lIUContext != null)
                {
                    lIUContext.LastBlock = lLastBlock;
                }

                return(lDataTable);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
                return(null);
            }
        }
Ejemplo n.º 60
0
 public IndexData RemoveDynamicRole(IndexData indexData, Oid obj, DynamicRole role)
 {
     throw new NotImplementedException();
 }