@Override
    public String encode(final String data, final Optional<RegisteredService> service) {
        try {
            if (service.isPresent()) {
                val registeredService = service.get();
                val result = encodeInternal(data, registeredService);
                if (result != null) {
                    return EncodingUtils.encodeBase64(result);
                }
            }
        } catch (final Exception e) {
            LoggingUtils.warn(LOGGER, e);
        }
        return null;
    }
Instantiates a new registered service cipher executor.
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/services/RegisteredServicePublicKeyCipherExecutor.java