use of com.blackducksoftware.integration.hub.service.UserGroupService in project hub-alert by blackducksoftware.
the class LoginActions method isUserRoleValid.
public boolean isUserRoleValid(final String userName, final RestConnection restConnection) {
final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
final UserGroupService userGroupService = hubServicesFactory.createUserGroupService();
try {
final List<RoleAssignmentView> userRoles = userGroupService.getRolesForUser(userName);
for (final RoleAssignmentView roles : userRoles) {
if ("System Administrator".equalsIgnoreCase(roles.name)) {
return true;
}
}
} catch (final IntegrationException e) {
return false;
}
return false;
}
use of com.blackducksoftware.integration.hub.service.UserGroupService in project hub-alert by blackducksoftware.
the class EmailGroupChannel method getEmailAddressesForGroup.
private List<String> getEmailAddressesForGroup(final HubServicesFactory hubServicesFactory, final String hubGroup) throws IntegrationException {
final UserGroupService groupService = hubServicesFactory.createUserGroupService();
final UserGroupView userGroupView = groupService.getGroupByName(hubGroup);
if (userGroupView == null) {
throw new IntegrationException("Could not find the Hub group: " + hubGroup);
}
logger.info(userGroupView.toString());
logger.info(userGroupView.json);
final List<UserView> users = hubServicesFactory.createHubService().getAllResponses(userGroupView, UserGroupView.USERS_LINK_RESPONSE);
return users.stream().map(user -> user.email).collect(Collectors.toList());
}
Aggregations