.withUserID(userID) .withUserEmail(userInfo.getEmail()) .withFirstName(userInfo.getFirstName()) .withLastName(userInfo.getLastName()) .build() Role.toRole(r.getRole()) .withFirstName(userInfo.getFirstName()) .withLastName(userInfo.getLastName()) .withUserEmail(userInfo.getEmail())
private UserRole getRoleWithUserInfo(com.intuit.wasabi.repository.cassandra.pojo.UserRole userRole) { LOGGER.debug("Getting user info for user role={}", userRole); Application.Name appName = userRole.getAppName().equals(ALL_APPLICATIONS) ? WILDCARD : Application.Name.valueOf(userRole.getAppName()); UserInfo userInfo = getUserInfo(UserInfo.Username.valueOf(userRole.getUserId())); UserRole roleWithUserInfo; if (nonNull(userInfo)) { roleWithUserInfo = UserRole.newInstance( appName, Role.toRole(userRole.getRole())). withUserID(UserInfo.Username.valueOf(userRole.getUserId())). withFirstName(userInfo.getFirstName()). withLastName(userInfo.getLastName()). withUserEmail(userInfo.getEmail()).build(); } else { roleWithUserInfo = UserRole.newInstance(appName, Role.toRole(userRole.getRole())) .withUserID(UserInfo.Username.valueOf(userRole.getUserId())).build(); } LOGGER.debug("Role with user info for user role={} is {}", userRole, roleWithUserInfo); return roleWithUserInfo; }
UserRole convertAppRoleToUserRole(Application.Name applicationName, AppRole appRole) { Role role = Role.toRole(appRole.getRole()); UserInfo.Username userID = UserInfo.Username.valueOf(appRole.getUserId()); UserInfo userInfo = getUserInfo(userID); if (userInfo == null) { userInfo = lookupUser(userID); } return UserRole.newInstance(applicationName, role) .withUserID(userID) .withUserEmail(userInfo.getEmail()) .withFirstName(userInfo.getFirstName()) .withLastName(userInfo.getLastName()) .build(); }