com.sap.cds.feature.xsuaa.XsuaaConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cds-feature-xsuaa Show documentation
Show all versions of cds-feature-xsuaa Show documentation
API implementation to handle oauth2 tokens (JWT) in XSUAA format
The newest version!
/**************************************************************************
* (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
**************************************************************************/
package com.sap.cds.feature.xsuaa;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sap.cds.services.runtime.CdsRuntimeConfiguration;
import com.sap.cds.services.runtime.CdsRuntimeConfigurer;
import com.sap.cds.services.utils.XsuaaUtils;
import com.sap.cloud.environment.servicebinding.api.ServiceBinding;
public class XsuaaConfiguration implements CdsRuntimeConfiguration {
private static final Logger logger = LoggerFactory.getLogger(XsuaaConfiguration.class);
@Override
public void eventHandlers(CdsRuntimeConfigurer configurer) {
xsuaaConfigured(configurer, binding -> {
configurer.eventHandler(new XsuaaTenantProviderHandler(binding));
});
}
@Override
public void providers(CdsRuntimeConfigurer configurer) {
xsuaaConfigured(configurer, binding -> {
logger.info("Loaded feature 'XsuaaUserInfoProvider' ({})", binding.getName().get());
configurer.provider(new XsuaaUserInfoProvider(binding, configurer.getCdsRuntime()));
});
}
private void xsuaaConfigured(CdsRuntimeConfigurer configurer, Consumer configure) {
XsuaaUtils xsuaaUtils = new XsuaaUtils(configurer.getCdsRuntime());
if (xsuaaUtils.xsuaaAuthenticationConfigured()) {
xsuaaUtils.getXsuaaServiceBindings().stream().findFirst().ifPresent(configure);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy