/// <summary> /// Adds all of the elements of the "c" collection to the "target" collection. /// </summary> /// <param name="target">Collection where the new elements will be added.</param> /// <param name="c">Collection whose elements will be added.</param> /// <returns>Returns true if at least one element was added, false otherwise.</returns> public static bool AddAll(System.Collections.ICollection target, System.Collections.ICollection c) { System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator(); bool added = false; //Reflection. Invoke "addAll" method for proprietary classes System.Reflection.MethodInfo method; try { method = target.GetType().GetMethod("addAll"); if (method != null) { added = (bool)method.Invoke(target, new System.Object[] { c }); } else { method = target.GetType().GetMethod("Add"); while (e.MoveNext() == true) { bool tempBAdded = (int)method.Invoke(target, new System.Object[] { e.Current }) >= 0; added = added ? added : tempBAdded; } } } catch (System.Exception ex) { throw ex; } return(added); }
/// <summary> /// Retains the elements in the target collection that are contained in the specified collection /// </summary> /// <param name="target">Collection where the elements will be removed.</param> /// <param name="c">Elements to be retained in the target collection.</param> /// <returns>true</returns> public static bool RetainAll(System.Collections.ICollection target, System.Collections.ICollection c) { System.Collections.IEnumerator e = new System.Collections.ArrayList(target).GetEnumerator(); System.Collections.ArrayList al = new System.Collections.ArrayList(c); //Reflection. Invoke "RetainAll" method for proprietary classes or "Remove" for each element in the collection System.Reflection.MethodInfo method; try { method = c.GetType().GetMethod("RetainAll"); if (method != null) { method.Invoke(target, new System.Object[] { c }); } else { method = c.GetType().GetMethod("Remove"); while (e.MoveNext() == true) { if (al.Contains(e.Current) == false) { method.Invoke(target, new System.Object[] { e.Current }); } } } } catch (System.Exception ex) { throw ex; } return(true); }
/// <summary> /// Adds all of the elements of the "c" collection to the "target" collection. /// </summary> /// <param name="target">Collection where the new elements will be added.</param> /// <param name="c">Collection whose elements will be added.</param> /// <returns>Returns true if at least one element was added, false otherwise.</returns> public static bool AddAll(System.Collections.ICollection target, System.Collections.ICollection c) { System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator(); bool added = false; //Reflection. Invoke "addAll" method for proprietary classes System.Reflection.MethodInfo method; try { method = target.GetType().GetMethod("addAll"); if (method != null) added = (bool) method.Invoke(target, new System.Object[] {c}); else { method = target.GetType().GetMethod("Add"); while (e.MoveNext() == true) { bool tempBAdded = (int) method.Invoke(target, new System.Object[] {e.Current}) >= 0; added = added ? added : tempBAdded; } } } catch (System.Exception ex) { throw ex; } return added; }
/// <summary> /// Adds all the elements of the specified collection that are not present to the list. /// </summary> /// <param name="c">Collection where the new elements will be added</param> /// <returns>Returns true if at least one element was added, false otherwise.</returns> public bool AddAll(System.Collections.ICollection c) { System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator(); bool added = false; while (e.MoveNext() == true) { if (this.Add(e.Current) == true) added = true; } return added; }
public bool AddAll(ICollection c) { IEnumerator enumerator = new ArrayList(c).GetEnumerator(); bool flag = false; while (enumerator.MoveNext()) { if (this.Add(enumerator.Current)) { flag = true; } } return flag; }
public bool AddAll(ICollection c) { IEnumerator e = new ArrayList(c).GetEnumerator(); bool added = false; while (e.MoveNext()) { if (AddWithoutSorting(e.Current)) { added = true; } } Sort(comparator); return added; }
/// <summary> /// Adds all the elements of the specified collection that are not present to the list. /// </summary> /// <param name="c">Collection where the new elements will be added</param> /// <returns>Returns true if at least one element was added, false otherwise.</returns> public bool AddAll(ICollection c) { IEnumerator e = new ArrayList(c).GetEnumerator(); bool added = false; while (e.MoveNext() == true) { if (Add(e.Current) == true) { added = true; } } return added; }
/// <summary> /// Adds all the elements of the specified collection that are not present to the list. /// </summary> /// <param name="c">Collection where the new elements will be added</param> /// <returns>Returns true if at least one element was added, false otherwise.</returns> public bool AddAll(System.Collections.ICollection c) { System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator(); bool added = false; while (e.MoveNext() == true) { if (this.Add(e.Current) == true) { added = true; } } return(added); }
/// <summary> /// Adds all the elements contained into the specified collection, starting at the specified position. /// </summary> /// <param name="index">Position at which to add the first element from the specified collection.</param> /// <param name="list">The list used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public static bool AddAll(IList list, int index, ICollection c) { bool result = false; if (c != null) { IEnumerator tempEnumerator = new ArrayList(c).GetEnumerator(); int tempIndex = index; while (tempEnumerator.MoveNext()) { list.Insert(tempIndex++, tempEnumerator.Current); result = true; } } return result; }
public static bool AddAll(ICollection target, ICollection c) { IEnumerator enumerator = new ArrayList(c).GetEnumerator(); bool flag = false; try { MethodInfo method = target.GetType().GetMethod("addAll"); if (method != null) { return (bool) method.Invoke(target, new object[] { c }); } method = target.GetType().GetMethod("Add"); while (enumerator.MoveNext()) { bool flag2 = ((int) method.Invoke(target, new object[] { enumerator.Current })) >= 0; flag = flag ? flag : flag2; } } catch (Exception exception) { throw exception; } return flag; }
/// <summary> /// Adds all the elements contained into the specified collection, starting at the specified position. /// </summary> /// <param name="index">Position at which to add the first element from the specified collection.</param> /// <param name="list">The list used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(int index, System.Collections.IList list) { bool result = false; if (list!=null) { System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(list).GetEnumerator(); int tempIndex = index; while (tempEnumerator.MoveNext()) { base.Insert(tempIndex++, tempEnumerator.Current); result = true; } } return result; }
/// <summary> Invalidate the old session after copying all of its contents to a newly created session with a new session id. /// Note that this is different from logging out and creating a new session identifier that does not contain the /// existing session contents. Care should be taken to use this only when the existing session does not contain /// hazardous contents. /// /// </summary> /// <returns> The invaldiated session. /// </returns> /// <seealso cref="Owasp.Esapi.Interfaces.IHttpUtilities.ChangeSessionIdentifier()"> /// </seealso> public IHttpSession ChangeSessionIdentifier() { IHttpRequest request = ((Authenticator) Esapi.Authenticator()).CurrentRequest; IHttpResponse response = ((Authenticator) Esapi.Authenticator()).CurrentResponse; IHttpSession session = ((Authenticator)Esapi.Authenticator()).CurrentSession; IDictionary temp = new Hashtable(); // make a copy of the session content IEnumerator e = session.GetEnumerator(); while (e != null && e.MoveNext()) { string name = (string) e.Current; object val = session[name]; temp[name] = val; } // invalidate the old session and create a new one // This hack comes from here: http://support.microsoft.com/?kbid=899918 session.Abandon(); response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "")); // copy back the session content IEnumerator i = new ArrayList(temp).GetEnumerator(); while (i.MoveNext()) { DictionaryEntry entry = (DictionaryEntry) i.Current; session.Add((string) entry.Key, entry.Value); } return session; }
internal static PkixPolicyNode PrepareCertB( PkixCertPath certPath, int index, IList[] policyNodes, PkixPolicyNode validPolicyTree, int policyMapping) //throws CertPathValidatorException { IList certs = certPath.Certificates; X509Certificate cert = (X509Certificate)certs[index]; int n = certs.Count; // i as defined in the algorithm description int i = n - index; // (b) // Asn1Sequence pm = null; try { pm = (Asn1Sequence)Asn1Sequence.GetInstance(PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.PolicyMappings)); } catch (Exception ex) { throw new PkixCertPathValidatorException( "Policy mappings extension could not be decoded.", ex, certPath, index); } PkixPolicyNode _validPolicyTree = validPolicyTree; if (pm != null) { Asn1Sequence mappings = (Asn1Sequence)pm; IDictionary m_idp = new Hashtable(); ISet s_idp = new HashSet(); for (int j = 0; j < mappings.Count; j++) { Asn1Sequence mapping = (Asn1Sequence) mappings[j]; string id_p = ((DerObjectIdentifier) mapping[0]).Id; string sd_p = ((DerObjectIdentifier) mapping[1]).Id; ISet tmp; if (!m_idp.Contains(id_p)) { tmp = new HashSet(); tmp.Add(sd_p); m_idp[id_p] = tmp; s_idp.Add(id_p); } else { tmp = (ISet)m_idp[id_p]; tmp.Add(sd_p); } } IEnumerator it_idp = s_idp.GetEnumerator(); while (it_idp.MoveNext()) { string id_p = (string)it_idp.Current; // // (1) // if (policyMapping > 0) { bool idp_found = false; IEnumerator nodes_i = policyNodes[i].GetEnumerator(); while (nodes_i.MoveNext()) { PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current; if (node.ValidPolicy.Equals(id_p)) { idp_found = true; node.ExpectedPolicies = (ISet)m_idp[id_p]; break; } } if (!idp_found) { nodes_i = policyNodes[i].GetEnumerator(); while (nodes_i.MoveNext()) { PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current; if (Rfc3280CertPathUtilities.ANY_POLICY.Equals(node.ValidPolicy)) { ISet pq = null; Asn1Sequence policies = null; try { policies = (Asn1Sequence)PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.CertificatePolicies); } catch (Exception e) { throw new PkixCertPathValidatorException( "Certificate policies extension could not be decoded.", e, certPath, index); } foreach (Asn1Encodable ae in policies) { PolicyInformation pinfo = null; try { pinfo = PolicyInformation.GetInstance(ae.ToAsn1Object()); } catch (Exception ex) { throw new PkixCertPathValidatorException( "Policy information could not be decoded.", ex, certPath, index); } if (Rfc3280CertPathUtilities.ANY_POLICY.Equals(pinfo.PolicyIdentifier.Id)) { try { pq = PkixCertPathValidatorUtilities .GetQualifierSet(pinfo.PolicyQualifiers); } catch (PkixCertPathValidatorException ex) { throw new PkixCertPathValidatorException( "Policy qualifier info set could not be decoded.", ex, certPath, index); } break; } } bool ci = false; ISet critExtOids = cert.GetCriticalExtensionOids(); if (critExtOids != null) { ci = critExtOids.Contains(X509Extensions.CertificatePolicies.Id); } PkixPolicyNode p_node = (PkixPolicyNode)node.Parent; if (Rfc3280CertPathUtilities.ANY_POLICY.Equals(p_node.ValidPolicy)) { PkixPolicyNode c_node = new PkixPolicyNode(new ArrayList(), i, (ISet)m_idp[id_p], p_node, pq, id_p, ci); p_node.AddChild(c_node); policyNodes[i].Add(c_node); } break; } } } // // (2) // } else if (policyMapping <= 0) { //IEnumerator nodes_i = policyNodes[i].GetEnumerator(); //IEnumerator nodes_i = ArrayList.ReadOnly(policyNodes[i]).GetEnumerator(); IEnumerator nodes_i = new ArrayList(policyNodes[i]).GetEnumerator(); while (nodes_i.MoveNext()) { PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current; if (node.ValidPolicy.Equals(id_p)) { PkixPolicyNode p_node = (PkixPolicyNode)node.Parent; //p_node.RemoveChild(node); p_node.RemoveChild(node); //((IList)policyNodes[i]).Remove(nodes_i.Current); for (int k = (i - 1); k >= 0; k--) { IList nodes = policyNodes[k]; for (int l = 0; l < nodes.Count; l++) { PkixPolicyNode node2 = (PkixPolicyNode)nodes[l]; if (!node2.HasChildren) { _validPolicyTree = PkixCertPathValidatorUtilities.RemovePolicyNode( _validPolicyTree, policyNodes, node2); if (_validPolicyTree == null) { break; } } } } } } } } } return _validPolicyTree; }
public static bool RetainAll(ICollection target, ICollection c) { IEnumerator enumerator = new ArrayList(target).GetEnumerator(); ArrayList list = new ArrayList(c); try { MethodInfo method = c.GetType().GetMethod("retainAll"); if (method != null) { method.Invoke(target, new object[] { c }); } else { method = c.GetType().GetMethod("Remove"); while (enumerator.MoveNext()) { if (!list.Contains(enumerator.Current)) { method.Invoke(target, new object[] { enumerator.Current }); } } } } catch (Exception exception) { throw exception; } return true; }
/// <summary> /// Retains the Elements in the target collection that are contained in the specified collection /// </summary> /// <param name="target">Collection where the Elements will be removed.</param> /// <param name="c">Elements to be retained in the target collection.</param> /// <returns>true</returns> public static bool RetainAll(ICollection target, ICollection c) { IEnumerator e = new ArrayList(target).GetEnumerator(); var al = new ArrayList(c); //Reflection. Invoke "retainAll" method for proprietary classes or "Remove" for each Element in the collection System.Reflection.MethodInfo method; try { method = c.GetType().GetMethod("retainAll"); if (method != null) method.Invoke(target, new Object[] {c}); else { method = c.GetType().GetMethod("Remove"); while (e.MoveNext()) { if (al.Contains(e.Current) == false) method.Invoke(target, new[] {e.Current}); } } } catch (Exception ex) { throw ex; } return true; }
/// <summary> /// Removes all the elements contained into the specified collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be removed.</param> /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns> public virtual bool RemoveAll(System.Collections.ICollection collection) { bool result = false; System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator(); while (tempEnumerator.MoveNext()) { if (this.Contains(tempEnumerator.Current)) result = this.Remove(tempEnumerator.Current); } return result; }
/// <summary> /// Verifies if all the elements of the specified collection are contained into the current collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be verified.</param> /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns> public virtual bool ContainsAll(System.Collections.ICollection collection) { bool result = false; System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator(); while (tempEnumerator.MoveNext()) if (!(result = this.Contains(tempEnumerator.Current))) break; return result; }
/// <summary> /// Adds all the elements contained in the specified collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(System.Collections.ICollection collection) { bool result = false; if (collection!=null) { System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator(); while (tempEnumerator.MoveNext()) { if (tempEnumerator.Current != null) result = this.Add(tempEnumerator.Current); } } return result; }
/// <summary> /// Removes all the elements contained into the specified collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be removed.</param> /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns> public virtual bool RemoveAll(ICollection collection) { bool result = false; IEnumerator tempEnumerator = new ArrayList(collection).GetEnumerator(); while (tempEnumerator.MoveNext()) { result = true; if (base.Contains(tempEnumerator.Current)) base.Remove(tempEnumerator.Current); } return result; }