/// <summary> /// Returns a printable representation of the {@code X509CRLSelector}. /// </summary> /// <returns> a {@code String} describing the contents of the /// {@code X509CRLSelector}. </returns> public override String ToString() { StringBuffer sb = new StringBuffer(); sb.Append("X509CRLSelector: [\n"); if (IssuerNames_Renamed != null) { sb.Append(" IssuerNames:\n"); Iterator <Object> i = IssuerNames_Renamed.Iterator(); while (i.HasNext()) { sb.Append(" " + i.Next() + "\n"); } } if (MinCRL_Renamed != null) { sb.Append(" minCRLNumber: " + MinCRL_Renamed + "\n"); } if (MaxCRL_Renamed != null) { sb.Append(" maxCRLNumber: " + MaxCRL_Renamed + "\n"); } if (DateAndTime_Renamed != null) { sb.Append(" dateAndTime: " + DateAndTime_Renamed + "\n"); } if (CertChecking != null) { sb.Append(" Certificate being checked: " + CertChecking + "\n"); } sb.Append("]"); return(sb.ToString()); }
private ICollection <string> MarkupLabelsOnly(ICollection <string> set1) { ICollection <string> set = new HashSet <string>(set1); for (Iterator <string> it = set.Iterator(); it.HasNext();) { if (!it.Next().StartsWith(DefaultLabels.MARKUP_PREFIX)) { it.Remove(); } } return(set); }
public void TestIterator() { Iterator<Object> i = hs.Iterator(); int x = 0; while (i.HasNext) { Assert.IsTrue(hs.Contains(i.Next()), "Failed to iterate over all elements"); ++x; } Assert.IsTrue(hs.Size() == x, "Returned iteration of incorrect size"); HashSet<Object> s = new HashSet<Object>(); s.Add(null); Assert.IsNull(s.Iterator().Next(), "Cannot handle null"); }
/// <summary> /// Decides whether a {@code CRL} should be selected. /// </summary> /// <param name="crl"> the {@code CRL} to be checked </param> /// <returns> {@code true} if the {@code CRL} should be selected, /// {@code false} otherwise </returns> public virtual bool Match(CRL crl) { if (!(crl is X509CRL)) { return(false); } X509CRL xcrl = (X509CRL)crl; /* match on issuer name */ if (IssuerNames_Renamed != null) { X500Principal issuer = xcrl.IssuerX500Principal; Iterator <X500Principal> i = IssuerX500Principals.Iterator(); bool found = false; while (!found && i.HasNext()) { if (i.Next().Equals(issuer)) { found = true; } } if (!found) { if (Debug != null) { Debug.println("X509CRLSelector.match: issuer DNs " + "don't match"); } return(false); } } if ((MinCRL_Renamed != null) || (MaxCRL_Renamed != null)) { /* Get CRL number extension from CRL */ sbyte[] crlNumExtVal = xcrl.GetExtensionValue("2.5.29.20"); if (crlNumExtVal == null) { if (Debug != null) { Debug.println("X509CRLSelector.match: no CRLNumber"); } } System.Numerics.BigInteger crlNum; try { DerInputStream @in = new DerInputStream(crlNumExtVal); sbyte[] encoded = @in.OctetString; CRLNumberExtension crlNumExt = new CRLNumberExtension(false, encoded); crlNum = crlNumExt.get(CRLNumberExtension.NUMBER); } catch (IOException) { if (Debug != null) { Debug.println("X509CRLSelector.match: exception in " + "decoding CRL number"); } return(false); } /* match on minCRLNumber */ if (MinCRL_Renamed != null) { if (crlNum.CompareTo(MinCRL_Renamed) < 0) { if (Debug != null) { Debug.println("X509CRLSelector.match: CRLNumber too small"); } return(false); } } /* match on maxCRLNumber */ if (MaxCRL_Renamed != null) { if (crlNum.CompareTo(MaxCRL_Renamed) > 0) { if (Debug != null) { Debug.println("X509CRLSelector.match: CRLNumber too large"); } return(false); } } } /* match on dateAndTime */ if (DateAndTime_Renamed != null) { Date crlThisUpdate = xcrl.ThisUpdate; Date nextUpdate = xcrl.NextUpdate; if (nextUpdate == null) { if (Debug != null) { Debug.println("X509CRLSelector.match: nextUpdate null"); } return(false); } Date nowPlusSkew = DateAndTime_Renamed; Date nowMinusSkew = DateAndTime_Renamed; if (Skew > 0) { nowPlusSkew = new Date(DateAndTime_Renamed.Time + Skew); nowMinusSkew = new Date(DateAndTime_Renamed.Time - Skew); } // Check that the test date is within the validity interval: // [ thisUpdate - MAX_CLOCK_SKEW, // nextUpdate + MAX_CLOCK_SKEW ] if (nowMinusSkew.After(nextUpdate) || nowPlusSkew.Before(crlThisUpdate)) { if (Debug != null) { Debug.println("X509CRLSelector.match: update out-of-range"); } return(false); } } return(true); }
private ICollection<string> MarkupLabelsOnly(ICollection<string> set1) { ICollection<string> set = new HashSet<string>(set1); for (Iterator<string> it = set.Iterator(); it.HasNext(); ) { if (!it.Next().StartsWith(DefaultLabels.MARKUP_PREFIX)) { it.Remove(); } } return set; }