Build a DataSnap Client and Server - Delphi 233

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
goodday alist here from learn.tv and in this video we're going to write a small data snap server and client and we'll start with the server so we'll go new other data snap and dat snap server so you've got two options rest and uh sort of non-rest uh we're with a non-rest it's more efficient on local networks um because the data is binary forms application vcl well should go back so forms application perfect for debugging uh service application is probably what you'd use to deploy we will make a vcl application and we're sticking with TCP if you do HTTP or htps it's still using binary it's not rest it's still binary um formats but we're also going to add encryption and authentication so if we go next Port 211 yes I haven't got a server running currently so that's good and T component is good if you're wanting to put data sets and things on there it's good to have a this DS server module we're just going to have a couple methods so a t component is perfect okay so ooh nice okay that um is that going to come back and haunt us no that seems to be fine now so we have our new server unit and this this is our T server methods one and it's got the two sample methods Echo string and reverse string and in our server container we have a server class and that is hooked up when we get a get class to our server methods one we also have a authentication manager which we'll talk about later that's for our username and password stuff a transport filter that is if we go here and look at the filters we see that we've got oursa encryption and pc1 well that's RSA for the um exchanging the private Keys uh for the exch the P exchanging the pc1 key but anyway and there's also the D server uh which is auto start so this is now capable of running so we'll run that and minimize that down and let's build our client and so I'm going to build a new Windows vcl application and we need a SQL connection which I'm not going to give any particular uh name to we do need to specify the driver as being data data snap and I'm going to disable login prompt because it does not work and we can see in our parameters um host name is Local Host and so we don't need to do anything and we are connected to our server so we now want to do our reverse string uh method so I'm going to throw an edit on there and I'm going to call it edit reverse string this is um part of CN Pac up here so you need to install that if you want component naming and a button button reverse and I'm just going to remove the button from the caption and we'll throw that somewhere there so click on reverse and it reverses the string in here fairly simple to be able to do that we need to generate proxy classes and if we right click um we can generate the data St client classes I'll do that and then we have our T methods one client with an echo string and a reverse string so um also if if you're doing this uh I found the the generate proxy classes to be a bit unreliable if you're doing it uh regularly so you can add a DS proxy generator and that needs a metadata provider and we need a a connection metadata provider which we hook up to our SQL connection and our metadata provider and in here we can specify uh that we want uh object pescal dbx and then we can specify a a file name and directory and other bits and pieces uh but um we're not going to bother with that we're just going to stick with our unit 41 so we need to use 41 so what we need to do is create a server and I'm just going to grab copy and paste that now it needs a dbx connection now our SQL connection one is not a dvx connection but it has one and of course and of course want fre it so call rever string method need to specify a string which of course is our uh edit reverse string. text okay and the other thing I need to do really do is okie dokie so in theory there should be enough yep so that's that's uh you know sending this off Getting It reversed and uh retrieving the the result so uh not a very efficient way to reverse a string but um it's exactly what we want to achieve we are communicating with our server so our next step if I just shut down the server is we want to specify a username and password and we do that in the auth authentication manager so I'm just going to use same text um and the user is going to be alista and same St maybe for so same text is not case sensitive so password and not secure and we make it not secure one just to make it slightly less not secure uh but yeah not a very good password uh I think that that would get broken uh in a reasonable amount of time and so we we need to rerun our server so run without debugging come back to our client and in our client we need to specify the username and password now I mentioned briefly about the login prompt not working um that is because in our parameters uh I there's no way of adding uh new ones here so we go to the code editor and authentication I'm going to copy that to the board user equals oops Alister will not secure one okay save yes please so that should now be in our parameters now the reason why the login prompt doesn't work is because the login prompt sets parameters user uncore name and password not DS authentication user and DS authentication password so um it probably should if should detect the driver's data snap but anyway or you know username and password should work uh for data snap but that's okay so we should be able to sit connected true yes and we if we run that now our rever string works and we have you know it's predicted by predicted by username and password and encryption um all safe and secure right well not really uh it's only secure if you're not concerned about security so firstly we're storing the username and password on the client we really need to prompt for it and yeah and in these server methods uh no server container um in the transport so let's go filters we have uh this pc1 and is is that is that a good good key um the answer is no uh but not possibly for the reasons you might think and we've got a key length of 1024 and a key exponent of three uh are those values good well you can easily Google that because this is the standard irsa properties um the answer is again uh it depends and if you want to find out how how to fix the security and this application to come to my talk at adag this year at the adag Symposium so we have here scr top so um this is the 2024 Symposium and I am presenting a paper or a topic enhancing application Security in dely and we'll talk about the um usual SQL injection and guey modification kind of stuff you know how how secure a win32 goys um answer is not very but there are plenty of ways of of fixing that um there like CSV injection that was a new one to me recently and a few other bits and pieces um there's also PDF injection um which can be a problem so do come along to my talk on the 17th of May 2024 if it's past that date there hopefully will be a replay available for it although not necessarily there is a uh small fee I think for attending but um basically this there are prizes and effectively your your fee will be completely um minuscule compared to the sponsors this there usually Stu I've done a few books I think you'll have to be attending in person uh to get a copy of the um the physical book but anyway I'm I'm rambling do come along to the talk if you can make it uh it should be quite interesting I'm looking forward to seeing some of these other talks as well so I'm Alis Christie from.tv oh and I I should do self-promotion as well I do have a couple of books code fast in delphy and code better in delphy which you can get um from learn.tv so uh yep I'm Christie attend my get my books and I'll see you in the next video thanks for watching
Info
Channel: Alister Christie
Views: 1,165
Rating: undefined out of 5
Keywords: Delphi
Id: cruS-XKeWbU
Channel Id: undefined
Length: 11min 34sec (694 seconds)
Published: Fri May 03 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.