PageRenderTime 988ms CodeModel.GetById 972ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 90 lines | 70 code | 10 blank | 10 comment | 15 complexity | 936d55a8a8ffd2749327d90644a1e693 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /**
  2. * Sequence
  3. *
  4. * An ASN1 type for a Sequence, implemented as an Array
  5. * Copyright (c) 2007 Henri Torgemane
  6. *
  7. * See LICENSE.txt for full license information.
  8. */
  9. package com.hurlant.util.der
  10. {
  11. import flash.utils.ByteArray;
  12. public dynamic class Sequence extends Array implements IAsn1Type
  13. {
  14. protected var type:uint;
  15. protected var len:uint;
  16. public function Sequence(type:uint = 0x30, length:uint = 0x00) {
  17. this.type = type;
  18. this.len = length;
  19. }
  20. public function getLength():uint
  21. {
  22. return len;
  23. }
  24. public function getType():uint
  25. {
  26. return type;
  27. }
  28. public function toDER():ByteArray {
  29. var tmp:ByteArray = new ByteArray;
  30. for (var i:int=0;i<length;i++) {
  31. var e:IAsn1Type = this[i];
  32. if (e == null) { // XXX Arguably, I could have a der.Null class instead
  33. tmp.writeByte(0x05);
  34. tmp.writeByte(0x00);
  35. } else {
  36. tmp.writeBytes(e.toDER());
  37. }
  38. }
  39. return DER.wrapDER(type, tmp);
  40. }
  41. public function toString():String {
  42. var s:String = DER.indent;
  43. DER.indent += " ";
  44. var t:String = "";
  45. for (var i:int=0;i<length;i++) {
  46. if (this[i]==null) continue;
  47. var found:Boolean = false;
  48. for (var key:String in this) {
  49. if ( (i.toString()!=key) && this[i]==this[key]) {
  50. t += key+": "+this[i]+"\n";
  51. found = true;
  52. break;
  53. }
  54. }
  55. if (!found) t+=this[i]+"\n";
  56. }
  57. // var t:String = join("\n");
  58. DER.indent= s;
  59. return DER.indent+"Sequence["+type+"]["+len+"][\n"+t+"\n"+s+"]";
  60. }
  61. /////////
  62. public function findAttributeValue(oid:String):IAsn1Type {
  63. for each (var set:* in this) {
  64. if (set is Set) {
  65. var child:* = set[0];
  66. if (child is Sequence) {
  67. var tmp:* = child[0];
  68. if (tmp is ObjectIdentifier) {
  69. var id:ObjectIdentifier = tmp as ObjectIdentifier;
  70. if (id.toString()==oid) {
  71. return child[1] as IAsn1Type;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. return null;
  78. }
  79. }
  80. }