OidTokenizer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1
  4. {
  5. /**
  6. * class for breaking up an Oid into it's component tokens, ala
  7. * java.util.StringTokenizer. We need this class as some of the
  8. * lightweight Java environment don't support classes like
  9. * StringTokenizer.
  10. */
  11. public class OidTokenizer
  12. {
  13. private string oid;
  14. private int index;
  15. public OidTokenizer(
  16. string oid)
  17. {
  18. this.oid = oid;
  19. }
  20. public bool HasMoreTokens
  21. {
  22. get { return index != -1; }
  23. }
  24. public string NextToken()
  25. {
  26. if (index == -1)
  27. {
  28. return null;
  29. }
  30. int end = oid.IndexOf('.', index);
  31. if (end == -1)
  32. {
  33. string lastToken = oid.Substring(index);
  34. index = -1;
  35. return lastToken;
  36. }
  37. string nextToken = oid.Substring(index, end - index);
  38. index = end + 1;
  39. return nextToken;
  40. }
  41. }
  42. }
  43. #pragma warning restore
  44. #endif