Skip to content

Commit

Permalink
Added more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mans4singh committed Dec 23, 2016
1 parent 32fc945 commit 6578099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,15 @@ public Response getUserList(@HeaderParam(AUTHORIZATION)
}

UserPermissionsList userPermissionsList = authorization.getUserPermissionsList(subject);
List<UserRoleList> userRoleListList = new ArrayList<>();
List<UserRoleList> userRoleList = new ArrayList<>();
for (UserPermissions userPermissions : userPermissionsList.getPermissionsList()) {
UserRoleList list = authorization.getApplicationUsers(userPermissions.getApplicationName());
if (!list.getRoleList().isEmpty()) {
userRoleListList.add(list);
userRoleList.add(list);
}
}

return httpHeader.headers().entity(userRoleListList).build();
return httpHeader.headers().entity(userRoleList).build();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.common.base.Optional;
import com.intuit.wasabi.authenticationobjects.UserInfo;
import com.intuit.wasabi.authenticationobjects.UserInfo.Username;
import com.intuit.wasabi.authorization.Authorization;
import com.intuit.wasabi.authorizationobjects.*;
import com.intuit.wasabi.eventlog.EventLog;
Expand Down Expand Up @@ -219,6 +218,8 @@ private UserInfo.Username parseUsername(Optional<String> authHeader) {
@Override
public void assignUserToSuperAdminRole(UserInfo candidateUserInfo, UserInfo assigningUserInfo) {

LOGGER.debug("Assigning super admin role to {} by {} ", candidateUserInfo, assigningUserInfo);

UserRoleList userRoleList = getUserRoleList(candidateUserInfo.getUsername());

LOGGER.debug("User role list {}", userRoleList);
Expand All @@ -237,9 +238,13 @@ public void assignUserToSuperAdminRole(UserInfo candidateUserInfo, UserInfo assi
@Override
public void removeUserFromSuperAdminRole(UserInfo candidateUserInfo, UserInfo assigningUserInfo) {

LOGGER.debug("Removing user {} from superadmin by {}", candidateUserInfo, assigningUserInfo);

List<UserRole> allSuperAdmins = getSuperAdminRoleList();

if ( allSuperAdmins.size() == 1 )
LOGGER.debug("Current superadmins {}", allSuperAdmins);

if ( allSuperAdmins.size() == 1 )
throw new IllegalArgumentException("Cannot delete last superadmin " + candidateUserInfo.getUsername());

boolean isSuperAdmin = allSuperAdmins.stream().anyMatch((UserRole ur) -> ur.getRole().equals(Role.SUPERADMIN)
Expand All @@ -256,6 +261,8 @@ public void removeUserFromSuperAdminRole(UserInfo candidateUserInfo, UserInfo as

@Override
public List<UserRole> getSuperAdminRoleList() {
LOGGER.debug("Getting all super admins");

return authorizationRepository.getSuperAdminRoleList();
}

Expand Down

0 comments on commit 6578099

Please sign in to comment.