use of io.imunity.furms.spi.exceptions.UnityFailureException in project furms by unity-idm.
the class UnityUsersDAO method getUserStatus.
@Override
public UserStatus getUserStatus(FenixUserId fenixUserId) {
String uri = UriComponentsBuilder.newInstance().path(ENTITY_BASE).path(fenixUserId.id).toUriString();
try {
ObjectNode response = unityClient.get(uri, ObjectNode.class, Map.of("identityType", "identifier"));
String statusStr = response.get("entityInformation").get("state").asText();
EntityState unityState = EntityState.valueOf(statusStr);
return unityState == EntityState.valid ? UserStatus.ENABLED : UserStatus.DISABLED;
} catch (WebClientResponseException e) {
throw new UnityFailureException(e.getMessage(), e);
}
}
use of io.imunity.furms.spi.exceptions.UnityFailureException in project furms by unity-idm.
the class UnitySiteGroupDAO method update.
@Override
public void update(Site site) {
assertTrue(site != null && !isEmpty(site.getId()), () -> new IllegalArgumentException("Could not update Site in Unity. Missing Site or Site ID."));
Map<String, Object> uriVariables = uriVariables(site);
String metaSitePath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(SITE_PATTERN).path(META).uriVariables(uriVariables).buildAndExpand().encode().toUriString();
try {
Group group = unityClient.get(metaSitePath, Group.class);
group.setDisplayedName(new I18nString(site.getName()));
unityClient.put(GROUP_BASE, group);
} catch (WebClientResponseException e) {
throw new UnityFailureException(e.getMessage(), e);
}
}
use of io.imunity.furms.spi.exceptions.UnityFailureException in project furms by unity-idm.
the class UnitySiteGroupDAO method create.
@Override
public void create(Site site) {
assertTrue(site != null && !isEmpty(site.getId()), () -> new IllegalArgumentException("Could not create Site in Unity. Missing Site or Site ID"));
Map<String, Object> uriVariables = uriVariables(site);
String groupPath = UriComponentsBuilder.newInstance().path(SITE_PATTERN).uriVariables(uriVariables).toUriString();
Group group = new Group(groupPath);
group.setDisplayedName(new I18nString(site.getName()));
try {
unityClient.post(GROUP_BASE, group);
} catch (WebClientResponseException e) {
throw new UnityFailureException(e.getMessage(), e);
}
try {
String createSiteUsersPath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(groupPath + USERS_PATTERN).toUriString();
unityClient.post(createSiteUsersPath);
} catch (WebClientResponseException e) {
throw new UnityFailureException(e.getMessage(), e);
}
}
use of io.imunity.furms.spi.exceptions.UnityFailureException in project furms by unity-idm.
the class UserServiceImpl method setUserStatus.
@Override
@FurmsAuthorize(capability = USERS_MAINTENANCE)
public void setUserStatus(FenixUserId fenixUserId, UserStatus status) {
checkNotNull(status);
checkNotNull(fenixUserId);
LOG.info("Setting {} status to {}", fenixUserId, status);
try {
usersDAO.setUserStatus(fenixUserId, status);
userAllocationsService.findAllByFenixUserId(fenixUserId).forEach(userAddition -> userAccountStatusUpdater.setStatus(new SiteAgentSetUserAccountStatusRequest(userAddition, status, SECURITY_INCIDENT)));
} catch (UnityFailureException e) {
LOG.info("Failed to resolve user", e);
throw new UnknownUserException(fenixUserId);
}
}
use of io.imunity.furms.spi.exceptions.UnityFailureException in project furms by unity-idm.
the class UnityUsersDAO method setUserStatus.
@Override
public void setUserStatus(FenixUserId fenixUserId, UserStatus status) {
EntityState unityStatus = status == UserStatus.ENABLED ? EntityState.valid : EntityState.disabled;
String uri = UriComponentsBuilder.newInstance().path(ENTITY_BASE).path(fenixUserId.id).path("/status/").path(unityStatus.name()).toUriString();
try {
unityClient.put(uri, null, Map.of("identityType", "identifier"));
} catch (WebClientResponseException e) {
throw new UnityFailureException(e.getMessage(), e);
}
}
Aggregations