Class BinarySecurityContextInterceptor
java.lang.Object
ca.uhn.fhir.rest.server.interceptor.binary.BinarySecurityContextInterceptor
This security interceptor checks any Binary resources that are being exposed to
a user and can forbid the user from accessing them based on the security context
found in
Binary.securityContext.identifier
.
This interceptor is intended to be subclassed. The default implementation if it
is not subclassed will reject any access to a Binary resource unless the
request is a system request (using SystemRequestDetails
or the Binary
resource has no value in Binary.securityContext.identifier
.
Override securityContextIdentifierAllowed(String, String, RequestDetails)
in order
to allow the user to access specific context values.
- Since:
- 6.8.0
-
Constructor Summary
ConstructorDescriptionBinarySecurityContextInterceptor
(ca.uhn.fhir.context.FhirContext theFhirContext) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyAccessControl
(org.hl7.fhir.instance.model.api.IBaseBinary theBinary, RequestDetails theRequestDetails) This method applies security to a given Binary resource.protected void
applyAccessControl
(org.hl7.fhir.instance.model.api.IBaseBinary theBinary, String theSecurityContextSystem, String theSecurityContextValue, RequestDetails theRequestDetails) This method applies access controls to a Binary resource containing the given identifier system and value in the Binary.securityContext element.protected void
handleForbidden
(org.hl7.fhir.instance.model.api.IBaseBinary theBinary) Handles a non-permitted operation.void
preShowResources
(IPreResourceShowDetails theShowDetails, RequestDetails theRequestDetails) Interceptor hook method.void
preShowResources
(org.hl7.fhir.instance.model.api.IBaseResource theOldValue, org.hl7.fhir.instance.model.api.IBaseResource theNewValue, RequestDetails theRequestDetails) Interceptor hook method.protected boolean
securityContextIdentifierAllowed
(String theSecurityContextSystem, String theSecurityContextValue, RequestDetails theRequestDetails) Determines whether the current user has access to the given security context identifier.
-
Constructor Details
-
BinarySecurityContextInterceptor
Constructor- Parameters:
theFhirContext
- The FHIR context
-
-
Method Details
-
preShowResources
public void preShowResources(IPreResourceShowDetails theShowDetails, RequestDetails theRequestDetails) Interceptor hook method. Do not call this method directly. -
preShowResources
public void preShowResources(org.hl7.fhir.instance.model.api.IBaseResource theOldValue, org.hl7.fhir.instance.model.api.IBaseResource theNewValue, RequestDetails theRequestDetails) Interceptor hook method. Do not call this method directly. -
applyAccessControl
protected void applyAccessControl(org.hl7.fhir.instance.model.api.IBaseBinary theBinary, RequestDetails theRequestDetails) This method applies security to a given Binary resource. It is not typically overridden but you could override it if you wanted to completely replace the security logic in this interceptor.- Parameters:
theBinary
- The Binary resource being checkedtheRequestDetails
- The request details associated with this request
-
applyAccessControl
protected void applyAccessControl(org.hl7.fhir.instance.model.api.IBaseBinary theBinary, String theSecurityContextSystem, String theSecurityContextValue, RequestDetails theRequestDetails) This method applies access controls to a Binary resource containing the given identifier system and value in the Binary.securityContext element.- Parameters:
theBinary
- The binary resourcetheSecurityContextSystem
- The identifier systemtheSecurityContextValue
- The identifier valuetheRequestDetails
- The request details
-
handleForbidden
Handles a non-permitted operation. This method throws aForbiddenOperationException
but you could override it to change that behaviour. -
securityContextIdentifierAllowed
protected boolean securityContextIdentifierAllowed(String theSecurityContextSystem, String theSecurityContextValue, RequestDetails theRequestDetails) Determines whether the current user has access to the given security context identifier. This method is intended to be overridden, the default implementation simply always returnsfalse
.- Parameters:
theSecurityContextSystem
- TheBinary.securityContext.identifier.system
valuetheSecurityContextValue
- TheBinary.securityContext.identifier.value
valuetheRequestDetails
- The request details associated with this request- Returns:
- Returns
true
if the request should be permitted, andfalse
otherwise
-