Class SecurityPolicyEnforcer
java.lang.Object
net.solarnetwork.central.security.SecurityPolicyEnforcer
- All Implemented Interfaces:
InvocationHandler
Support for enforcing a
SecurityPolicy on domain objects.- Since:
- 1.12
-
Constructor Summary
ConstructorsConstructorDescriptionSecurityPolicyEnforcer(SecurityPolicy policy, Object principal, Object delegate) Construct a new enforcer.SecurityPolicyEnforcer(SecurityPolicy policy, Object principal, Object delegate, org.springframework.util.PathMatcher pathMatcher) Construct a new enforcer with patch matching support.SecurityPolicyEnforcer(SecurityPolicy policy, Object principal, Object delegate, org.springframework.util.PathMatcher pathMatcher, SecurityPolicyMetadataType metadataType) Construct a new enforcer with patch matching support. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TWrap an object with aSecurityPolicyEnforcer, enforcing policy properties.voidverify()Verify the security policy on all supported properties immediately.net.solarnetwork.domain.datum.GeneralDatumMetadataverifyMetadata(net.solarnetwork.domain.datum.GeneralDatumMetadata metadata) Verify an arbitrary metadata instance against the configured policy.Long[]verifyNodeIds(Long[] nodeIds) Verify an arbitrary list of node IDs against the configured policy.String[]verifySourceIds(String[] sourceIds) Verify an arbitrary list of source IDs against the configured policy.
-
Constructor Details
-
SecurityPolicyEnforcer
Construct a new enforcer.- Parameters:
policy- The policy to enforce.principal- The active principal.delegate- The domain object to enforce the policy on.
-
SecurityPolicyEnforcer
public SecurityPolicyEnforcer(SecurityPolicy policy, Object principal, Object delegate, org.springframework.util.PathMatcher pathMatcher) Construct a new enforcer with patch matching support.- Parameters:
policy- The policy to enforce.principal- The active principal.delegate- The domain object to enforce the policy on.pathMatcher- The path matcher to use.- Since:
- 1.1
-
SecurityPolicyEnforcer
public SecurityPolicyEnforcer(SecurityPolicy policy, Object principal, Object delegate, org.springframework.util.PathMatcher pathMatcher, SecurityPolicyMetadataType metadataType) Construct a new enforcer with patch matching support.- Parameters:
policy- The policy to enforce.principal- The active principal.delegate- The domain object to enforce the policy on.pathMatcher- The path matcher to use.metadataType- The type of metadata associated withdelegate, ornull.- Since:
- 1.2
-
-
Method Details
-
createSecurityPolicyProxy
Wrap an object with aSecurityPolicyEnforcer, enforcing policy properties. This will return a proxy object that implements all interfaces on the provided enforder'sdelegateproperty.- Type Parameters:
T- the return object type- Parameters:
enforcer- The policy enforcer.- Returns:
- A new wrapped object.
-
verify
public void verify()Verify the security policy on all supported properties immediately.- Throws:
AuthorizationException- if any policy fails
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
verifyNodeIds
Verify an arbitrary list of node IDs against the configured policy.- Parameters:
nodeIds- The node IDs to verify.- Returns:
- The allowed node IDs.
- Throws:
AuthorizationException- if no node IDs are allowed
-
verifySourceIds
Verify an arbitrary list of source IDs against the configured policy.- Parameters:
sourceIds- The source IDs to verify.- Returns:
- The allowed source IDs.
- Throws:
AuthorizationException- if no source IDs are allowed
-
verifyMetadata
public net.solarnetwork.domain.datum.GeneralDatumMetadata verifyMetadata(net.solarnetwork.domain.datum.GeneralDatumMetadata metadata) Verify an arbitrary metadata instance against the configured policy.- Parameters:
metadata- The metadata to verify.- Returns:
- The allowed metadata.
- Throws:
AuthorizationException- if no metadata access is allowed
-
getDelgate
-