Class PermissionArgumentParser

java.lang.Object
ca.cdr.api.security.permission.PermissionArgumentParser

public final class PermissionArgumentParser extends Object
Parser for PermissionEnum arguments
  • Method Details

    • withFhirContext

      @Nonnull public static PermissionArgumentParser withFhirContext(@Nonnull FhirContext theFhirContext)
    • withoutFhirContext

      @Nonnull public static PermissionArgumentParser withoutFhirContext()
    • parse

      public Optional<PermissionArgumentValue> parse(@Nonnull GrantedAuthorityJson theGrantedAuthority)
      Parse any authority generically. Parses the GrantedAuthorityJson argument via the declared format of the PermissionEnum. Use PermissionArgumentFormat.IPermissionComponent type checks to extract information.
      Parameters:
      theGrantedAuthority - the authority (permission and argument) to parse
      Returns:
      the parsed value, if the format was valid
    • parseForValue

      @Nonnull public <T extends PermissionArgumentValue> Optional<T> parseForValue(@Nonnull GrantedAuthorityJson theGrantedAuthority, @Nonnull Class<T> theArgumentValueType)
      Parse the argument string from the GrantedAuthorityJson into the declared argument value type. It is an error to request the wrong type. Use parse(GrantedAuthorityJson) to parse for any permission.
      Type Parameters:
      T - the type or type component to be parsed
      Parameters:
      theGrantedAuthority - the permission and argument to parse
      theArgumentValueType - the concrete parsed value type or a component interface
      Returns:
      the parsed data, if the declared argument format agrees with theArgumentValueType
      Throws:
      IllegalArgumentException - if the declared GA type does not match theArgumentValueType
    • parse

      public <T extends PermissionArgumentValue> Optional<T> parse(@Nullable String thePermissionArgument, @Nonnull PermissionArgumentFormat<T> theFormat)
      Parse a string against a defined format.
      Type Parameters:
      T - The concrete argument value type (e.g. TypeInCompartmentWithOptionalFilter), for the format.
      Parameters:
      thePermissionArgument - the permission argument to parse
      theFormat - the permission argument format
      Returns:
      The value-type for the format, or empty if the string doesn't match the format.
    • hasFilter

      public static boolean hasFilter(GrantedAuthorityJson theGrantedAuthorityJson)
      Goofy check looking for the presence of filter expressions in an argument. Faster than a full parse.
      Parameters:
      theGrantedAuthorityJson - the authority to check
      Returns:
      true if the permission argument type can have a filter AND the filter is present