Class PolicyEnforcementPoint.QueryParamSpec
java.lang.Object
org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint.QueryParamSpec
- Enclosing class:
- PolicyEnforcementPoint
Specification for query parameter authorization and validation.
A privileged parameter declares the values that expand the caller's authority or scope
and the roles entitled to send them; PolicyEnforcementPoint.enforcePolicy(org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint.EndpointPolicySpec, java.util.UUID, java.util.UUID) rejects
such a value from any other role with 403 Forbidden, before value validation and
before any path that would ignore the parameter.
-
Constructor Summary
ConstructorsConstructorDescriptionQueryParamSpec(String name, String defaultValue, boolean requiresPrivilege, Set<String> restrictedToRoles) Creates a new policy specification for a non-privileged parameter or for a boolean parameter whosetruevalue is privilege-expanding.QueryParamSpec(String name, String defaultValue, Set<String> privilegedValues, Set<String> restrictedToRoles) Creates a new policy specification for an enumerated parameter whose listed values are privilege-expanding. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default value of the query parameter.getName()Returns the name of the query parameter.Returns the set of roles permitted to use this parameter.booleanisPrivilegeExpanding(String value) Returns whether the given raw value expands the caller's authority or scope.booleanReturns whether this parameter has privilege-expanding values.privilegedUnlessDefault(String name, String defaultValue, Set<String> restrictedToRoles) Creates a new policy specification for a parameter whose every value but the default one is privilege-expanding, for values that cannot be listed (e.g. a Context UUID).
-
Constructor Details
-
QueryParamSpec
public QueryParamSpec(String name, String defaultValue, boolean requiresPrivilege, Set<String> restrictedToRoles) Creates a new policy specification for a non-privileged parameter or for a boolean parameter whosetruevalue is privilege-expanding.- Parameters:
name- the name of the query parameterdefaultValue- the default value of the parameterrequiresPrivilege- whether the valuetruerequires one ofrestrictedToRolesrestrictedToRoles- the restricted roles, or null/empty if none
-
QueryParamSpec
public QueryParamSpec(String name, String defaultValue, Set<String> privilegedValues, Set<String> restrictedToRoles) Creates a new policy specification for an enumerated parameter whose listed values are privilege-expanding. Enumerated wire values are matched exactly.- Parameters:
name- the name of the query parameterdefaultValue- the default value of the parameterprivilegedValues- the values that require one ofrestrictedToRolesrestrictedToRoles- the restricted roles
-
-
Method Details
-
privilegedUnlessDefault
public static PolicyEnforcementPoint.QueryParamSpec privilegedUnlessDefault(String name, String defaultValue, Set<String> restrictedToRoles) Creates a new policy specification for a parameter whose every value but the default one is privilege-expanding, for values that cannot be listed (e.g. a Context UUID).- Parameters:
name- the name of the query parameterdefaultValue- the default value, the only one any role may sendrestrictedToRoles- the roles that may send any other value- Returns:
- the specification
-
isPrivilegeExpanding
Returns whether the given raw value expands the caller's authority or scope.- Parameters:
value- the raw query parameter value- Returns:
trueif the value is one of the privileged values
-
getName
Returns the name of the query parameter.- Returns:
- the parameter name
-
getDefaultValue
Returns the default value of the query parameter.- Returns:
- the default value
-
isRequiresPrivilege
public boolean isRequiresPrivilege()Returns whether this parameter has privilege-expanding values.- Returns:
- true if privileged, false otherwise
-
getRestrictedToRoles
Returns the set of roles permitted to use this parameter.- Returns:
- the allowed roles
-