@@ -88,7 +88,7 @@ public String getCurrentUserId() {
8888 return getUserId (getCurrentAuth ());
8989 }
9090
91- public String [] getAdminGroups () {
91+ public Set < String > getAdminGroups () {
9292 Set <String > adminGroups = new HashSet <>();
9393
9494 // Support for old, non-array notation
@@ -105,10 +105,10 @@ public String[] getAdminGroups() {
105105 adminGroups .add (groupName .toUpperCase ());
106106 }
107107
108- return adminGroups . toArray ( new String [ adminGroups . size ()]) ;
108+ return adminGroups ;
109109 }
110110
111- public String [] getAdminUsers () {
111+ public Set < String > getAdminUsers () {
112112 Set <String > adminUsers = new HashSet <>();
113113
114114 // Support for old, non-array notation
@@ -125,14 +125,14 @@ public String[] getAdminUsers() {
125125 adminUsers .add (userName );
126126 }
127127
128- return adminUsers . toArray ( new String [ adminUsers . size ()]) ;
128+ return adminUsers ;
129129 }
130130
131- public String [] getGroups () {
131+ public List < String > getGroups () {
132132 return getGroups (getCurrentAuth ());
133133 }
134134
135- public static String [] getGroups (Authentication auth ) {
135+ public static List < String > getGroups (Authentication auth ) {
136136 List <String > groups = new ArrayList <>();
137137 if (auth != null ) {
138138 for (GrantedAuthority grantedAuth : auth .getAuthorities ()) {
@@ -141,15 +141,15 @@ public static String[] getGroups(Authentication auth) {
141141 groups .add (authName );
142142 }
143143 }
144- return groups . toArray ( new String [ groups . size ()]) ;
144+ return groups ;
145145 }
146146
147147 public boolean isAdmin () {
148148 return isAdmin (getCurrentAuth ());
149149 }
150150
151151 public boolean isAdmin (Authentication auth ) {
152- if (!authBackend .hasAuthorization ()) {
152+ if (!authBackend .hasAuthorization () || auth == null ) {
153153 return false ;
154154 }
155155
@@ -161,7 +161,7 @@ public boolean isAdmin(Authentication auth) {
161161
162162 String userName = getUserId (auth );
163163 for (String adminUser : getAdminUsers ()) {
164- if (userName != null && userName .equals (adminUser )) {
164+ if (userName != null && userName .equalsIgnoreCase (adminUser )) {
165165 return true ;
166166 }
167167 }
0 commit comments