All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.security.xsuaa.autoconfiguration.XsuaaResourceServerJwkAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 3.5.9
Show newest version
/**
 * SPDX-FileCopyrightText: 2018-2023 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
 * 

* SPDX-License-Identifier: Apache-2.0 */ package com.sap.cloud.security.xsuaa.autoconfiguration; import com.sap.cloud.security.xsuaa.XsuaaServiceConfiguration; import com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoderBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.*; import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.web.client.RestOperations; import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; /** * {@link EnableAutoConfiguration Auto-configuration} that exposes a {@link JwtDecoder}, which has the standard Spring * Security Jwt validators as well as the XSUAA-specific validators. *

* Activates when there is a bean of type {@link Jwt} configured in the context. * *

* can be disabled with @EnableAutoConfiguration(exclude={XsuaaResourceServerJwkAutoConfiguration.class}) or with * property spring.xsuaa.auto = false */ @Configuration @ConditionalOnClass(Jwt.class) @ConditionalOnProperty(prefix = "spring.xsuaa", name = "auto", havingValue = "true", matchIfMissing = true) @AutoConfigureBefore(OAuth2ResourceServerAutoConfiguration.class) // imports OAuth2ResourceServerJwtConfiguration which // specifies JwtDecoder public class XsuaaResourceServerJwkAutoConfiguration { private final Logger logger = LoggerFactory.getLogger(getClass()); @Bean @ConditionalOnBean({ XsuaaServiceConfiguration.class, RestOperations.class }) @ConditionalOnWebApplication(type = Type.SERVLET) @ConditionalOnMissingBean public JwtDecoder xsuaaJwtDecoder(XsuaaServiceConfiguration xsuaaServiceConfiguration, RestOperations xsuaaRestOperations) { logger.debug("auto-configures JwtDecoder using restOperations of type: {}", xsuaaRestOperations); return new XsuaaJwtDecoderBuilder(xsuaaServiceConfiguration) .withRestOperations(xsuaaRestOperations) .build(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy