use of org.finra.gatekeeper.services.accessrequest.model.User in project Gatekeeper by FINRAOS.
the class RevokeAccessServiceTask method execute.
/**
* @param execution - the request to execute on
* @throws Exception - if the revocation fails
*/
public void execute(DelegateExecution execution) throws Exception {
Job job = managementService.createJobQuery().processInstanceId(execution.getProcessInstanceId()).singleResult();
AccessRequest accessRequest = (AccessRequest) execution.getVariable("accessRequest");
try {
logger.info("Revoking access for Users, Attempts remaining: " + job.getRetries());
for (User user : accessRequest.getUsers()) {
for (UserRole role : accessRequest.getRoles()) {
databaseConnectionService.revokeAccess(accessRequest.getAwsRdsInstances(), RoleType.valueOf(role.getRole().toUpperCase()), user.getUserId());
}
}
} catch (Exception e) {
if (job.getRetries() - 1 == 0) {
logger.error("Maximum attempt limit reached. Notify Ops team for manual removal");
emailServiceWrapper.notifyOps(accessRequest);
emailServiceWrapper.notifyAdminsOfFailure(accessRequest, e);
} else {
throw e;
}
}
}
Aggregations