Class RoleWorkflowConditionProvider

java.lang.Object
org.keycloak.models.workflow.conditions.RoleWorkflowConditionProvider
All Implemented Interfaces:
WorkflowConditionProvider, Provider

public class RoleWorkflowConditionProvider extends Object implements WorkflowConditionProvider
  • Constructor Details

    • RoleWorkflowConditionProvider

      public RoleWorkflowConditionProvider(KeycloakSession session, String expectedRole)
  • Method Details

    • getSupportedResourceType

      public ResourceType getSupportedResourceType()
      Description copied from interface: WorkflowConditionProvider
      Returns the ResourceType} that this condition is capable of evaluating.
      Specified by:
      getSupportedResourceType in interface WorkflowConditionProvider
      Returns:
      the supported ResourceType for this condition implementation
    • evaluate

      public boolean evaluate(WorkflowExecutionContext context)
      Description copied from interface: WorkflowConditionProvider
      Evaluates the condition against the given workflow execution context.

      Implementations should inspect the provided context and return true when the condition is satisfied and false otherwise. Typically, implementations use the resource found in the context to test if the condition holds or not, but sometimes the condition may depend on other aspects, such as the current time or other environmental conditions not directly related to the resource.
      Specified by:
      evaluate in interface WorkflowConditionProvider
      Parameters:
      context - the execution context for the workflow evaluation
      Returns:
      true if the condition is met, false otherwise
    • toPredicate

      public jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<String> query, jakarta.persistence.criteria.Root<?> path)
      Description copied from interface: WorkflowConditionProvider
      Creates a JPA Criteria API Predicate representing this condition for use in queries.

      Implementations should construct and return a Predicate that can be applied to a query that targets the underlying resource. The method receives a CriteriaBuilder, the CriteriaQuery being built and the query Root corresponding to the resource being filtered.
      Specified by:
      toPredicate in interface WorkflowConditionProvider
      Parameters:
      cb - the CriteriaBuilder used to construct predicates
      query - the CriteriaQuery being constructed
      path - the Root representing the resource entity in the query
      Returns:
      a Predicate representing this condition for use in a CriteriaQuery
    • validate

      public void validate() throws WorkflowInvalidStateException
      Description copied from interface: WorkflowConditionProvider
      Validates the internal configuration/state of this condition provider.

      Implementations should perform any necessary self-checks and throw a WorkflowInvalidStateException if the provider is not correctly configured or cannot operate safely.
      Specified by:
      validate in interface WorkflowConditionProvider
      Throws:
      WorkflowInvalidStateException - if the provider is in an invalid state
    • close

      public void close()
      Specified by:
      close in interface Provider