private boolean isImpersonationAuthorized()

in emr-user-role-mapper-application/src/main/java/com/amazon/aws/emr/api/MetadataController.java [187:204]


    private boolean isImpersonationAuthorized(HttpServletRequest httpServletRequest,
                                              String impersonatedUser) {
        Optional<String> caller = identifyCaller(httpServletRequest, false);
        if (caller.isPresent()) {
            if (!applicationConfiguration
                    .getAllowedUsersForImpersonation().contains(caller.get())) {
                log.warn("Unauthorized user {} trying to impersonate {}",
                        caller.get(), impersonatedUser);
                return false;
            }

            log.debug("Authorized {} to impersonate {}", caller.get(), impersonatedUser);
            return true;
        } else {
            log.warn("Failed to identify the caller of impersonation request");
            return false;
        }
    }