public abstract class Cap extends Mod implements ObjectCompletionWatcher
Constructor and Description |
---|
Cap(JSONObject desc)
JSON-driven constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
delete(User from)
Handle a 'delete' message.
|
protected void |
encodeDefaultParameters(JSONLiteral lit)
Encode the basic capability parameters as part of encoding this
capability mod.
|
void |
ensureValid(User from)
Guard function to guarantee that an operation being attempted by a user
is being applied to a capability that is actually available to that
user.
|
boolean |
isExpired()
Test if this capability has expired.
|
void |
objectIsComplete()
Mark the item as visible only to its holder.
|
void |
setlabel(User from,
String label)
Handle a 'setlabel' message.
|
void |
spawn(User from,
OptString dest,
OptBoolean transferrable,
OptBoolean deleteable,
OptInteger duration,
OptInteger expiration)
Handle a 'spawn' message.
|
void |
transfer(User from,
String destRef)
Handle a 'transfer' message.
|
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
public Cap(JSONObject desc) throws JSONDecodingException
System.currentTimeMillis()
.desc
- The parsed JSON object describing this capability mod.JSONDecodingException
public final void objectIsComplete()
Application code should not call this method.
objectIsComplete
in interface ObjectCompletionWatcher
protected final void encodeDefaultParameters(JSONLiteral lit)
lit
- The JSONLiteral into which this capability mod is being
encoded.public final void ensureValid(User from) throws MessageHandlerException
MessageHandlerException
.MessageHandlerException
- if the test fails.public final boolean isExpired()
@JSONMethod public final void delete(User from) throws MessageHandlerException
This request will be rejected if the capability is marked as undeletable and is not expired.
recv: { to:REF, op:"delete" }
send: { to:REF, op:"delete" }
from
- The user who sent the message.MessageHandlerException
@JSONMethod(value="label") public void setlabel(User from, String label) throws MessageHandlerException
recv: { to:REF, op:"setlabel",
label:STR }
send: no reply is sent.
from
- The user who sent the message.label
- The new label string.MessageHandlerException
@JSONMethod(value="dest") public final void transfer(User from, String destRef) throws MessageHandlerException
This request will be rejected if the capability is marked as untransferrable. Yes, this is unenforceable due to the possibility of proxying, but marketing solipsism must be served.
recv: { to:REF, op:"transfer", dest:DESTREF }
send: { to:REF, op:"delete" }
send: { to:DESTREF, op:"make", ... }
from
- The user who sent the message.destRef
- Reference to user or context that is to receive the
capability.MessageHandlerException
@JSONMethod(value={"dest","transferrable","deletable","duration","expiration"}) public void spawn(User from, OptString dest, OptBoolean transferrable, OptBoolean deleteable, OptInteger duration, OptInteger expiration) throws MessageHandlerException
This method will reject, as an illegal rights amplification, any attempt to spawn a capability that is undeletable when the base capability is deletable, transferrable when the base capability is untransferrable, or which has a later expiration time than the base capability.
If 'dest' designates a different holder, the operation will also be
regarded as a transfer and subjected to all the same checks as a call to
transfer()
.
recv: { to:REF, op:"spawn", dest:optDESTREF,
transferrable:optBOOL,
duration:optLONG,
expiration:optLONG }
send: { to:DESTREF, op:"make", ... }
from
- The user who sent the message.dest
- Reference to container into which the new capability is to
be placed. If omitted, defaults to the sending user. If this
capability is non-transferrable, must refer to the sending user or a
container contained by the sending user.transferrable
- Flag indicating whether the new capability is to
be transferrable. If omitted, defaults to the same value as this
capability. It is not permitted to set this parameter to
true if this capability is not itself transferrable.deleteable
- Flag indicating whether the new capability is to be
deleteable. If omitted, defaults to true. It is not permitted to
set this parameter to false if this capability is itself deletable.duration
- Expiration time of the new capability, expressed as an
offset (in milliseconds) from the present. A value of 0 (the
default) indicates that the capability is permanent.expiration
- Expiration time of the new capability, expressed as
an absolute system time (in milliseconds).MessageHandlerException
Copyright © 2017. All rights reserved.