private RegisteredService checkServiceExpirationPolicyIfAny(final RegisteredService registeredService) { if (registeredService == null || RegisteredServiceAccessStrategyUtils.ensureServiceIsNotExpired(registeredService)) { return registeredService; } return processExpiredRegisteredService(registeredService); }
/** * Ensure service access is allowed. * * @param service the service * @param registeredService the registered service */ public static void ensureServiceAccessIsAllowed(final String service, final RegisteredService registeredService) { if (registeredService == null) { val msg = String.format("Unauthorized Service Access. Service [%s] is not found in service registry.", service); LOGGER.warn(msg); throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg); } if (!registeredService.getAccessStrategy().isServiceAccessAllowed()) { val msg = String.format("Unauthorized Service Access. Service [%s] is not enabled in service registry.", service); LOGGER.warn(msg); throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg); } if (!ensureServiceIsNotExpired(registeredService)) { val msg = String.format("Expired Service Access. Service [%s] has been expired", service); LOGGER.warn(msg); throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_EXPIRED_SERVICE, msg); } }