Package com.osohq.oso
Class Oso
java.lang.Object
com.osohq.oso.Polar
com.osohq.oso.Oso
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Ensure that `actor` is allowed to perform `action` on `resource`.authorizedActions
(Object actor, Object resource) authorizedActions
(Object actor, Object resource, boolean allowWildcard) Determine the actions `actor` is allowed to take on `resource`.authorizedFields
(Object actor, Object action, Object resource) authorizedFields
(Object actor, Object action, Object resource, boolean allowWildcard) Determine the fields of `resource` on which `actor` is allowed to perform `action`.void
authorizeField
(Object actor, Object action, Object resource, Object field) Ensure that `actor` is allowed to perform `action` on a given `resource`'s `field`.void
authorizeRequest
(Object actor, Object request) Ensure that `actor` is allowed to send `request` to the server.getAllowedActions
(Object actor, Object resource) Return the allowed actions for the given actor and resource, if any.getAllowedActions
(Object actor, Object resource, boolean allowWildcard) Deprecated.Use `authorizedActions` instead.boolean
Submit an `allow` query to the Polar knowledge base.static void
void
setReadAction
(Object readAction) Override the "read" action, which is used to differentiate between a `NotFoundException` and a `ForbiddenException` on authorization failures.Methods inherited from class com.osohq.oso.Polar
clearRules, loadFile, loadFiles, loadFilesFromResources, loadStr, loadStr, query, query, query, query, query, query, query, queryRule, queryRule, queryRuleOnce, registerClass, registerClass, registerConstant, repl, repl
-
Constructor Details
-
Method Details
-
main
- Throws:
Exceptions.OsoException
IOException
-
setReadAction
Override the "read" action, which is used to differentiate between a `NotFoundException` and a `ForbiddenException` on authorization failures. -
isAllowed
public boolean isAllowed(Object actor, Object action, Object resource) throws Exceptions.OsoException Submit an `allow` query to the Polar knowledge base.Oso oso = new Oso(); o.loadStr("allow(\"guest\", \"get\", \"widget\");"); assert o.isAllowed("guest", "get", "widget");
- Parameters:
actor
- the actor performing the requestaction
- the action the actor is attempting to performresource
- the resource being accessed- Returns:
- boolean
- Throws:
Exceptions.OsoException
-
getAllowedActions
public HashSet<Object> getAllowedActions(Object actor, Object resource) throws Exceptions.OsoException Return the allowed actions for the given actor and resource, if any.Oso oso = new Oso(); o.loadStr("allow(\"guest\", \"get\", \"widget\");"); HashSet actions = o.getAllowedActions("guest", "widget"); assert actions.contains("get");
- Parameters:
actor
- the actor performing the requestresource
- the resource being accessed- Returns:
- HashSet
-