Learn R Programming

dataone (version 2.2.2)

isAuthorized: Check if an action is authorized for the specified identifier

Description

Test if the user identified by the provided token has authorization for operation on the specified object.

Usage

isAuthorized(x, ...)

# S4 method for D1Node isAuthorized(x, id, action)

Arguments

x

The node to send the request to. This is either a "CNode" or "MNode" instance.

...

(Not yet used)

id

The DataONE identifier (pid or sid) to check access for.

action

The DataONE action to check, possible values: "read", "write", "changePermission"

Value

a logical, TRUE if the action is authorized, false if not.

Details

The identifier parameter may be either a DataONE persistent identifier (pid) or series identifier (sid).

See Also

CNode class description.

Examples

Run this code
# NOT RUN {
# Send an authorization check to the D1 production CN.
cn <- CNode("PROD")
pid <- "doi:10.6073/pasta/7fcb8fea57843fae65f63094472f502d"
canRead <- isAuthorized(cn, pid, "read")
canWrite <- isAuthorized(cn, pid, "write")
canChange <- isAuthorized(cn, pid, "changePermission")

# Now send a check to a member node.
mn <- getMNode(cn, "urn:node:KNB")
pid <- "doi:10.6085/AA/pisco_recruitment.149.1"
canRead <- isAuthorized(mn, pid, "read")
canWrite <- isAuthorized(mn, pid, "write")
canChange <- isAuthorized(mn, pid, "changePermission")
# }

Run the code above in your browser using DataLab