Class FieldSecurityUtil

java.lang.Object
nl.datasteel.crudcraft.runtime.security.FieldSecurityUtil

public final class FieldSecurityUtil extends Object
Utility methods for enforcing field-level security on DTOs.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canRead(String[] roles)
    Determines if the current user can read based on the given roles.
    static boolean
    canWrite(String[] roles)
    Determines if the current user can write based on the given roles.
    static <T> T
    filterRead(T dto)
    Filters the provided DTO for read operations.
    static <T> T
    filterWrite(T dto)
    Filters the provided DTO for write operations.
    static <T> T
    filterWrite(T dto, Object existing)
    Filters the DTO using values from an existing object to restore fields the caller is not permitted to modify.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • canRead

      public static boolean canRead(String[] roles)
      Determines if the current user can read based on the given roles.
      Parameters:
      roles - roles required for read access
      Returns:
      true if the user has any of the roles
    • canWrite

      public static boolean canWrite(String[] roles)
      Determines if the current user can write based on the given roles.
      Parameters:
      roles - roles required for write access
      Returns:
      true if the user has any of the roles
    • filterRead

      public static <T> T filterRead(T dto)
      Filters the provided DTO for read operations.
      Parameters:
      dto - the object to filter
      Returns:
      the filtered DTO
    • filterWrite

      public static <T> T filterWrite(T dto)
      Filters the provided DTO for write operations.
      Parameters:
      dto - the object to filter
      Returns:
      the filtered DTO
    • filterWrite

      public static <T> T filterWrite(T dto, Object existing)
      Filters the DTO using values from an existing object to restore fields the caller is not permitted to modify.
      Parameters:
      dto - the DTO containing new values
      existing - the existing object to source immutable field values from
      Returns:
      the filtered DTO