Class Grant
java.lang.Object
io.jenkins.plugins.batchcontrol.model.Grant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public final class Grant
extends Object
An approved temporary permission (SPEC item 8, section 3): the result of an approved
GrantRequest. Persisted as XStream XML at grants/<id>.xml.
The grant id equals the id of the grant request it came from (they are 1:1), so change
records that carry a grantId resolve directly to the request detail screen.
Expiry is never timer-driven: activity is always judged by isActiveAt(Instant)
at check time (SPEC item 8, D-08). Timestamps are persisted as epoch milliseconds because the
Jenkins XStream class filter does not allow java.time.Instant.
Only security.GrantService may set the revocation fields.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringP-15: the revocation reason of the windows closed by turning change control off.static final StringD-74: the revocation reason of a window whose item was deleted (or no longer exists).static final StringS-39-02: the revocation reason of a window that could not follow its renamed or moved item for certain (its file could not be updated, another item had already taken the old name again, or another item has just taken the name the window gives).static final StringS-39-03: the revocation reason of a window ended at startup because the change records could not all be read, so it could not be shown not to have ended before. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsCreateName(String itemName) D-40: whether this grant's Create allows a new item calleditemName(the item name, not the full name).static GrantcreateFor(GrantRequest request, Instant grantedAt) Creates the grant for an approved request: the grantee is the requester, the window is[grantedAt, grantedAt + durationMinutes), and the id equals the request id.voidfollowItem(String newFullName) D-74: the window follows its item, renamed or moved tonewFullName.A defensive copy; the granted actions never change after creation.D-58a: the items changed under this grant and not reviewed since (a copy; nevernull).D-35c: the items created through this grant's Create (a copy; nevernull).D-40: the CREATE name restriction (/regex/or exact name), ornull.The id of the request this grant came from.getId()D-71: the kind of the scope item, copied from the request (nullif it recorded none).The revocation reason of a mass revocation, ornull; seeREVOKED_CHANGE_CONTROL_OFF.getScope()getUser()booleanhasChanged(String itemFullName) WhetheritemFullNamewas changed under this grant and not reviewed since (D-58a).booleanhasCreated(String itemFullName) WhetheritemFullNamewas created through this grant's Create (D-35c).booleanisActiveAt(Instant at) Whether the grant confers its permissions at the given instant: not yet expired (strictly beforeexpiresAt— the first check at or past the expiry instant is already denied) and not revoked.booleanWhether the D-36 GRANT_EXPIRING notification was already sent.voidmarkRevoked(Instant revokedAt, String revokedBy, String reason) Marks the grant revoked byrevokedBy, recording why (null: an individual revocation).voidsetChangedItems(List<String> items) Replaces the changed-items list (D-58a).voidsetCreatedItems(List<String> items) Replaces the created-items list (D-35c).voidsetExpiringNotified(boolean expiringNotified) Onlysecurity.GrantServicemarks the notification as sent.
-
Field Details
-
REVOKED_CHANGE_CONTROL_OFF
P-15: the revocation reason of the windows closed by turning change control off.- See Also:
-
REVOKED_ITEM_DELETED
D-74: the revocation reason of a window whose item was deleted (or no longer exists).- See Also:
-
REVOKED_ITEM_NOT_FOLLOWED
S-39-02: the revocation reason of a window that could not follow its renamed or moved item for certain (its file could not be updated, another item had already taken the old name again, or another item has just taken the name the window gives).- See Also:
-
REVOKED_UNCONFIRMED
S-39-03: the revocation reason of a window ended at startup because the change records could not all be read, so it could not be shown not to have ended before.- See Also:
-
-
Method Details
-
createFor
Creates the grant for an approved request: the grantee is the requester, the window is[grantedAt, grantedAt + durationMinutes), and the id equals the request id. -
getCreateNamePattern
D-40: the CREATE name restriction (/regex/or exact name), ornull. -
allowsCreateName
D-40: whether this grant's Create allows a new item calleditemName(the item name, not the full name). Always true without a restriction. -
isExpiringNotified
public boolean isExpiringNotified()Whether the D-36 GRANT_EXPIRING notification was already sent. -
setExpiringNotified
public void setExpiringNotified(boolean expiringNotified) Onlysecurity.GrantServicemarks the notification as sent. -
getGrantRequestId
The id of the request this grant came from. -
getId
-
getUser
-
getScope
-
getItemKind
D-71: the kind of the scope item, copied from the request (nullif it recorded none). -
followItem
D-74: the window follows its item, renamed or moved tonewFullName. Onlysecurity.GrantServicecalls this. -
getActions
A defensive copy; the granted actions never change after creation. -
getGrantedAt
-
getExpiresAt
-
getRevokedAt
-
getRevokedBy
-
getRevokedReason
The revocation reason of a mass revocation, ornull; seeREVOKED_CHANGE_CONTROL_OFF. -
isActiveAt
Whether the grant confers its permissions at the given instant: not yet expired (strictly beforeexpiresAt— the first check at or past the expiry instant is already denied) and not revoked. -
getCreatedItems
D-35c: the items created through this grant's Create (a copy; nevernull). -
hasCreated
WhetheritemFullNamewas created through this grant's Create (D-35c). -
setCreatedItems
Replaces the created-items list (D-35c). Onlysecurity.GrantServicecalls this, when an item is created, relocated or deleted. -
getChangedItems
D-58a: the items changed under this grant and not reviewed since (a copy; nevernull). -
hasChanged
WhetheritemFullNamewas changed under this grant and not reviewed since (D-58a). -
setChangedItems
Replaces the changed-items list (D-58a). Onlysecurity.GrantServicecalls this. -
markRevoked
Marks the grant revoked byrevokedBy, recording why (null: an individual revocation). Onlysecurity.GrantServicemay revoke a grant (Manage holders, SPEC item 8).
-