Class StaticActionAuthorizationService<U>
java.lang.Object
com.svenruppert.jsentinel.action.StaticActionAuthorizationService<U>
- Type Parameters:
U- subject type
- All Implemented Interfaces:
ActionAuthorizationService<U>
public final class StaticActionAuthorizationService<U>
extends Object
implements ActionAuthorizationService<U>
Default
ActionAuthorizationService that checks an
ActionPermission against the subject's permission set obtained
via the configured AuthorizationService.
The action's name is matched
case-sensitively against the value of
each permission returned by
AuthorizationService.permissionsFor(Object), so applications
can keep a single string vocabulary across both APIs while opting
into the typed action layer.
On requireAllowed denial, this implementation emits an
ActionDenied audit event before throwing.
-
Constructor Summary
ConstructorsConstructorDescriptionStaticActionAuthorizationService(AuthorizationService<U> authorizationService, JSentinelAuditService auditService) StaticActionAuthorizationService(Class<U> subjectType) Builds a service that resolves theAuthorizationServiceviaJSentinelServiceResolver. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisAllowed(U subject, ActionPermission permission) voidrequireAllowed(U subject, ActionPermission permission) ThrowsAccessDeniedExceptionif the subject is not allowed.
-
Constructor Details
-
StaticActionAuthorizationService
Builds a service that resolves theAuthorizationServiceviaJSentinelServiceResolver. Audit events are routed toJSentinelServiceResolver.securityAuditService()at check time.- Parameters:
subjectType- compile-time helper — kept on the constructor so the generic parameter is inferable; not stored
-
StaticActionAuthorizationService
public StaticActionAuthorizationService(AuthorizationService<U> authorizationService, JSentinelAuditService auditService) - Parameters:
authorizationService- the application's authorization serviceauditService- audit sink, ornullto resolve fromJSentinelServiceResolverat each check
-
-
Method Details
-
isAllowed
- Specified by:
isAllowedin interfaceActionAuthorizationService<U>- Parameters:
subject- the calling subject (may benull)permission- the action permission to evaluate- Returns:
trueifsubjectmay executepermission
-
requireAllowed
Description copied from interface:ActionAuthorizationServiceThrowsAccessDeniedExceptionif the subject is not allowed. Implementations should additionally publish anActionDeniedaudit event in this case.- Specified by:
requireAllowedin interfaceActionAuthorizationService<U>- Parameters:
subject- the calling subject (may benull)permission- the action permission to enforce
-