private static Optional<ResponseEntity<String>> authorizePrincipal(final AmazonSecurityTokenServiceProperties amz,
                                                                       final Principal principal) {
        if (StringUtils.isNotBlank(amz.getPrincipalAttributeName())) {
            if (!principal.getAttributes().containsKey(amz.getPrincipalAttributeName())) {
                LOGGER.error("Failed to locate authorization attribute for principal [{}]", principal);
                return Optional.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authorization failure"));
            }
            val attributeValues = principal.getAttributes().get(amz.getPrincipalAttributeName());
            if (StringUtils.isNotBlank(amz.getPrincipalAttributeValue())
                && attributeValues.stream().noneMatch(value -> RegexUtils.find(amz.getPrincipalAttributeValue(), value.toString()))) {
                LOGGER.error("Failed to locate authorization attribute value for principal [{}]", principal);
                return Optional.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authorization failure"));
            }
        }
        return Optional.empty();
    }
This is {@link AmazonSecurityTokenServiceEndpoint}.

@author Misagh Moayyed
@since 6.4.0
support/cas-server-support-aws/src/main/java/org/apereo/cas/aws/AmazonSecurityTokenServiceEndpoint.java