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 Details

    • REVOKED_CHANGE_CONTROL_OFF

      public static final String REVOKED_CHANGE_CONTROL_OFF
      P-15: the revocation reason of the windows closed by turning change control off.
      See Also:
    • REVOKED_ITEM_DELETED

      public static final String 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

      public static final String 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

      public static final String 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

      public static Grant createFor(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.
    • getCreateNamePattern

      public String getCreateNamePattern()
      D-40: the CREATE name restriction (/regex/ or exact name), or null.
    • allowsCreateName

      public boolean allowsCreateName(String itemName)
      D-40: whether this grant's Create allows a new item called itemName (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)
      Only security.GrantService marks the notification as sent.
    • getGrantRequestId

      public String getGrantRequestId()
      The id of the request this grant came from.
    • getId

      public String getId()
    • getUser

      public String getUser()
    • getScope

      public GrantScope getScope()
    • getItemKind

      public ItemKind getItemKind()
      D-71: the kind of the scope item, copied from the request (null if it recorded none).
    • followItem

      public void followItem(String newFullName)
      D-74: the window follows its item, renamed or moved to newFullName. Only security.GrantService calls this.
    • getActions

      public List<GrantAction> getActions()
      A defensive copy; the granted actions never change after creation.
    • getGrantedAt

      public Instant getGrantedAt()
    • getExpiresAt

      public Instant getExpiresAt()
    • getRevokedAt

      public Instant getRevokedAt()
    • getRevokedBy

      public String getRevokedBy()
    • getRevokedReason

      public String getRevokedReason()
      The revocation reason of a mass revocation, or null; see REVOKED_CHANGE_CONTROL_OFF.
    • isActiveAt

      public boolean isActiveAt(Instant at)
      Whether the grant confers its permissions at the given instant: not yet expired (strictly before expiresAt — the first check at or past the expiry instant is already denied) and not revoked.
    • getCreatedItems

      public List<String> getCreatedItems()
      D-35c: the items created through this grant's Create (a copy; never null).
    • hasCreated

      public boolean hasCreated(String itemFullName)
      Whether itemFullName was created through this grant's Create (D-35c).
    • setCreatedItems

      public void setCreatedItems(List<String> items)
      Replaces the created-items list (D-35c). Only security.GrantService calls this, when an item is created, relocated or deleted.
    • getChangedItems

      public List<String> getChangedItems()
      D-58a: the items changed under this grant and not reviewed since (a copy; never null).
    • hasChanged

      public boolean hasChanged(String itemFullName)
      Whether itemFullName was changed under this grant and not reviewed since (D-58a).
    • setChangedItems

      public void setChangedItems(List<String> items)
      Replaces the changed-items list (D-58a). Only security.GrantService calls this.
    • markRevoked

      public void markRevoked(Instant revokedAt, String revokedBy, String reason)
      Marks the grant revoked by revokedBy, recording why (null: an individual revocation). Only security.GrantService may revoke a grant (Manage holders, SPEC item 8).