private Optional<AuditableExecutionResult> byServiceAndRegisteredServiceAndPrincipal(final AuditableContext context) {
        val providedService = context.getService();
        val providedRegisteredService = context.getRegisteredService();
        val providedPrincipal = context.getPrincipal();
        if (providedService.isPresent() && providedRegisteredService.isPresent() && providedPrincipal.isPresent()) {
            val registeredService = providedRegisteredService.get();
            val service = providedService.get();
            val principal = providedPrincipal.get();

            val result = AuditableExecutionResult.builder()
                .registeredService(registeredService)
                .service(service)
                .build();

            try {
                principalAccessStrategyEnforcer.authorize(
                    RegisteredServicePrincipalAccessStrategyEnforcer.PrincipalAccessStrategyContext.builder()
                        .registeredService(registeredService)
                        .principalId(principal.getId())
                        .principalAttributes(principal.getAttributes())
                        .service(service)
                        .applicationContext(applicationContext)
                        .build());
            } catch (final Throwable e) {
                result.setException(e);
            }
            return Optional.of(result);
        }
        return Optional.empty();
    }
By service and registered service and principal optional.

@param context the context
@return the optional
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/RegisteredServiceAccessStrategyAuditableEnforcer.java