public override IDataTransferable Duplicate() { IWCCertificate m = new IWCCertificate(); m.FromOSD(ToOSD()); return(m); }
public override IDataTransferable Duplicate() { IWCCertificate m = new IWCCertificate(); m.FromOSD(ToOSD()); return m; }
public override void FromOSD(OSDMap map) { TrustLevel = (TrustLevel)map["TrustLevel"].AsInteger(); Certificate = new IWCCertificate(); Certificate.FromOSD((OSDMap)OSDParser.DeserializeJson(map["Certificate"].AsString())); URL = map["URL"].AsString(); }
/// <summary> /// This is a request to remove the remote host from our list of current connections. /// </summary> /// <param name="request"></param> /// <returns></returns> private byte[] Delete(OSDMap request) { IWCCertificate Certificate = new IWCCertificate(); //Pull the connection info out of the request Certificate.FromOSD(request); //Make sure that they are verified to connect if (!CertificateVerification.VerifyCertificate(Certificate)) return FailureResult(); //Remove them from our list of connections CertificateVerification.RemoveCertificate(Certificate); return SuccessfulResult(); }
/// <summary> /// This is the initial request to join this host /// We need to verify passwords and add sessionHashes to our database /// </summary> /// <param name="request"></param> /// <returns></returns> private byte[] Query(OSDMap request) { IWCCertificate Certificate = new IWCCertificate(); //Pull the connection info out of the request Certificate.FromOSD(request); //Lets make sure that they are allowed to connect to us if (!CertificateVerification.VerifyCertificate(Certificate)) { //Make sure the other host is not trying to spoof one of our certificates if (CertificateVerification.GetCertificateBySessionHash(Certificate.SessionHash) != null) { //SPOOF! XXXXXX return FailureResult(); } //This is an untrusted connection otherwise if (!IWC.m_allowUntrustedConnections) return FailureResult(); //We don't allow them //Give them the default untrusted connection level Certificate.TrustLevel = IWC.m_untrustedConnectionsDefaultTrust; } //Update them in the database so that they can connect again later CertificateVerification.AddCertificate(Certificate); BuildSecureUrlsForConnection(Certificate); OSDMap result = Certificate.ToOSD(false); result["Result"] = "Successful"; return Return(result); }
/// <summary> /// Query the given host (by connection) and verify that we can connect to it. /// </summary> /// <param name="connector">The host to connect to</param> /// <returns>The connection that has been recieved from the host</returns> public IWCCertificate QueryRemoteHost(Connection connection) { OSDMap request = connection.Certificate.ToOSD(false); request["Method"] = "Query"; OSDMap reply = WebUtils.PostToService(connection.URL, request); if (reply["Success"].AsBoolean()) { if (reply["_Result"].Type != OSDType.Map) { m_log.Warn("[IWC]: Unable to connect successfully to " + connection.URL + ", connection did not have all the required data."); return null; } OSDMap innerReply = (OSDMap)reply["_Result"]; if (innerReply["Result"].AsString() == "Successful") { IWCCertificate c = new IWCCertificate(); c.FromOSD(innerReply); m_log.Error("[IWC]: Connected successfully to " + connection.URL); return c; } m_log.Warn("[IWC]: Unable to connect successfully to " + connection.URL + ", " + innerReply["Result"]); } else { m_log.Warn("[IWC]: Unable to connect successfully to " + connection.URL); } return null; }