Add permission mask decoding

in #utopian-io6 years ago (edited)

permission_out.png

(EN) Add permission mask decoding.

Because the ScadaLTS permissions do not work, we store them in a separate User-Management system, which we ask for permissions using the REST API.

  • API PermissionEvaluator:
    • /api/permission/filter takes into account the isRead permission mask, i.e. if the user has the isRead
      permission set to the element, he will be able to see the element.
    • /api/permission/hasPermission he asks for permission (isRead, isWrite, isExecute) in context.

This causes that we need to decode the permission mask on the backend side which should be added in this task.

The task involves the preparation of the decoding mechanism itself and tests.

  • For mask decoding purposes, the EncodeAndDecodeMaskPermission class was created in the org.scada_lts.shared package with the methods:
    • byte getBit(Integer mask, byte index) - The method return the int (0,1) value based on the converted numeric mask e.g. 1, into a string, e.g. '001' and a bit based on the index, eg an index equal to 2 returns 1.
    • int getMask(isRead, isWrite, isExecute) - The method that returns the mask in numerical form based on the permissions.
    • byte isRead(Integer mask) - The method that checks the isExecute permission in the mask on the first bit from the left, returns 0 or 1. eg mask 1 '100' will return 1 and '010' will return 0.
    • byte isWrite(Integer mask) - The method that checks the isWrite permission in the mask on the second bit from the left, returns 0 or 1. eg mask 2 '010' will return 1 and '100' will return 0.
    • byte isExecute(Integer mask) - The method that checks the isExecute permission in the mask on the third bit from the left, returns 0 or 1. eg mask 1 '001' will return 1 and '100' will return 0.

Link to sources:
EncodeAndDecodeMaskPermission
EncodeAndDecodeMaskPermissionTest

I'm just learning English, this is not my native language, I am asking for understanding on language issues.

(PL) Dodanie dekodowania maski uprawnień.

Dlatego że uprawnienia w ScadaLTS nie działają przechowujemy je w osobnym systemie User-Management, którego pytamy się o uprawnienia używając REST API.

  • API PermissionEvaluator:
    • /api/permission/filter uwzględnia maskę uprawnienia isRead czyli jeśli użytkownik będzie miał uprawnienie isRead ustawione do elementu to będzie mógł zobaczyć element.
    • /api/permission/hasPermission dostaje zapytanie o uprawnienie (isRead, isWrite, isExecute) w kontekście.

To powoduję, że potrzebujemy dekodować maskę uprawnień po stronie backendu co należy dodać w tym zadaniu.

Zadanie obejmuje przygotowanie samego mechanizmu dekodowania i testy.

  • Dla celów dekodowania maski powstała klasa EncodeAndDecodeMaskPermission w pakiecie org.scada_lts.shared z metodami:
    • byte getBit(Integer mask, byte index) - Metoda zwracająca wartości int (0,1) na podstawie zamienionej maski numerycznej (np. 1) na ciąg znaków np. ‘001’ i pobranie bit-u na podstawie indeksu np. index równy 2 zwróci 1.
    • int getMask(isRead, isWrite, isExecute) - Metoda zwracająca maskę w postaci numerycznej na podstawie uprawnień.
    • byte isRead(Integer mask) - Metoda sprawdzająca uprawnienie isRead w masce na pierwszym bicie od lewej strony, zwraca 0 lub 1. np. maska ‘100’ zwroci 1 a ‘010’ zwróci 0.
    • byte isWrite(Integer mask) - Metoda sprawdzająca uprawnienie isWrite w masce na drugim bicie od lewej strony, zwraca 0 lub 1. np. maska 2 ‘010’ zwróci 1 a ‘100’ zwróci 0.
    • byte isExecute(Integer mask) - Metoda sprawdzająca uprawnienie isExecute na trzecim bicie od lewej, zwraca 0 lub 1. np maska ‘001’ zwraca wartość 0 lub 1. np. dla maski ‘001’ zwróci 1 a dla maski ‘010’ zwróci 0;

Link do źródeł:
EncodeAndDecodeMaskPermission
EncodeAndDecodeMaskPermissionTest



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Dziękuję, za szybką reakcje.

Hey @grzesiekb I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • This is your first accepted contribution here in Utopian. Welcome!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

gwoli informacji, tak długo dopóki cena SBD jest wyższa niż 1 USD, nie opłaca się brać 100% Power Up, już lepiej jest 50/50 i potem zamienic SBD i STEEM i dopiero PowerUp. Przy obecnej cenie SBD można dostać nawet kilka razy więcej.

To dość ważna kwestia :), spróbuje to ogarnąć jak to się wylicza i przelicza i opisać to.

Cokolwiek to znaczy ciesze się, że kolejny Polak doceniony. Zupełnie nie mam pojęcia o czym piszecie :-) a skubnąłbym troszke wiedzy.

Piszę o zmianach w kodzie programu open-source Scada-LTS. Program może służyć do automatyzacji domu lub monitorowania np. oczyszczalni ścieków, krótki opis również na steemit Opis Scada-LTS

No to łeb na karku masz :-)

Wynik robi wrażenie...

To zasługa utopion-io

Właśnie widzę, ale czy jest tam miejsce dla fotografów? Czu samo stosowanie tagu jest konieczne, czy jakieś dodatkowe zasady podczas publikacji postow?

Post zamieszczasz ze strony utopian.io, i tak są dodatkowe zasady utopian-io rules, jest sekcja opisująca prace graficzne to może fotograf też mógłby wspierać pracę nad projektami open-source. (to jest do sprawdzenia)