4
* An ASN1 type for a Sequence, implemented as an Array
5
* Copyright (c) 2007 Henri Torgemane
7
* See LICENSE.txt for full license information.
9
package com.hurlant.util.der
11
import flash.utils.ByteArray;
13
public dynamic class Sequence extends Array implements IAsn1Type
15
protected var type:uint;
16
protected var len:uint;
18
public function Sequence(type:uint = 0x30, length:uint = 0x00) {
23
public function getLength():uint
28
public function getType():uint
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
41
tmp.writeBytes(e.toDER());
44
return DER.wrapDER(type, tmp);
47
public function toString():String {
48
var s:String = DER.indent;
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";
61
if (!found) t+=this[i]+"\n";
63
// var t:String = join("\n");
65
return DER.indent+"Sequence["+type+"]["+len+"][\n"+t+"\n"+s+"]";
70
public function findAttributeValue(oid:String):IAsn1Type {
71
for each (var set:* in this) {
74
if (child is Sequence) {
76
if (tmp is ObjectIdentifier) {
77
var id:ObjectIdentifier = tmp as ObjectIdentifier;
78
if (id.toString()==oid) {
79
return child[1] as IAsn1Type;
b'\\ No newline at end of file'