#2 mORMot 1 » ObjectToJSON vs RecordSaveJson » 2021-02-24 14:04:47

zensan
Replies: 2

Hi!

Is that possible to serialize the given object a simple way (dump) just like RecordSaveJson?
The problem is that ObjectToJson always returns empty json if there is no properties! But I do not want any properties, I just have plain fields to serialize..
THe idea is that I want in some future switch from SuperObject to SynOpse for JSON serialization.

type
  TMyClass = class
  public
    name: String;
    value: Double;
  end;

  TMyRecord = record
  public
    name: String;
    value: Double;
  end;

Everything works fine with record, but never with a class.
SuperObject JSON or any other library does this without problem, but I cant get it working with SynCommons unit.
What do I miss?

1) I do not want or will descend from TSynPersistent;
2) I can't add properties/change the interfaces of the class;
3) I tried ObjectToVariant -> VariantToJson;
4) I have mORMot unit in uses list for TJSONSerializer.

Many thanks for your help!

#3 Re: mORMot 1 » Invalid signature when verifying TJWTHS256 » 2018-07-10 09:54:08

Thank you very much for the info. It worked fine in the end when using the same encoding on .NET side, but also required minimal length of the secret key (it was too short for 256 bit token smile ).

#4 mORMot 1 » Invalid signature when verifying TJWTHS256 » 2018-07-04 12:07:22

zensan
Replies: 2

Hello!

We are trying to start using the TJWTHS256 classes. But we immediately faced the issue when trying to verufy the generated tokens in ASP.NET or .NET application.

So I tried the following and that works fine in the code:

var
  LToken: TJWTAbstract;
  LTokenText: RawUTF8;
...
  LToken := TJWTHS256.Create('The secret password', 0, [jrcIssuer, jrcSubject, jrcIssuedAt, jrcJwtID], []);
  LTokenText := LToken.Compute(['http://www.ourdomain.com', True], 'Issuer', 'subject', '', 0);
  Result := LToken.VerifyPayload(LTokenText, 'subject', 'Issuer', '') = jwtValid;
...
Result in the Delphi app is True. So if I understood correctly - the VerifyPayload method returns true. And also we can see in the generated token that there is a signature in the end.

But when we try to validate the given token outside of Delphi and mORMot world it always says "Invalid signature"!

For example: https://www.jsonwebtoken.io/ parses all the data, but says that the signature is not valid (that also happens in other web-sites). We tried removing the expiration claim but that does not change anything.

Can you help us with understanding what we are doing wrong?

Thank you in advance!

#5 Re: mORMot 1 » THttpServerRequest interface based REST server and response code » 2017-12-14 13:57:48

Should I use OnErrorURI event of the TSQLRestServer. Is that the right approach?

Just for the record it looks like that actually does the job. I just check the exception class of the event OnErrorURI parameter and if it is of my ERESTServerError then I return false and set the error from the properties of the exception.

#6 mORMot 1 » THttpServerRequest interface based REST server and response code » 2017-12-14 13:36:55

zensan
Replies: 1

Hi!

I am using your HTTPServer for providing REST access to the API of a certain system. All is fine, but I can't figure out how can I do one thing.
So I was using the Sample 14 for the start. So I do TInterfaceFactory.RegisterInterfaces([TypeInfo(IMyInterfaceName)]) and so on (so create the TSQLModel, TSQLRestServerFullMemory and TRestHTTPServer.

When I have the method like UserDisplayInfo(ID: Integer): TUserDisplayInfo then I get the response with 200 OK and the JSON of the record which is all fine.
But when the user is not found by the ID we wish to return the response code 404 (for example) or some other code accordingly to the standard..

How that can be done?

I thought first that maybe SynXXX has some kind of raise ESynHTTPErrorCode.Create(AErrorCode: Cardinal; AMessage: String)... but when I look at handling of the Request method of the HTTP server I see that the responses are kind of hard-coded. And I can only override them if I override the Request method - which actually is not so convinient probably..

Thanks in advance!

#7 mORMot 1 » Generating the ORM classes for an existing database » 2015-12-04 09:02:13

zensan
Replies: 0

Hi!

Do you have any possibility to generate the ORM classes for an existing MS SQL Server database tables?

I checked out samples 12 - SynDBExplorer... but after I got connected to the DB the form was a bit strange (empty list of tables and objects), executing SQL raised class not registered.. and after I closed the app and started it again choosing the configured MSSQL connection I got a Class not registered error on line
Props.ForeignKeysData := UncompressString(C.ForeignKeys); in function TryConnect.

Thanks in advance.

#9 Re: mORMot 1 » Leaf b8275632e2 or latest version issue » 2015-07-30 07:16:52

Yes, thanks. I just did that.. But that wasn't obvios for me as I even forgot that I have SynopsePDF installed.. smile

By the way TestSQL3.dpr fails on PDF tests..

I have removed the old SynPDF folder at all.

#10 Re: mORMot 1 » Leaf b8275632e2 or latest version issue » 2015-07-29 13:44:12

I have installed the SynPDF library before... and the INC file was conflicting with the one in the mORMot.

So I managed that..

#11 mORMot 1 » Leaf b8275632e2 or latest version issue » 2015-07-29 10:51:39

zensan
Replies: 5

Hi!

I am new user for the mORMot framework. So I downloaded (latest sources) your library [b8275632e2] as instructed and tried to check samples I am interested in.

And in the manual it is described that I can build and run TestSQL3.dpr but it fails with the error:
[dcc32 Error] mORMotHttpClient.pas(433): E2003 Undeclared identifier: 'TSQLHttpClientWinHTTP'

I am using Delphi XE7 Update 1.

When trying to compile samples I get another error:
[dcc32 Error] SynLog.pas(328): E2003 Undeclared identifier: 'TSynPersistentLocked'

What do I do wrong (except choosing the developer job wink )?

Thanks in advance!

Board footer

Powered by FluxBB