Search in sources :

Example 1 with UserRole

use of org.finra.gatekeeper.services.accessrequest.model.UserRole 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;
        }
    }
}
Also used : User(org.finra.gatekeeper.services.accessrequest.model.User) AccessRequest(org.finra.gatekeeper.services.accessrequest.model.AccessRequest) UserRole(org.finra.gatekeeper.services.accessrequest.model.UserRole) Job(org.activiti.engine.runtime.Job)

Example 2 with UserRole

use of org.finra.gatekeeper.services.accessrequest.model.UserRole in project Gatekeeper by FINRAOS.

the class GatekeeperOverrideProperties method getMaxDaysForRequest.

public Integer getMaxDaysForRequest(GatekeeperRdsRole requestorRole, List<UserRole> roleList, String sdlc) {
    Integer currMax = maxDays;
    // For each role let's check if there was some override value set.
    for (UserRole role : roleList) {
        Map<String, Map<String, Integer>> overridePolicy = getOverridePolicy(requestorRole);
        // if there's a policy then lets keep going
        if (overridePolicy != null && overridePolicy.containsKey(role.getRole()) && overridePolicy.containsValue(overridePolicy.get(role.getRole()))) {
            Map<String, Integer> env = overridePolicy.get(role.getRole());
            Integer max = env.get(sdlc) != null ? env.get(sdlc) : maxDays;
            currMax = max < currMax ? max : currMax;
        }
    }
    return currMax;
}
Also used : UserRole(org.finra.gatekeeper.services.accessrequest.model.UserRole) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

UserRole (org.finra.gatekeeper.services.accessrequest.model.UserRole)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Job (org.activiti.engine.runtime.Job)1 AccessRequest (org.finra.gatekeeper.services.accessrequest.model.AccessRequest)1 User (org.finra.gatekeeper.services.accessrequest.model.User)1