1010import org .springframework .beans .factory .annotation .Value ;
1111import org .springframework .security .core .Authentication ;
1212import org .springframework .security .core .GrantedAuthority ;
13- import org .springframework .security .core .authority .SimpleGrantedAuthority ;
1413import org .springframework .stereotype .Service ;
1514
1615@ Service
@@ -23,27 +22,27 @@ public class AuthorizationService {
2322
2423 @ Value ("${admin-groups:cf-admins}" )
2524 void initializeAdminRoles (String groups ) {
26- this .admin_groups = Arrays .asList (groups .split ("," )).stream ().map (g -> {
27- return "ROLE_" + g .trim ().toUpperCase ();
28- } ).collect (Collectors .toList ());
25+ AuthorizationService .admin_groups = Arrays .asList (groups .split ("," )).stream ().map (g ->
26+ "ROLE_" + g .trim ().toUpperCase ()
27+ ).collect (Collectors .toList ());
2928 }
3029 @ Value ("${channel-groups:cf-channels}" )
3130 void initializeChannelModRoles (String groups ) {
32- this .channel_groups = Arrays .asList (groups .split ("," )).stream ().map (g -> {
33- return "ROLE_" + g .trim ().toUpperCase ();
34- } ).collect (Collectors .toList ());
31+ AuthorizationService .channel_groups = Arrays .asList (groups .split ("," )).stream ().map (g ->
32+ "ROLE_" + g .trim ().toUpperCase ()
33+ ).collect (Collectors .toList ());
3534 }
3635 @ Value ("${property-groups:cf-properties}" )
3736 void initializePropertyRoles (String groups ) {
38- this .property_groups = Arrays .asList (groups .split ("," )).stream ().map (g -> {
39- return "ROLE_" + g .trim ().toUpperCase ();
40- } ).collect (Collectors .toList ());
37+ AuthorizationService .property_groups = Arrays .asList (groups .split ("," )).stream ().map (g ->
38+ "ROLE_" + g .trim ().toUpperCase ()
39+ ).collect (Collectors .toList ());
4140 }
4241 @ Value ("${tag-groups:cf-tags}" )
4342 void initializeTagRoles (String groups ) {
44- this .tag_groups = Arrays .asList (groups .split ("," )).stream ().map (g -> {
45- return "ROLE_" + g .trim ().toUpperCase ();
46- } ).collect (Collectors .toList ());
43+ AuthorizationService .tag_groups = Arrays .asList (groups .split ("," )).stream ().map (g ->
44+ "ROLE_" + g .trim ().toUpperCase ()
45+ ).collect (Collectors .toList ());
4746 }
4847
4948 public enum ROLES {
@@ -57,11 +56,10 @@ public enum ROLES {
5756 private ROLES (List <String > groups ) {
5857 this .groups = groups ;
5958 }
60-
61- };
59+ }
6260
6361 public boolean isAuthorizedOwner (Authentication authentication , XmlTag data ) {
64- ArrayList <String > auth = new ArrayList <String >();
62+ ArrayList <String > auth = new ArrayList <>();
6563 Collection <? extends GrantedAuthority > auths = authentication .getAuthorities ();
6664 for (GrantedAuthority a : auths )
6765 auth .add (a .getAuthority ());
@@ -74,7 +72,7 @@ public boolean isAuthorizedOwner(Authentication authentication, XmlTag data) {
7472 }
7573
7674 public boolean isAuthorizedOwner (Authentication authentication , XmlProperty data ) {
77- ArrayList <String > auth = new ArrayList <String >();
75+ ArrayList <String > auth = new ArrayList <>();
7876 Collection <? extends GrantedAuthority > auths = authentication .getAuthorities ();
7977 for (GrantedAuthority a : auths )
8078 auth .add (a .getAuthority ());
@@ -87,7 +85,7 @@ public boolean isAuthorizedOwner(Authentication authentication, XmlProperty data
8785 }
8886
8987 public boolean isAuthorizedOwner (Authentication authentication , XmlChannel data ) {
90- ArrayList <String > auth = new ArrayList <String >();
88+ ArrayList <String > auth = new ArrayList <>();
9189 Collection <? extends GrantedAuthority > auths = authentication .getAuthorities ();
9290 for (GrantedAuthority a : auths )
9391 auth .add (a .getAuthority ());
@@ -100,7 +98,7 @@ public boolean isAuthorizedOwner(Authentication authentication, XmlChannel data)
10098 }
10199
102100 public boolean isAuthorizedRole (Authentication authentication , ROLES expectedRole ) {
103- ArrayList <String > auth = new ArrayList <String >();
101+ ArrayList <String > auth = new ArrayList <>();
104102 Collection <? extends GrantedAuthority > auths = authentication .getAuthorities ();
105103 for (GrantedAuthority a : auths )
106104 auth .add (a .getAuthority ());
0 commit comments