java.lang.Comparable<Permission>
, net.sergeych.biserializer.BiSerializable
ChangeNumberPermission
, ChangeOwnerPermission
, ChangeRolePermission
, ModifyDataPermission
, RevokePermission
, SplitJoinPermission
public abstract class Permission extends java.lang.Object implements net.sergeych.biserializer.BiSerializable, java.lang.Comparable<Permission>
Role
player (e.g. Universa party, set of keys used in signing the contract) to
perform some change over the contract state. The real permissions are all superclasses of it.
The actually permission implementation must implement #checkChanges(Contract, Contract, Map,Set,Collection,Collection)
, see this method for
information on how to approve changes with the permission.
Modifier and Type | Field | Description |
---|---|---|
protected net.sergeych.tools.Binder |
params |
Modifier | Constructor | Description |
---|---|---|
protected |
Permission() |
|
protected |
Permission(java.lang.String name,
Role role) |
|
protected |
Permission(java.lang.String name,
Role role,
net.sergeych.tools.Binder params) |
Modifier and Type | Method | Description |
---|---|---|
void |
checkChanges(Contract contract,
Contract changed,
java.util.Map<java.lang.String,net.sergeych.diff.Delta> stateChanges,
java.util.Set<Contract> revokingItems,
java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Process changes of the contract.
|
abstract void |
checkChangesQuantized(Contract contract,
Contract changed,
java.util.Map<java.lang.String,net.sergeych.diff.Delta> stateChanges,
java.util.Set<Contract> revokingItems,
java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Process changes of the contract.
|
int |
compareTo(Permission o) |
Compares permissions by name.
|
void |
deserialize(net.sergeych.tools.Binder data,
net.sergeych.biserializer.BiDeserializer deserializer) |
|
boolean |
equals(java.lang.Object obj) |
Compares permission with obj.
|
static Permission |
forName(java.lang.String name,
Role role,
net.sergeych.tools.Binder params) |
Create new permission of a specific type by type name
|
@Nullable java.lang.String |
getId() |
Get the permission id or null if is not yet set.
|
java.lang.String |
getName() |
Get name of permission.
|
net.sergeych.tools.Binder |
getParams() |
Get params of permission or null if is not yet set.
|
Role |
getRole() |
Get role allows to permission.
|
boolean |
isAllowedFor(java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Deprecated.
|
boolean |
isAllowedForKeys(com.icodici.crypto.PublicKey... keys) |
Deprecated.
|
boolean |
isAllowedForKeys(java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Deprecated.
|
boolean |
isAllowedForKeysQuantized(com.icodici.crypto.PublicKey... keys) |
Check permission is allowed to keys
|
boolean |
isAllowedForKeysQuantized(java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Check permission is allowed to keys
|
boolean |
isAllowedForQuantized(java.util.Collection<com.icodici.crypto.PublicKey> keys) |
Check permission is allowed to keys and references
|
net.sergeych.tools.Binder |
serialize(net.sergeych.biserializer.BiSerializer serializer) |
|
void |
setId(@NonNull java.lang.String id) |
Set the permission id.
|
java.lang.String |
toString() |
Get permission as string.
|
protected Permission()
protected Permission(java.lang.String name, Role role)
protected Permission(java.lang.String name, Role role, net.sergeych.tools.Binder params)
public @Nullable java.lang.String getId()
public void setId(@NonNull java.lang.String id)
id
- is identifierpublic net.sergeych.tools.Binder getParams()
public static Permission forName(java.lang.String name, Role role, net.sergeych.tools.Binder params)
name
- is specific type namerole
- allows to permissionparams
- is parameters of permission, set of parameters depends on the type of permission@Deprecated public boolean isAllowedForKeys(com.icodici.crypto.PublicKey... keys)
keys
- is public keys@Deprecated public boolean isAllowedForKeys(java.util.Collection<com.icodici.crypto.PublicKey> keys)
keys
- is collection of public keys@Deprecated public boolean isAllowedFor(java.util.Collection<com.icodici.crypto.PublicKey> keys)
keys
- is collection of public keyspublic boolean isAllowedForKeysQuantized(com.icodici.crypto.PublicKey... keys) throws Quantiser.QuantiserException
keys
- is public keysQuantiser.QuantiserException
public boolean isAllowedForKeysQuantized(java.util.Collection<com.icodici.crypto.PublicKey> keys) throws Quantiser.QuantiserException
keys
- is collection of public keysQuantiser.QuantiserException
public boolean isAllowedForQuantized(java.util.Collection<com.icodici.crypto.PublicKey> keys) throws Quantiser.QuantiserException
keys
- is collection of public keysQuantiser.QuantiserException
public net.sergeych.tools.Binder serialize(net.sergeych.biserializer.BiSerializer serializer)
serialize
in interface net.sergeych.biserializer.BiSerializable
public void deserialize(net.sergeych.tools.Binder data, net.sergeych.biserializer.BiDeserializer deserializer)
deserialize
in interface net.sergeych.biserializer.BiSerializable
public final void checkChanges(Contract contract, Contract changed, java.util.Map<java.lang.String,net.sergeych.diff.Delta> stateChanges, java.util.Set<Contract> revokingItems, java.util.Collection<com.icodici.crypto.PublicKey> keys)
Contract.addError(Errors, String)
for all relevant but
inappropriate changes.
IMPORTANT NOTE. Implementations usually should not add errors to the contract unless the permission can be used only once in any contract, such as change_owher or revoke. In all other cases, when the permission could be specified several times for different roles and with different parameter, implementation should do nothing on the error and let others porceed. Unprocessed changes will cause error if no permission will clear it.
contract
- source (valid) contractchanged
- is contract for checkingstateChanges
- map of changes, see Delta
for detailsrevokingItems
- items to be revoked. The ones are getting joined will be removed during checkkeys
- keys contract is sealed with. Keys are used to check other contracts permissionspublic abstract void checkChangesQuantized(Contract contract, Contract changed, java.util.Map<java.lang.String,net.sergeych.diff.Delta> stateChanges, java.util.Set<Contract> revokingItems, java.util.Collection<com.icodici.crypto.PublicKey> keys) throws Quantiser.QuantiserException
Contract.addError(Errors, String)
for all relevant but
inappropriate changes.
IMPORTANT NOTE. Implementations usually should not add errors to the contract unless the permission can be used only once in any contract, such as change_owher or revoke. In all other cases, when the permission could be specified several times for different roles and with different parameter, implementation should do nothing on the error and let others porceed. Unprocessed changes will cause error if no permission will clear it.
contract
- source (valid) contractchanged
- is contract for checkingstateChanges
- map of changes, see Delta
for detailsrevokingItems
- items to be revoked. The ones are getting joined will be removed during checkkeys
- keys contract is sealed with. Keys are used to check other contracts permissionsQuantiser.QuantiserException
public java.lang.String toString()
toString
in class java.lang.Object
public Role getRole()
public java.lang.String getName()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- is compared objectpublic int compareTo(Permission o)
compareTo
in interface java.lang.Comparable<Permission>
o
- is compared permission