[MonoTODO] // FIXME: Check how expanded entity is handled here. public override int ReadContentAsBase64(byte [] buffer, int index, int count) { if (validatingReader != null) { return(validatingReader.ReadContentAsBase64(buffer, index, count)); } else { return(sourceReader.ReadContentAsBase64(buffer, index, count)); } }
[MonoTODO] // FIXME: Check how expanded entity is handled here. public override int ReadContentAsBase64(byte [] buffer, int offset, int length) { if (validatingReader != null) { return(validatingReader.ReadContentAsBase64(buffer, offset, length)); } else { return(sourceReader.ReadContentAsBase64(buffer, offset, length)); } }
public override int ReadContentAsBase64(byte [] buffer, int index, int count) { // return base.ReadContentAsBase64 ( // buffer, offset, length); // FIXME: This is problematic wrt end of entity. if (entity != null) { return(entity.ReadContentAsBase64( buffer, index, count)); } else { return(source.ReadContentAsBase64( buffer, index, count)); } }
public override int ReadContentAsBase64(byte[] buffer, int index, int count) { CheckAsync(); return(_coreReader.ReadContentAsBase64(buffer, index, count)); }
/// <summary> /// Reads a wst:Entropy element and constructs a SecurityToken /// Assumes that the provided entropy is never more than 1Kb in size. /// </summary> /// <param name="xr">An XmlReader positioned on the start tag of wst:Entropy</param> /// <returns>A SecurityToken that contains the entropy value.</returns> private static SecurityToken ProcessEntropyElement(XmlReader xr) { // If provided XmlReader is null, throw an exception if (xr == null) throw new ArgumentNullException("xr"); // If the wst:Entropy element is empty, then throw an exception. if (xr.IsEmptyElement) throw new ArgumentException("wst:Entropy element was empty. Unable to create SecurityToken object"); // Store the initial depth so we can exit this function when we reach the corresponding end-tag int initialDepth = xr.Depth; // Set our return value to null SecurityToken st = null; // Enter a read loop... while (xr.Read()) { // Look for a non-empty wst:BinarySecret element if (Constants.Trust.Elements.BinarySecret == xr.LocalName && Constants.Trust.NamespaceUri == xr.NamespaceURI && !xr.IsEmptyElement && XmlNodeType.Element == xr.NodeType) { // Allocate a 1024 byte buffer for the entropy byte[] temp = new byte[1024]; // Move reader to content of wst:BinarySecret element... xr.Read(); // ...and read that content as base64. Store the actual number of bytes we get. int nBytes = xr.ReadContentAsBase64(temp, 0, temp.Length); // Allocate a new array of the correct size to hold the provided entropy byte[] entropy = new byte[nBytes]; // Copy the entropy from the temporary array into the new array. for (int i = 0; i < nBytes; i++) entropy[i] = temp[i]; // Create new BinarySecretSecurityToken from the provided entropy st = new BinarySecretSecurityToken(entropy); } // Look for the end-tag that corresponds to the start-tag the reader was positioned // on when the method was called. When we find it, break out of the read loop. if (Constants.Trust.Elements.Entropy == xr.LocalName && Constants.Trust.NamespaceUri == xr.NamespaceURI && xr.Depth == initialDepth && XmlNodeType.EndElement == xr.NodeType) break; } return st; }
public void Restore(XmlReader reader) { for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); switch (reader.Name) { case "checkforupdates": CheckForUpdates = reader.ReadContentAsBool(); break; case "automaticallyinstallupdates": AutomaticallyInstallUpdates = reader.ReadContentAsBool(); break; case "passwordsalt": _passwordSalt = reader.ReadContentAsBase64(); break; case "proxyserver": ProxyServer = reader.ReadContentAsString(); break; case "proxyusername": ProxyUsername = reader.ReadContentAsString(); break; case "proxypassword": _password = reader.ReadContentAsBase64(); break; default: Log.WarnFormat("Skipping unknown attribute '{0}'", reader.Name); break; } } CreatePasswordSaltIfNecessary(); }
private static TableStorageField ToObject(XmlReader reader, string edmType, bool isNull, string propertyName) { object value; Type dataType; string formatString; if(edmType == TableStorageConstants.Edm.TYPE_BINARY) { if(isNull) { value = DBNull.Value; } else { using(Stream stream = new MemoryStream()) { const int size = 256; byte[] buffer = new byte[size]; int count; while((count = reader.ReadContentAsBase64(buffer, 0, size)) > 0) { stream.Write(buffer, 0, count); } stream.Seek(0, SeekOrigin.Begin); value = stream; } } dataType = typeof(byte[]); formatString = "{0}"; } else if(edmType == TableStorageConstants.Edm.TYPE_BOOLEAN) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsBoolean(); } dataType = typeof(bool); formatString = "{0}"; } else if(edmType == TableStorageConstants.Edm.TYPE_DATETIME) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsDateTime(); } dataType = typeof(DateTime); formatString = TableStorageConstants.Edm.DATE_TIME_FORMAT; } else if(edmType == TableStorageConstants.Edm.TYPE_DOUBLE) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsDouble(); } dataType = typeof(double); formatString = "{0}"; } else if(edmType == TableStorageConstants.Edm.TYPE_GUID) { if(isNull) { value = DBNull.Value; } else { value = Guid.Parse(reader.ReadContentAsString()); } dataType = typeof(Guid); formatString = "{0:D}"; } else if(edmType == TableStorageConstants.Edm.TYPE_INT) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsInt(); } dataType = typeof(int); formatString = "{0}"; } else if(edmType == TableStorageConstants.Edm.TYPE_LONG) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsLong(); } dataType = typeof(long); formatString = "{0}"; } else if(StringComparer.OrdinalIgnoreCase.Equals(TableStorageConstants.Edm.TYPE_STRING, edmType)) { if(isNull) { value = DBNull.Value; } else { value = reader.ReadContentAsString(); } dataType = typeof(string); formatString = "{0}"; } else { throw new TableStorageException(string.Format("The type, '{0},' is not supported.", edmType)); } return new TableStorageField(value, edmType, propertyName, isNull, dataType, formatString); }