Can you give me some example of authorization.
- How can I add a new user.
- How can I set access to a register, cuz I tried to do like this:
RegPointer->SetAccess(2, DLMS_ACCESS_MODE_AUTHENTICATED_READ);
But it still was available even without authorization.
You don't add users for authorization. The password is validated using ValidateAuthentication method when authentication level is Low. If authentication level is high, you need to create an Association object and set the correct secret for it. The secret is checked automatically.
The attribute access is get using GetAttributeAccess method.
Okay, I got the theory.
But what is the syntaxis in your library?
Cuz I couldn't find any example of it using.
So, I should to call some methods in method 'Init' for server or I should just write the password some where else?
Okay, I did this:
CGXByteBuffer buff(20);
buff.AddString("12345");
ValidateAuthentication(DLMS_AUTHENTICATION_LOW, buff);
Inside of int CGXDLMSBase::Init this part of code. But the client still can connect without any auth.
What am I doing wrong?
And what should I do to set some password for some auth level?
And also should I do this ->SetAccess() for every register I want to set an access restriction for?
Like this ->SetAccess(2, DLMS_ACCESS_MODE_READ);
Each association has its own password. It's checked by the framework, but you need to set if for the association object. You can set it when association object is create or you can set it like this:
//Find the association object.
CGXDLMSAssociationLogicalName* ln = (CGXDLMSAssociationLogicalName*)GetItems().FindByLN(
DLMS_OBJECT_TYPE_ASSOCIATION_LOGICAL_NAME, "0.0.40.0.0.255");
//Set the secret
CGXByteBuffer secret;
secret.AddString("Gurux");
ln->SetSecret(&secret);
You can check the accessrights using GetAttributeAccess.
Note that accessright might depends from the used association.
Hi,
Hi,
Are you implementing the meter or reading one?
BR,
Mikko
I am implementing one.
I am implementing one.
Hi,
Hi,
You don't add users for authorization. The password is validated using ValidateAuthentication method when authentication level is Low. If authentication level is high, you need to create an Association object and set the correct secret for it. The secret is checked automatically.
The attribute access is get using GetAttributeAccess method.
Check this:
https://www.gurux.fi/Gurux.DLMS.Server
BR,
Mikko
Okay, I got the theory.
Okay, I got the theory.
But what is the syntaxis in your library?
Cuz I couldn't find any example of it using.
So, I should to call some methods in method 'Init' for server or I should just write the password some where else?
Hi,
Hi,
There might be multiple associations and each association might have a different password.
COSEM access rights vary between associations.
Password is check here:
https://github.com/Gurux/GuruxDLMS.c/blob/9a684a6966589b0e59acdcea3d26b…
The access rights are check in svr_getAttributeAccess.
BR,
Mikko
Okay, I did this:
Okay, I did this:
CGXByteBuffer buff(20);
buff.AddString("12345");
ValidateAuthentication(DLMS_AUTHENTICATION_LOW, buff);
Inside of int CGXDLMSBase::Init this part of code. But the client still can connect without any auth.
What am I doing wrong?
Hi,
Hi,
I'm sorry. You are using ANSI C++ and not ANSI C. This is the correct example:
https://github.com/Gurux/Gurux.DLMS.cpp/blob/ad9528a9678ea80cf12caba2ab…
You don't call the ValidateAuthentication, the framework will call it when needed.
BR,
Mikko
Okay, got it thanks.
Okay, got it thanks.
And what should I do to set some password for some auth level?
And also should I do this ->SetAccess() for every register I want to set an access restriction for?
Like this ->SetAccess(2, DLMS_ACCESS_MODE_READ);
Hi,
Hi,
Each association has its own password. It's checked by the framework, but you need to set if for the association object. You can set it when association object is create or you can set it like this:
//Find the association object.
CGXDLMSAssociationLogicalName* ln = (CGXDLMSAssociationLogicalName*)GetItems().FindByLN(
DLMS_OBJECT_TYPE_ASSOCIATION_LOGICAL_NAME, "0.0.40.0.0.255");
//Set the secret
CGXByteBuffer secret;
secret.AddString("Gurux");
ln->SetSecret(&secret);
You can check the accessrights using GetAttributeAccess.
Note that accessright might depends from the used association.
https://github.com/Gurux/Gurux.DLMS.cpp/blob/ad9528a9678ea80cf12caba2ab…
BR,
Mikko