Search in sources :

Example 1 with RoleAssignmentView

use of com.blackducksoftware.integration.hub.api.generated.view.RoleAssignmentView 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;
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) UserGroupService(com.blackducksoftware.integration.hub.service.UserGroupService) RoleAssignmentView(com.blackducksoftware.integration.hub.api.generated.view.RoleAssignmentView) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory)

Aggregations

IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 RoleAssignmentView (com.blackducksoftware.integration.hub.api.generated.view.RoleAssignmentView)1 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)1 UserGroupService (com.blackducksoftware.integration.hub.service.UserGroupService)1