Policy Builders
PrivMX Endpoint has configurable policies that determine who can perform specified actions in Containers and Items. To learn more about them, see the Policies documentation.
PrivMX Endpoint Java Extra library provides classes that provide static fields of available policy values in ItemPolicyValues
, ContainerPolicyValues
and SpecialPolicyValue
,
as well as ItemPolicyBuilder
and ContainerPolicyBuilder
classes for configuring the respective policies.
Combining Policy Values
Some policy values like ContainerPolicyComplexValue
or ItemPolicyComplexValue
can be combined
with the same type of policy value using .AND()
or .OR()
methods.
Configuring a Container Policy
Builder will create an empty policy, if it's not configured yet, which is equivalent to setting inherit
in all fields. To configure it, call the methods responsible for setting particular policies.
Those calls can be chained together, since each of the methods setting a policy value returns the reference to the builder.
The ContainerPolicyBuilder
can build both ContainerPolicy
and ContainerPolicyWithoutItem
by calling .build()
and .buildWithoutItem()
respectively.
To build the ItemPolicy
, use ItemPolicyBuilder
which works in the same way as ContainerPolicyBuilder
:
val itemPolicy: ItemPolicy = ItemPolicyBuilder()
.setUpdate(
ItemPolicyValues.ITEM_OWNER
.AND(ItemPolicyValues.MANAGER)
.OR(ItemPolicyValues.USER)
)
.setListMy(ContainerPolicyValues.USER)
.build()