private SecurityToken invokeSecurityTokenServiceForToken(final WSFederationRegisteredService rp,
                                                             final SecurityTokenServiceClient sts,
                                                             final String principalId) {

        try {
            val properties = sts.getProperties();
            properties.put(SecurityConstants.USERNAME, principalId);
            val uid = credentialCipherExecutor.encode(principalId);
            properties.put(SecurityConstants.PASSWORD, uid);
            LOGGER.debug("Requesting security token for principal [{}] and registered service [{}]", uid, rp);
            return sts.requestSecurityToken(rp.getAppliesTo());
        } catch (final Exception e) {
            LoggingUtils.error(LOGGER, e);
            throw new AuthenticationException(e.getMessage());
        }
    }
This is {@link DefaultSecurityTokenServiceTokenFetcher}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-ws-sts-api/src/main/java/org/apereo/cas/authentication/DefaultSecurityTokenServiceTokenFetcher.java