示例#1
0
        /**
         * Parse a {@link CertificateUrl} from a {@link Stream}.
         *
         * @param context
         *            the {@link TlsContext} of the current connection.
         * @param input
         *            the {@link Stream} to parse from.
         * @return a {@link CertificateUrl} object.
         * @throws IOException
         */
        public static CertificateUrl parse(TlsContext context, Stream input)
        {
            byte type = TlsUtilities.ReadUint8(input);

            if (!CertChainType.IsValid(type))
            {
                throw new TlsFatalAlert(AlertDescription.decode_error);
            }

            int totalLength = TlsUtilities.ReadUint16(input);

            if (totalLength < 1)
            {
                throw new TlsFatalAlert(AlertDescription.decode_error);
            }

            byte[] urlAndHashListData = TlsUtilities.ReadFully(totalLength, input);

            MemoryStream buf = new MemoryStream(urlAndHashListData, false);

            IList url_and_hash_list = Platform.CreateArrayList();

            while (buf.Position < buf.Length)
            {
                UrlAndHash url_and_hash = UrlAndHash.Parse(context, buf);
                url_and_hash_list.Add(url_and_hash);
            }

            return(new CertificateUrl(type, url_and_hash_list));
        }
示例#2
0
        /**
         * @param type
         *            see {@link CertChainType} for valid constants.
         * @param urlAndHashList
         *            a {@link IList} of {@link UrlAndHash}.
         */
        public CertificateUrl(byte type, IList urlAndHashList)
        {
            if (!CertChainType.IsValid(type))
            {
                throw new ArgumentException("not a valid CertChainType value", "type");
            }
            if (urlAndHashList == null || urlAndHashList.Count < 1)
            {
                throw new ArgumentException("must have length > 0", "urlAndHashList");
            }

            this.mType           = type;
            this.mUrlAndHashList = urlAndHashList;
        }