///<summary> /// reads the object class info definitions from xml ///</summary> ///<returns>Dictionary of object classes</returns> protected internal static IDictionary <ObjectClass, ObjectClassInfo> GetOCInfo(string name) { Assembly assembly = Assembly.GetExecutingAssembly(); Stream stream = assembly.GetManifestResourceStream(name); Assertions.NullCheck(stream, "stream"); //we just read TextReader streamReader = new StreamReader(stream); String xml; try { xml = streamReader.ReadToEnd(); } finally { streamReader.Close(); } //read from xml var ret = (ICollection <object>)SerializerUtil.DeserializeXmlObject(xml, true); Assertions.NullCheck(ret, "ret"); //create map of object infos var map = new Dictionary <ObjectClass, ObjectClassInfo>(ret.Count); foreach (ObjectClassInfo o in ret) { map.Add(new ObjectClass(o.ObjectType.ToString()), o); } return(map); }
private static IDictionary <ObjectClass, ObjectClassInfo> GetOCInfoInternal(Stream stream, bool dump) { Assertions.NullCheck(stream, "stream"); //we just read TextReader streamReader = new StreamReader(stream); String xml; try { xml = streamReader.ReadToEnd(); } finally { streamReader.Close(); } if (dump) { LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "XML = {0}", xml); } //read from xml var ret = (ICollection <object>)SerializerUtil.DeserializeXmlObject(xml, true); Assertions.NullCheck(ret, "ret"); //create map of object infos var map = new Dictionary <ObjectClass, ObjectClassInfo>(ret.Count); foreach (ObjectClassInfo o in ret) { map.Add(new ObjectClass(o.ObjectType.ToString()), o); } return(map); }
protected override Object CloneObject(Object o) { String xml = SerializerUtil.SerializeXmlObject(o, true); Console.WriteLine(xml); o = SerializerUtil.DeserializeXmlObject(xml, true); //pass through a list to make sure dtd correctly defines all xml objects List <Object> list = new List <Object>(); list.Add(o); xml = SerializerUtil.SerializeXmlObject(list, true); Console.WriteLine(xml); IList <Object> rv = (IList <Object>)SerializerUtil.DeserializeXmlObject(xml, true); return(rv[0]); }
private bool ProcessRequest() { CultureInfo locale; try { locale = (CultureInfo)_connection.ReadObject(); } catch (EndOfStreamException) { return(false); } //We can't set this because C# does not like language-neutral //cultures for CurrentCulture - this tends to blow up //TODO: think more about this... //Thread.CurrentThread.CurrentCulture = locale; Thread.CurrentThread.CurrentUICulture = locale; GuardedString key = (GuardedString)_connection.ReadObject(); bool authorized; try { authorized = key.VerifyBase64SHA1Hash(_server.KeyHash); } finally { key.Dispose(); } Org.IdentityConnectors.Framework.Common.Exceptions.InvalidCredentialException authException = null; if (!authorized) { authException = new Org.IdentityConnectors.Framework.Common.Exceptions.InvalidCredentialException("Remote framework key is invalid"); } Object requestObject = _connection.ReadObject(); if (requestObject is HelloRequest) { if (authException != null) { HelloResponse response = new HelloResponse(authException, null, null, null); _connection.WriteObject(response); } else { HelloResponse response = ProcessHelloRequest((HelloRequest)requestObject); _connection.WriteObject(response); } } else if (requestObject is OperationRequest) { if (authException != null) { OperationResponsePart part = new OperationResponsePart(authException, null); _connection.WriteObject(part); } else { OperationRequest opRequest = (OperationRequest)requestObject; OperationResponsePart part = ProcessOperationRequest(opRequest); _connection.WriteObject(part); } } else if (requestObject is EchoMessage) { if (authException != null) { //echo message probably doesn't need auth, but //it couldn't hurt - actually it does for test connection EchoMessage part = new EchoMessage(authException, null); _connection.WriteObject(part); } else { EchoMessage message = (EchoMessage)requestObject; Object obj = message.Object; String xml = message.ObjectXml; if (xml != null) { Console.WriteLine("xml: \n" + xml); Object xmlClone = SerializerUtil.DeserializeXmlObject(xml, true); xml = SerializerUtil.SerializeXmlObject(xmlClone, true); } EchoMessage message2 = new EchoMessage(obj, xml); _connection.WriteObject(message2); } } else { throw new Exception("Unexpected request: " + requestObject); } return(true); }