19 package org.turro.security;
21 import java.util.function.Supplier;
22 import org.turro.elephant.context.Application;
23 import org.turro.plugin.contacts.IContact;
32 private final String[] roles;
33 private final Supplier<Boolean> supplier;
36 this.contact = contact;
42 this.contact = contact;
43 this.supplier = supplier;
49 for(String role : roles) {
50 if(role.contains(
":")) {
55 if(hasAnyRoleKey(role)) {
61 if(supplier !=
null) {
62 return supplier.get();
67 private boolean isInRole(String role) {
68 return contact !=
null || contact.
isValid() ?
72 private boolean hasAnyRoleKey(String role) {
73 return contact !=
null || contact.
isValid() ?
static IContact getUser()
static Permission from(String... roles)
static Permission from(Supplier< Boolean > supplier)
static Permission from(IContact contact, String... roles)
static Permission from(IContact contact, Supplier< Boolean > supplier)
boolean isInRole(String role)
boolean hasAnyRoleKey(String role)