net.sergeych.biserializer.BiSerializable
ListRole
, QuorumVoteRole
, RoleLink
, SimpleRole
public abstract class Role
extends java.lang.Object
implements net.sergeych.biserializer.BiSerializable
IMPORTANT, This class express "any_of" logic, e.g. if any of the presented keys is listed, then the role is allowed.
Modifier and Type | Class | Description |
---|---|---|
static class |
Role.RequiredMode |
/* Mode of combining references
|
Modifier and Type | Field | Description |
---|---|---|
protected java.util.Set<java.lang.String> |
requiredAllReferences |
|
protected java.util.Set<java.lang.String> |
requiredAnyReferences |
Modifier | Constructor | Description |
---|---|---|
protected |
Role() |
|
protected |
Role(java.lang.String name) |
Deprecated.
|
protected |
Role(java.lang.String name,
Contract contract) |
Modifier and Type | Method | Description |
---|---|---|
void |
addAllRequiredReferences(java.util.Collection<Reference> references,
Role.RequiredMode requiredMode) |
Adds required references to role.
|
void |
addRequiredReference(Reference reference,
Role.RequiredMode requiredMode) |
Adds required reference to role.
|
void |
addRequiredReference(java.lang.String refName,
Role.RequiredMode requiredMode) |
Adds required reference to role.
|
abstract void |
anonymize() |
If this role has public keys, they will be replaced with
AnonymousId . |
boolean |
containReference(java.lang.String name) |
|
void |
deserialize(net.sergeych.tools.Binder data,
net.sergeych.biserializer.BiDeserializer deserializer) |
|
boolean |
equalAddresses(Role otherRole) |
Deprecated.
|
boolean |
equalAnonIds(Role otherRole) |
Deprecated.
|
boolean |
equalKeys(@NonNull Role otherRole) |
Deprecated.
the only usable check allowance method is isAllowedForKeys
|
boolean |
equals(java.lang.Object obj) |
Role equality is different: it only checks that it points to the same role.
|
boolean |
equalsIgnoreName(Role otherRole) |
|
protected abstract boolean |
equalsIgnoreNameAndRefs(Role otherRole) |
|
static Role |
fromDslBinder(java.lang.String name,
net.sergeych.tools.Binder serializedRole) |
Create new role from dsl.
|
java.util.List<java.lang.String> |
getAllAddresses() |
Deprecated.
the only usable check allowance method is isAllowedForKeys
|
abstract java.util.Set<AnonymousId> |
getAnonymousIds() |
Deprecated.
getting plain keys from the role without understanding its internal structure is not allowed.
|
java.lang.String |
getComment() |
Get comment of role
|
Contract |
getContract() |
Get role contract.
|
abstract java.util.Set<com.icodici.crypto.KeyAddress> |
getKeyAddresses() |
Deprecated.
getting plain keys from the role without understanding its internal structure is not allowed.
|
KeyRecord |
getKeyRecord() |
Deprecated.
the only usable check allowance method is isAllowedForKeys
|
abstract java.util.Set<KeyRecord> |
getKeyRecords() |
Deprecated.
getting plain keys from the role without understanding its internal structure is not allowed.
|
abstract java.util.Set<com.icodici.crypto.PublicKey> |
getKeys() |
Deprecated.
getting plain keys from the role without understanding its internal structure is not allowed.
|
java.lang.String |
getName() |
Get name of role
|
java.util.Set<java.lang.String> |
getReferences(Role.RequiredMode requiredMode) |
Get set of references corresponding to the specified mode of combining references (
Role.RequiredMode ). |
@Nullable com.icodici.crypto.KeyAddress |
getSimpleAddress() |
Get an address from the role, if it is just a single one.
|
java.util.Set<java.lang.String> |
getSpecialReferences() |
Get names of
Reference that are not required but are used in voting. |
int |
hashCode() |
Get hash code of role name
|
abstract void |
initWithDsl(net.sergeych.tools.Binder serializedRole) |
Initializes role from dsl.
|
boolean |
isAllowedFor(java.util.Collection<? extends com.icodici.crypto.AbstractKey> keys,
java.util.Collection<java.lang.String> references) |
Deprecated.
use isAllowedForKeys instead.
|
boolean |
isAllowedForKeys(java.util.Set<? extends com.icodici.crypto.AbstractKey> keys) |
Deprecated.
|
boolean |
isAllowedForKeysQuantized(java.util.Set<? extends com.icodici.crypto.AbstractKey> keys) |
Check role is allowed to keys
|
boolean |
isMatchingKeyAddress(com.icodici.crypto.KeyAddress keyAddress) |
Deprecated.
the only usable check allowance method is isAllowedForKeys
|
boolean |
isMatchingRole(Role role) |
Deprecated.
the only usable check allowance method is isAllowedForKeys
|
abstract boolean |
isValid() |
Check validity of role
|
RoleLink |
linkAs(java.lang.String roleName) |
Create alias role to this one using
RoleLink . |
<T extends Role> |
resolve() |
If the role is a link or like, get the target role.
|
net.sergeych.tools.Binder |
serialize(net.sergeych.biserializer.BiSerializer s) |
|
void |
setComment(java.lang.String comment) |
Set comment of role
|
void |
setContract(Contract contract) |
Set role contract.
|
protected java.util.Set<java.lang.String> requiredAllReferences
protected java.util.Set<java.lang.String> requiredAnyReferences
protected Role()
protected Role(java.lang.String name, Contract contract)
@Deprecated protected Role(java.lang.String name)
public boolean containReference(java.lang.String name)
public void addAllRequiredReferences(java.util.Collection<Reference> references, Role.RequiredMode requiredMode)
Role.RequiredMode
).references
- is collection of added referencesrequiredMode
- is mode of combining referencespublic java.util.Set<java.lang.String> getReferences(Role.RequiredMode requiredMode)
Role.RequiredMode
).requiredMode
- is mode of combining referencespublic void addRequiredReference(Reference reference, Role.RequiredMode requiredMode)
Role.RequiredMode
).reference
- is added referencerequiredMode
- is mode of combining referencespublic void addRequiredReference(java.lang.String refName, Role.RequiredMode requiredMode)
Role.RequiredMode
).refName
- is name of reference in contractrequiredMode
- is mode of combining referencespublic java.lang.String getName()
public java.lang.String getComment()
public void setComment(java.lang.String comment)
comment
- of role@Deprecated public final boolean isAllowedForKeys(java.util.Set<? extends com.icodici.crypto.AbstractKey> keys)
keys
- is set of keyspublic boolean isAllowedForKeysQuantized(java.util.Set<? extends com.icodici.crypto.AbstractKey> keys) throws Quantiser.QuantiserException
keys
- is set of keysquantiser
- exceptionQuantiser.QuantiserException
@Deprecated public boolean isAllowedFor(java.util.Collection<? extends com.icodici.crypto.AbstractKey> keys, java.util.Collection<java.lang.String> references)
keys
- is collection of keysreferences
- this parameter is ignored@Deprecated public boolean isMatchingKeyAddress(com.icodici.crypto.KeyAddress keyAddress)
keyAddress
- address for matching with role@Deprecated public boolean isMatchingRole(Role role)
public abstract boolean isValid()
public int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- is object to be checked withpublic final boolean equalsIgnoreName(Role otherRole)
protected abstract boolean equalsIgnoreNameAndRefs(Role otherRole)
@Deprecated public boolean equalKeys(@NonNull Role otherRole)
To check that the role can be performed by some other role, use isAllowedForKeys(Set)
.
otherRole
- is Role
for checking by keys@Deprecated public boolean equalAddresses(Role otherRole)
@Deprecated public boolean equalAnonIds(Role otherRole)
@Deprecated public java.util.List<java.lang.String> getAllAddresses()
public abstract void initWithDsl(net.sergeych.tools.Binder serializedRole)
serializedRole
- is Binder
from dsl with data of rolepublic static Role fromDslBinder(java.lang.String name, net.sergeych.tools.Binder serializedRole)
name
- is role nameserializedRole
- is Binder
from dsl with data of role@Deprecated public abstract java.util.Set<com.icodici.crypto.PublicKey> getKeys()
getSimpleAddress()
if you need to display single bearer of a rolePublicKey
)@Deprecated public abstract java.util.Set<AnonymousId> getAnonymousIds()
getSimpleAddress()
if you need to display single bearer of a roleAnonymousId
)@Deprecated public abstract java.util.Set<com.icodici.crypto.KeyAddress> getKeyAddresses()
getSimpleAddress()
if you need to display single bearer of a roleKeyAddress
)@Deprecated public abstract java.util.Set<KeyRecord> getKeyRecords()
getSimpleAddress()
if you need to display single bearer of a roleKeyAddress
)public <T extends Role> @NonNull T resolve()
IllegalStateException
.T
- is type@Deprecated public KeyRecord getKeyRecord()
KeyRecord
public void setContract(Contract contract)
contract
- is role contractpublic Contract getContract()
public void deserialize(net.sergeych.tools.Binder data, net.sergeych.biserializer.BiDeserializer deserializer)
deserialize
in interface net.sergeych.biserializer.BiSerializable
public net.sergeych.tools.Binder serialize(net.sergeych.biserializer.BiSerializer s)
serialize
in interface net.sergeych.biserializer.BiSerializable
public RoleLink linkAs(java.lang.String roleName)
RoleLink
. If this role has attached to some contract, this method
also registers new role in the same contract.roleName
- new role nameRoleLink
public final @Nullable com.icodici.crypto.KeyAddress getSimpleAddress()
null
if a single address cannot be decided
for the role (like, if there is no addresses/keys discoverable or if there is more than 1 address/key). If the role is bound
to a public key rather than an address, returns its short address.public abstract void anonymize()
AnonymousId
.public java.util.Set<java.lang.String> getSpecialReferences()
Reference
that are not required but are used in voting.