protected static byte[] encodeInternal(final String data, final RegisteredService registeredService) {
        val publicKey = registeredService.getPublicKey();
        if (publicKey == null) {
            LOGGER.error("No public key is defined for service [{}]. No attributes will be released", registeredService);
            return null;
        }
        LOGGER.debug("Using service [{}] public key [{}] to initialize the cipher", registeredService.getServiceId(), publicKey);
        val cipher = publicKey.toCipher();
        if (cipher != null) {
            LOGGER.trace("Initialized cipher successfully. Proceeding to finalize...");
            return FunctionUtils.doUnchecked(() -> cipher.doFinal(data.getBytes(StandardCharsets.UTF_8)));
        }
        return null;
    }
Instantiates a new registered service cipher executor.
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/services/RegisteredServicePublicKeyCipherExecutor.java