File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
services-api/src/main/java/io/scalecube/services/auth Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 4
4
import java .util .Objects ;
5
5
import java .util .Set ;
6
6
7
+ /**
8
+ * Service principal implementation of {@link Principal}. Provides role-based access control by
9
+ * allowing checks against assigned roles and permissions.
10
+ */
7
11
public class ServicePrincipal implements Principal {
8
12
9
13
private final String role ;
@@ -17,7 +21,7 @@ public class ServicePrincipal implements Principal {
17
21
*/
18
22
public ServicePrincipal (String role , Collection <String > permissions ) {
19
23
this .role = role ;
20
- this .permissions = Set .copyOf (permissions );
24
+ this .permissions = permissions != null ? Set .copyOf (permissions ) : null ;
21
25
}
22
26
23
27
@ Override
@@ -37,6 +41,6 @@ public Collection<String> permissions() {
37
41
38
42
@ Override
39
43
public boolean hasPermission (String permission ) {
40
- return permissions .contains (permission );
44
+ return permissions != null && permissions .contains (permission );
41
45
}
42
46
}
You can’t perform that action at this time.
0 commit comments