Package com.onec.ui

Class UiProfileResolver

java.lang.Object
com.onec.ui.UiProfileResolver

public class UiProfileResolver extends Object
Resolves which UiLayout.Profile a user sees, by matching their roles against each named profile's target roles. Pure presentation/curation: this decides what a cooperating client renders, never what data access is granted — that stays enforced per data endpoint. Callers pass an already-normalized role set (upper-case, ROLE_ stripped); profile role tokens are normalized here so the two sides compare consistently.
  • Constructor Details

    • UiProfileResolver

      public UiProfileResolver()
  • Method Details

    • resolve

      public UiProfileResolver.Resolution resolve(UiLayout layout, Set<String> roles)
      Pick the best profile for a user: the highest-priority named profile whose roles intersect roles, falling back to the default profile when none match. Also returns the full set the user may switch between.
    • switchable

      public List<UiLayout.Profile> switchable(UiLayout layout, Set<String> roles)
      The profiles a user may switch between. A user who matches one or more named profiles is confined to those — they cannot fall back to the default back-office. The default profile is offered only to users who match no named profile at all. This is what locks a curated persona (e.g. a cleaner) out of every other view: their role grants exactly one profile and nothing else is switchable.
    • byId

      public UiLayout.Profile byId(UiLayout layout, String id)
      Look up a profile by id for an explicit ?profile= switch. Falls back to the default profile for null/blank/"default"/unknown ids. Note: this does not verify the user is eligible — callers that honor a client-supplied id should intersect with switchable(com.onec.ui.UiLayout, java.util.Set<java.lang.String>) first.