summaryrefslogtreecommitdiff
path: root/flash-src/third-party/com/hurlant/util/der/Sequence.as
diff options
context:
space:
mode:
authorHiroshi Ichikawa <gimite@gmail.com>2011-08-28 22:14:15 +0900
committerHiroshi Ichikawa <gimite@gmail.com>2011-08-28 22:14:15 +0900
commit80c91d84bc3e84f684f53172e8eb7cad81795fb1 (patch)
tree70d3a71d8020902ed246fc7b908ebf9c3478f653 /flash-src/third-party/com/hurlant/util/der/Sequence.as
parented0622a890de811eb6d766d5c5a9a62d726f0593 (diff)
downloadweb-socket-js-80c91d84bc3e84f684f53172e8eb7cad81795fb1.tar.gz
Moving our own .as files into flash-src/src and third-party .as files into flash-src/third-party.
Adding build rule for WebSocketWithoutDependencies.swc.
Diffstat (limited to 'flash-src/third-party/com/hurlant/util/der/Sequence.as')
-rwxr-xr-xflash-src/third-party/com/hurlant/util/der/Sequence.as90
1 files changed, 90 insertions, 0 deletions
diff --git a/flash-src/third-party/com/hurlant/util/der/Sequence.as b/flash-src/third-party/com/hurlant/util/der/Sequence.as
new file mode 100755
index 0000000..c352414
--- /dev/null
+++ b/flash-src/third-party/com/hurlant/util/der/Sequence.as
@@ -0,0 +1,90 @@
+/**
+ * Sequence
+ *
+ * An ASN1 type for a Sequence, implemented as an Array
+ * Copyright (c) 2007 Henri Torgemane
+ *
+ * See LICENSE.txt for full license information.
+ */
+package com.hurlant.util.der
+{
+ import flash.utils.ByteArray;
+
+ public dynamic class Sequence extends Array implements IAsn1Type
+ {
+ protected var type:uint;
+ protected var len:uint;
+
+ public function Sequence(type:uint = 0x30, length:uint = 0x00) {
+ this.type = type;
+ this.len = length;
+ }
+
+ public function getLength():uint
+ {
+ return len;
+ }
+
+ public function getType():uint
+ {
+ return type;
+ }
+
+ public function toDER():ByteArray {
+ var tmp:ByteArray = new ByteArray;
+ for (var i:int=0;i<length;i++) {
+ var e:IAsn1Type = this[i];
+ if (e == null) { // XXX Arguably, I could have a der.Null class instead
+ tmp.writeByte(0x05);
+ tmp.writeByte(0x00);
+ } else {
+ tmp.writeBytes(e.toDER());
+ }
+ }
+ return DER.wrapDER(type, tmp);
+ }
+
+ public function toString():String {
+ var s:String = DER.indent;
+ DER.indent += " ";
+ var t:String = "";
+ for (var i:int=0;i<length;i++) {
+ if (this[i]==null) continue;
+ var found:Boolean = false;
+ for (var key:String in this) {
+ if ( (i.toString()!=key) && this[i]==this[key]) {
+ t += key+": "+this[i]+"\n";
+ found = true;
+ break;
+ }
+ }
+ if (!found) t+=this[i]+"\n";
+ }
+// var t:String = join("\n");
+ DER.indent= s;
+ return DER.indent+"Sequence["+type+"]["+len+"][\n"+t+"\n"+s+"]";
+ }
+
+ /////////
+
+ public function findAttributeValue(oid:String):IAsn1Type {
+ for each (var set:* in this) {
+ if (set is Set) {
+ var child:* = set[0];
+ if (child is Sequence) {
+ var tmp:* = child[0];
+ if (tmp is ObjectIdentifier) {
+ var id:ObjectIdentifier = tmp as ObjectIdentifier;
+ if (id.toString()==oid) {
+ return child[1] as IAsn1Type;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ }
+} \ No newline at end of file