OidTokenizer.cs 1.1 KB

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