new AccessPolicy(rulesopt)
Create an AccessPolicy instance.
Parameters:
| Name |
Type |
Attributes |
Description |
rules |
Array.<(AccessRule|object)>
|
<optional>
|
Access rules to normalize. |
- Source:
Members
The DataONEObject that will be saved with this AccessPolicy
Type:
- Source:
Methods
Append one access rule to the policy.
Parameters:
| Name |
Type |
Description |
rule |
AccessRule
|
object
|
Access rule to append. |
- Source:
Returns:
The same policy instance.
-
Type
-
AccessPolicy
Remove all access rules.
- Source:
Returns:
The same policy instance.
-
Type
-
AccessPolicy
copyAccessPolicy(otherAccessPolicy)
Copies all the AccessRules from the given AccessPolicy and replaces this AccessPolicy
Parameters:
| Name |
Type |
Description |
otherAccessPolicy |
AccessPolicy
|
Policy to copy |
- Since:
- Source:
Fires:
- Backbone.Collection#event:reset
createDefaultPolicy()
Creates AccessRule member models from the `defaultAccessPolicy`
setting in the AppModel.
- Source:
getEmptyRules() → {Array.<AccessRule>}
- Source:
Returns:
Rules missing a subject or permissions.
-
Type
-
Array.<AccessRule>
getNonEmptyRules() → {Array.<AccessRule>}
- Source:
Returns:
Rules with a subject and permissions.
-
Type
-
Array.<AccessRule>
getRules() → {Array.<AccessRule>}
- Source:
Returns:
All access rules in the policy.
-
Type
-
Array.<AccessRule>
getSubjectInfo()
Gets the subject info for all of the subjects in this access policy.
Sets the subject info on each corresponding model.
- Source:
hasOwner() → {boolean}
Checks if there is at least one AccessRule with changePermission permission
in this AccessPolicy.
- Source:
Returns:
Whether the policy contains an owner rule
-
Type
-
boolean
isAuthorized(action) → {boolean}
Checks if the current user is authorized to perform the given action
based on the current access rules in this collection
Parameters:
| Name |
Type |
Description |
action |
string
|
The action to check authorization for. Can
be either `read`, `write`, or `changePermission` |
- Source:
Returns:
Whether the user can perform this action
-
Type
-
boolean
isAuthorized(actionopt, subjectopt) → {boolean}
Check whether this policy grants the requested action to a subject.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
action |
"read"
|
"write"
|
"changePermission"
|
<optional>
|
write
|
Permission to check |
subject |
string
|
Array.<string>
|
null
|
<optional>
|
null
|
Subject or candidate subjects
Defaults to `public` when omitted. |
- Source:
Returns:
`true` when any access rule authorizes the request
-
Type
-
boolean
Checks if the user is authorized to update the system metadata.
Updates to system metadata will fail if the user doesn't have changePermission permission,
unless the user is performing an update() at the same time and has
`write` permission.
- Since:
- Source:
Returns:
Whether the user may update the system metadata
-
Type
-
boolean
isPublic() → {boolean}
Returns true if this access policy specifies that it is accessible to
the public in any way
- Source:
Returns:
Whether the policy grants public access
-
Type
-
boolean
isPublic() → {boolean}
Check whether this policy grants public read access.
- Source:
Returns:
`true` when public has read access directly or through
the DataONE permission hierarchy.
-
Type
-
boolean
makePrivate()
Removes all access rules for the public subject
- Source:
makePublic()
Removes any AccessRule that denies public read and adds an AccessRule
that allows public read
- Source:
Normalize the policy in place.
- Source:
Returns:
The same policy instance.
-
Type
-
AccessPolicy
parse(accessPolicyXML)
Parses the given access policy XML and creates AccessRule models for
each rule in the access policy XML. Adds these models to this collection.
Parameters:
| Name |
Type |
Description |
accessPolicyXML |
Element
|
The `` XML element that
contains the access rules |
- Source:
push(…rules) → {number}
Append one or more access rules to the policy.
Parameters:
| Name |
Type |
Attributes |
Description |
rules |
AccessRule
|
object
|
<repeatable>
|
Access rules to append. |
- Source:
Returns:
The new array length.
-
Type
-
number
Remove one access rule.
Parameters:
| Name |
Type |
Description |
index |
number
|
Rule index to remove. |
- Source:
Throws:
-
When index is invalid or does not identify a rule
-
-
Type
-
Error
Returns:
The same policy instance.
-
Type
-
AccessPolicy
removeAccessRule(accessRule)
Remove the given AccessRule from this AccessPolicy
Parameters:
| Name |
Type |
Description |
accessRule |
AccessRule
|
The AccessRule model to remove |
- Source:
removeEmptyRules()
Remove rules missing a subject or permissions.
- Source:
replace(index, rule) → {AccessPolicy}
Replace one access rule.
Parameters:
| Name |
Type |
Description |
index |
number
|
Rule index to replace. |
rule |
AccessRule
|
object
|
Replacement rule. |
- Source:
Throws:
-
When index is invalid or does not identify a rule
-
-
Type
-
Error
Returns:
The same policy instance.
-
Type
-
AccessPolicy
serialize() → {object}
Creates an access policy XML from the values set on the member
AccessRule models.
- Source:
Returns:
A XML object of the access policy or null if empty
-
Type
-
object
toElement(doc) → {Element|null}
Serialize the access policy to XML.
Parameters:
| Name |
Type |
Description |
doc |
XMLDocument
|
XML document used to create elements. |
- Source:
Returns:
Serialized XML element, or `null` when empty.
-
Type
-
Element
|
null
toJSON() → {Array.<object>}
Return a JSON-serializable representation of the access policy.
- Source:
Returns:
Plain access rule data.
-
Type
-
Array.<object>
validate(pathopt) → {Array.<object>}
Validate each access rule in the policy.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
path |
string
|
<optional>
|
accessPolicy
|
Base path used in validation errors. Defaults to
`accessPolicy`. |
- Source:
Returns:
Validation errors for invalid rules.
-
Type
-
Array.<object>
fromElement(element) → {AccessPolicy}
Create an AccessPolicy from an `accessPolicy` XML element.
Parameters:
| Name |
Type |
Description |
element |
Element
|
XML element to parse. |
- Source:
Returns:
Parsed access policy instance.
-
Type
-
AccessPolicy
Coerce unknown input into an AccessPolicy instance.
Parameters:
- Source:
Returns:
Normalized access policy instance.
-
Type
-
AccessPolicy
parse(element, parseWarningsopt, pathopt) → {AccessPolicy}
Parse an `accessPolicy` XML element while salvaging valid rules.
Unknown child nodes and ordering issues are ignored silently.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
element |
Element
|
null
|
|
|
XML element to parse. |
parseWarnings |
Array.<object>
|
<optional>
|
|
Lossy parse warnings. |
path |
string
|
<optional>
|
accessPolicy
|
Field path used in warnings and validation. |
- Source:
Returns:
Parsed access policy instance.
-
Type
-
AccessPolicy