~ubuntu-branches/ubuntu/trusty/emscripten/trusty-proposed

« back to all changes in this revision

Viewing changes to third_party/websockify/include/web-socket-js/src/flash-src/third-party/com/hurlant/util/der/Sequence.as

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140119141240-jg1l42cc158j59tn
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        
 
13
        public dynamic class Sequence extends Array implements IAsn1Type
 
14
        {
 
15
                protected var type:uint;
 
16
                protected var len:uint;
 
17
                
 
18
                public function Sequence(type:uint = 0x30, length:uint = 0x00) {
 
19
                        this.type = type;
 
20
                        this.len = length;
 
21
                }
 
22
                
 
23
                public function getLength():uint
 
24
                {
 
25
                        return len;
 
26
                }
 
27
                
 
28
                public function getType():uint
 
29
                {
 
30
                        return type;
 
31
                }
 
32
 
 
33
                public function toDER():ByteArray {
 
34
                        var tmp:ByteArray = new ByteArray;
 
35
                        for (var i:int=0;i<length;i++) {
 
36
                                var e:IAsn1Type = this[i];
 
37
                                if (e == null) { // XXX Arguably, I could have a der.Null class instead
 
38
                                        tmp.writeByte(0x05);
 
39
                                        tmp.writeByte(0x00);
 
40
                                } else {
 
41
                                        tmp.writeBytes(e.toDER());
 
42
                                }
 
43
                        }
 
44
                        return DER.wrapDER(type, tmp);
 
45
                }
 
46
                
 
47
                public function toString():String {
 
48
                        var s:String = DER.indent;
 
49
                        DER.indent += "    ";
 
50
                        var t:String = "";
 
51
                        for (var i:int=0;i<length;i++) {
 
52
                                if (this[i]==null) continue;
 
53
                                var found:Boolean = false;
 
54
                                for (var key:String in this) {
 
55
                                        if ( (i.toString()!=key) && this[i]==this[key]) {
 
56
                                                t += key+": "+this[i]+"\n";
 
57
                                                found = true;
 
58
                                                break;
 
59
                                        }
 
60
                                }
 
61
                                if (!found) t+=this[i]+"\n";
 
62
                        }
 
63
//                      var t:String = join("\n");
 
64
                        DER.indent= s;
 
65
                        return DER.indent+"Sequence["+type+"]["+len+"][\n"+t+"\n"+s+"]";
 
66
                }
 
67
                
 
68
                /////////
 
69
                
 
70
                public function findAttributeValue(oid:String):IAsn1Type {
 
71
                        for each (var set:* in this) {
 
72
                                if (set is Set) {
 
73
                                        var child:* = set[0];
 
74
                                        if (child is Sequence) {
 
75
                                                var tmp:* = child[0];
 
76
                                                if (tmp is ObjectIdentifier) {
 
77
                                                        var id:ObjectIdentifier = tmp as ObjectIdentifier;
 
78
                                                        if (id.toString()==oid) {
 
79
                                                                return child[1] as IAsn1Type;
 
80
                                                        }
 
81
                                                }
 
82
                                        }
 
83
                                }
 
84
                        }
 
85
                        return null;
 
86
                }
 
87
                
 
88
                
 
89
        }
 
90
}
 
 
b'\\ No newline at end of file'