Hi Ivana,
for plugin development this can be done via the ContentPermissionManager.
You first have to get a ContentPermnissionSet from the desired page for the permission type you want to assign (these types are ContentPermission.EDIT_PERMISSION,ContentPermission.SHARED_PERMISSION, ContentPermission.VIEW_PERMISSION). Then you can create a new ContentPermission via the ContentPermission (you can use the method createUserPermission(, )
for this). Now you only have to add this new permission to the previously taken ContentPermisssionSet and via ContentPermissionManager add the ContentPermission to the page.
Then save the page and you are fine.
Hope this helps.