@@ -169,35 +169,31 @@ public List<Integer> checkUserPathPrivileges(
169169 String username , List <? extends PartialPath > allPath , PrivilegeType permission ) {
170170 checkCacheAvailable ();
171171 List <Integer > posList = new ArrayList <>();
172- User user = iAuthorCache .getUserCache (username );
173- if (user != null ) {
174- if (user .isOpenIdUser ()) {
175- return posList ;
176- }
177- int pos = 0 ;
178- for (PartialPath path : allPath ) {
179- if (!user .checkPathPrivilege (path , permission )) {
180- boolean checkFromRole = false ;
181- for (String rolename : user .getRoleSet ()) {
182- Role cachedRole = iAuthorCache .getRoleCache (rolename );
183- if (cachedRole == null ) {
184- return checkPathFromConfigNode (username , allPath , permission );
185- }
186- if (cachedRole .checkPathPrivilege (path , permission )) {
187- checkFromRole = true ;
188- break ;
189- }
172+ User user = getUser (username );
173+ if (user .isOpenIdUser ()) {
174+ return posList ;
175+ }
176+ int pos = 0 ;
177+ for (PartialPath path : allPath ) {
178+ if (!user .checkPathPrivilege (path , permission )) {
179+ boolean checkFromRole = false ;
180+ for (String rolename : user .getRoleSet ()) {
181+ Role cachedRole = iAuthorCache .getRoleCache (rolename );
182+ if (cachedRole == null ) {
183+ checkRoleFromConfigNode (username , rolename );
190184 }
191- if (!checkFromRole ) {
192- posList .add (pos );
185+ if (cachedRole .checkPathPrivilege (path , permission )) {
186+ checkFromRole = true ;
187+ break ;
193188 }
194189 }
195- pos ++;
190+ if (!checkFromRole ) {
191+ posList .add (pos );
192+ }
196193 }
197- return posList ;
198- } else {
199- return checkPathFromConfigNode (username , allPath , permission );
194+ pos ++;
200195 }
196+ return posList ;
201197 }
202198
203199 @ Override
@@ -642,15 +638,6 @@ private TPermissionInfoResp checkPrivilegeFromConfigNode(TCheckUserPrivilegesReq
642638 return permissionInfoResp ;
643639 }
644640
645- private List <Integer > checkPathFromConfigNode (
646- String username , List <? extends PartialPath > allPath , PrivilegeType permission ) {
647- TCheckUserPrivilegesReq req =
648- new TCheckUserPrivilegesReq (
649- username , PrivilegeModelType .TREE .ordinal (), permission .ordinal (), false );
650- req .setPaths (AuthUtils .serializePartialPathList (allPath ));
651- return checkPrivilegeFromConfigNode (req ).getFailPos ();
652- }
653-
654641 private boolean checkRoleFromConfigNode (String username , String rolename ) {
655642 TAuthorizerReq req = new TAuthorizerReq ();
656643 // just reuse authorizer request. only need username and rolename field.
0 commit comments