/// <summary> /// This method stores the content of an access token in to /// a list of string. This list can be serialized. /// </summary> /// <param name="tokendata">Target list</param> /// <param name="token">the token</param> /// <param name="configurationType">type of configguration which is responsable for the token</param> internal void StoreToken(Dictionary <String, String> tokendata, ICloudStorageAccessToken token, Type configurationType) { // add the configuration information into the tokendata.Add(TokenProviderConfigurationType, configurationType.FullName); tokendata.Add(TokenCredentialType, token.GetType().FullName); // get the provider by toke ICloudStorageProviderInternal provider = GetProviderByConfigurationTypeName(configurationType.FullName); // store all the other information to tokendata provider.StoreToken(tokendata, token); }
/// <summary> /// This method allows to load a token from a previously generated stream /// and the attached metadata /// </summary> /// <param name="tokenStream"></param> /// <param name="additionalMetaData"></param> /// <returns></returns> public ICloudStorageAccessToken DeserializeSecurityToken(Stream tokenStream, out Dictionary <String, String> additionalMetaData) { // load the data in our list var serializer = new DataContractSerializer(typeof(Dictionary <String, String>)); // check the type Object obj = serializer.ReadObject(tokenStream); if (!obj.GetType().Equals(typeof(Dictionary <String, String>))) #if SILVERLIGHT || MONODROID || MONOTOUCH { throw new Exception("A List<String> was expected"); } #else { throw new InvalidDataException("A List<String> was expected"); } #endif // evaluate the right provider Dictionary <String, String> tokendata = (Dictionary <String, String>)obj; // find the right provider by typename ICloudStorageProviderInternal provider = GetProviderByConfigurationTypeName(tokendata[TokenProviderConfigurationType]); // set the output parameter additionalMetaData = new Dictionary <string, string>(); // fill the metadata foreach (KeyValuePair <String, string> kvp in tokendata) { if (kvp.Key.StartsWith(TokenMetadataPrefix)) { additionalMetaData.Add(kvp.Key.Remove(0, TokenMetadataPrefix.Length), kvp.Value); } } // build the token return(provider.LoadToken(tokendata)); }
private void SetProviderByConfigurationTypeName(String TypeName) { _provider = GetProviderByConfigurationTypeName(TypeName); }
private void SetProviderByConfigurationTypeName(String TypeName) { _provider = GetProviderByConfigurationTypeName(TypeName); }
private void SetProviderByConfigurationTypeName(string typeName) { _provider = GetProviderByConfigurationTypeName(typeName); }