public class Darc extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
RuleEvolve |
static String |
RuleEvolveUnrestricted |
static String |
RuleSignature |
static String |
RuleSpawn |
| Constructor and Description |
|---|
Darc(byte[] buf)
Convenience constructure
|
Darc(DarcProto.Darc proto)
Convenience constructor
|
Darc(List<Identity> owners,
List<Identity> signers,
byte[] desc)
Convenience constructor
|
Darc(Rules rules,
byte[] desc)
The Darc constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addIdentity(String action,
Identity id,
String link)
Add a rule to the Darc.
|
boolean |
equals(Object other)
Compares this darc with another darc.
|
List<String> |
getActions() |
DarcId |
getBaseId()
Gets the base-ID of the darc, i.e.
|
byte[] |
getExpression(String action)
Returns a copy of the expression stored in the rule.
|
DarcId |
getId()
Calculate the getId of the darc by calculating the sha-256 of the invariant
parts which excludes the delegation-signature.
|
Identity |
getIdentity() |
DarcId |
getPrevID() |
long |
getVersion() |
static Rules |
initRules(List<Identity> owners,
List<Identity> signers)
This is a convenience function that initialise a set of rules with the default actions "_evolve" and "_sign".
|
Darc |
partialCopy()
Returns a partial copy of the Darc where the rules and the description stay the same but the other attributes are
uninitialised.
|
byte[] |
removeAction(String action)
Removes the given action.
|
void |
setBaseId(DarcId id) |
void |
setPrevId(Darc d) |
void |
setPrevId(DarcId id) |
void |
setRule(String action,
byte[] expression)
Sets a rule to be the action/expression pair.
|
void |
setVersion(long version)
Setter for the version number.
|
DarcProto.Darc |
toProto()
Creates the protobuf representation of the darc.
|
String |
toString() |
public static final String RuleSignature
public static final String RuleSpawn
public static final String RuleEvolve
public static final String RuleEvolveUnrestricted
public Darc(Rules rules, byte[] desc)
rules - The initial set of rules, consider using initRules to create them.desc - The description.public Darc(List<Identity> owners, List<Identity> signers, byte[] desc)
owners - a list of owners that are allowed to evolve the darcsigners - a list of signers on behalf of that darcdesc - free form description of the darcpublic Darc(DarcProto.Darc proto) throws CothorityCryptoException
proto - proto representation of the darcCothorityCryptoException - if there's a problem with the cryptographypublic Darc(byte[] buf)
throws com.google.protobuf.InvalidProtocolBufferException,
CothorityCryptoException
buf - byte representation of protobuf representationcom.google.protobuf.InvalidProtocolBufferException - if the Darc cannot be parsedCothorityCryptoException - if there's a problem with the cryptographypublic void setRule(String action, byte[] expression)
action - the actionexpression - the expressionpublic void addIdentity(String action, Identity id, String link) throws CothorityCryptoException
action - is the action in the rule.id - is the identity that is authorized for the actionlink - is how the identity should be combined with the existing identities, if they existCothorityCryptoException - if something goes wrongpublic byte[] getExpression(String action)
action - - which expression to returnpublic byte[] removeAction(String action)
action - if that action is in the set of rules, removes it.public DarcProto.Darc toProto()
public DarcId getId()
public void setPrevId(DarcId id)
id - the id of the previous darc.public void setBaseId(DarcId id)
id - the base-id to setpublic void setPrevId(Darc d)
d - the previous darcpublic DarcId getBaseId()
public DarcId getPrevID()
public long getVersion()
public Darc partialCopy()
public Identity getIdentity()
public static Rules initRules(List<Identity> owners, List<Identity> signers)
owners - A list of owners.signers - A list of signers.public boolean equals(Object other)
public void setVersion(long version)
Copyright © 2019. All rights reserved.