PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 57 lines | 18 code | 7 blank | 32 comment | 0 complexity | 052f79ba8a463ceb3a1418e7f68ec9a9 MD5 | raw file
 1/**
 2 * X509CertificateCollection
 3 * 
 4 * A class to store and index X509 Certificates by Subject.
 5 * Copyright (c) 2007 Henri Torgemane
 6 * 
 7 * See LICENSE.txt for full license information.
 8 */
 9package com.hurlant.crypto.cert {
10	
11	public class X509CertificateCollection {
12		
13		private var _map:Object;
14		
15		public function X509CertificateCollection() {
16			_map = {};
17		}
18		
19		/**
20		 * Mostly meant for built-in CA loading.
21		 * This entry-point allows to index CAs without parsing them.
22		 * 
23		 * @param name		A friendly name. not currently used
24		 * @param subject	base64 DER encoded Subject principal for the Cert
25		 * @param pem		PEM encoded certificate data
26		 * 
27		 */
28		public function addPEMCertificate(name:String, subject:String, pem:String):void {
29			_map[subject] = new X509Certificate(pem);
30		}
31		
32		/**
33		 * Adds a X509 certificate to the collection.
34		 * This call will force the certificate to be parsed.
35		 * 
36		 * @param cert		A X509 certificate
37		 * 
38		 */
39		public function addCertificate(cert:X509Certificate):void {
40			var subject:String = cert.getSubjectPrincipal();
41			_map[subject] = cert;
42		}
43		
44		/**
45		 * Returns a X509 Certificate present in the collection, given
46		 * a base64 DER encoded X500 Subject principal
47		 * 
48		 * @param subject	A Base64 DER-encoded Subject principal
49		 * @return 			A matching certificate, or null.
50		 * 
51		 */
52		public function getCertificate(subject:String):X509Certificate {
53			return _map[subject];
54		}
55		
56	}
57}