BrightSide Workbench Full Report + Source Code
org.turro.security.Permissions Class Reference
Collaboration diagram for org.turro.security.Permissions:

Static Public Member Functions

static FlatPermissions from (Set< String > securityGroups)
 
static Set< String > getSecurityGroupIdsBy (String role)
 
static Set< String > getRoleNames ()
 
static Set< String > getRoleNames (Set< String > securityGroups)
 
static Set< String > getRoleNamesByPermission (String role)
 
static SortedMap< String, SortedSet< String > > permissionStringMap ()
 
static Permissions instance ()
 
static void reset ()
 

Static Public Attributes

static TreeSet ON_SET = new TreeSet<>(Set.of("on"))
 

Protected Member Functions

 Permissions ()
 

Protected Attributes

final TreeMap< String, RoleMaproleMaps
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 36 of file Permissions.java.

Constructor & Destructor Documentation

◆ Permissions()

org.turro.security.Permissions.Permissions ( )
protected

Definition at line 132 of file Permissions.java.

132  {
133  roleMaps = new TreeMap<>();
134  loadMap();
135  }
final TreeMap< String, RoleMap > roleMaps

Member Function Documentation

◆ from()

static FlatPermissions org.turro.security.Permissions.from ( Set< String >  securityGroups)
static

Definition at line 40 of file Permissions.java.

40  {
41  FlatPermissions permissions = new FlatPermissions();
42  securityGroups.forEach(sg -> {
43  SecurityGroup securityGroup = SecurityGroups.get(sg);
44  flatten(securityGroup, permissions);
45  // Nested are done when SocialGroups.syndicate()
46 // securityGroup.getSyndicate().forEach(nested -> {
47 // flatten(SecurityGroups.get(nested), permissions);
48 // });
49  });
50  return permissions;
51  }
Here is the call graph for this function:

◆ getRoleNames() [1/2]

static Set<String> org.turro.security.Permissions.getRoleNames ( )
static

Definition at line 77 of file Permissions.java.

77  {
78  return instance().roleMaps.keySet();
79  }
static Permissions instance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoleNames() [2/2]

static Set<String> org.turro.security.Permissions.getRoleNames ( Set< String >  securityGroups)
static

Definition at line 81 of file Permissions.java.

81  {
82  return securityGroups.stream().flatMap(sg -> SecurityGroups.get(sg).getRoles().stream()).collect(Collectors.toSet());
83  }
Here is the call graph for this function:

◆ getRoleNamesByPermission()

static Set<String> org.turro.security.Permissions.getRoleNamesByPermission ( String  role)
static

Definition at line 85 of file Permissions.java.

85  {
86  String parts[] = role.split(":");
87  Set<String> set = new HashSet<>();
88  instance().roleMaps.entrySet().forEach(rm -> {
89  rm.getValue().getRolePermissions().entrySet().forEach(permission -> {
90  if(permission.getKey().equals(parts[0])) {
91  if(parts.length == 2 && permission.getValue().contains(parts[1])) {
92  set.add(rm.getValue().getName());
93  } else {
94  set.add(rm.getValue().getName());
95  }
96  }
97  });
98  });
99  return set;
100  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSecurityGroupIdsBy()

static Set<String> org.turro.security.Permissions.getSecurityGroupIdsBy ( String  role)
static

Definition at line 64 of file Permissions.java.

64  {
65  if(role.contains(":")) { // permission
66  Set<String> roleNames = getRoleNamesByPermission(role);
67  return SecurityGroups.getAll().stream()
68  .filter(sg -> sg.getRoles().stream().anyMatch(r -> roleNames.contains(r)))
69  .map(sg -> sg.getId()).collect(Collectors.toSet());
70  } else { // role name
71  return SecurityGroups.getAll().stream()
72  .filter(sg -> sg.getRoles().contains(role))
73  .map(sg -> sg.getId()).collect(Collectors.toSet());
74  }
75  }
static Set< String > getRoleNamesByPermission(String role)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ instance()

static Permissions org.turro.security.Permissions.instance ( )
static

Definition at line 124 of file Permissions.java.

124  {
125  return INIT.instance(() -> new Permissions());
126  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ permissionStringMap()

static SortedMap<String, SortedSet<String> > org.turro.security.Permissions.permissionStringMap ( )
static

Definition at line 104 of file Permissions.java.

104  {
105  SortedMap<String, SortedSet<String>> map = new TreeMap<>();
106  instance().roleMaps.entrySet().forEach(role -> {
107  SortedSet<String> set = new TreeSet<>();
108  role.getValue().getRolePermissions().entrySet().forEach(permission -> {
109  set.add(permission.getKey() + ": " + permission.getValue().stream().collect(Collectors.joining(", ")));
110  });
111  map.put(role.getKey(), set);
112  });
113  return map;
114  }
Here is the caller graph for this function:

◆ reset()

static void org.turro.security.Permissions.reset ( )
static

Definition at line 128 of file Permissions.java.

128  {
129  INIT.reset();
130  }

Member Data Documentation

◆ ON_SET

TreeSet org.turro.security.Permissions.ON_SET = new TreeSet<>(Set.of("on"))
static

Definition at line 117 of file Permissions.java.

◆ roleMaps

final TreeMap<String, RoleMap> org.turro.security.Permissions.roleMaps
protected

Definition at line 38 of file Permissions.java.


The documentation for this class was generated from the following file: