Jelajahi Sumber

Use direct code import

Issue gh-1231
Steve Riesenberg 2 tahun lalu
induk
melakukan
d45a1fbfce

+ 5 - 1
docs/src/docs/asciidoc/getting-started.adoc

@@ -80,7 +80,11 @@ If you want to customize the default configuration (regardless of whether you're
 These components can be defined as follows:
 
 [[sample.gettingStarted]]
-include::code:SecurityConfig[]
+.SecurityConfig.java
+[source,java]
+----
+include::{docs-java}/sample/gettingStarted/SecurityConfig.java[]
+----
 
 This is a minimal configuration for getting started quickly. To understand what each component is used for, see the following descriptions:
 

+ 36 - 9
docs/src/docs/asciidoc/guides/how-to-jpa.adoc

@@ -146,7 +146,10 @@ The following listing shows the `Client` entity, which is used to persist inform
 
 [[sample.jpa.entity.client]]
 .Client Entity
-include::code:Client[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/entity/client/Client.java[]
+----
 
 [[authorization-entity]]
 === Authorization Entity
@@ -155,7 +158,10 @@ The following listing shows the `Authorization` entity, which is used to persist
 
 [[sample.jpa.entity.authorization]]
 .Authorization Entity
-include::code:Authorization[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/entity/authorization/Authorization.java[]
+----
 
 [[authorization-consent-entity]]
 === Authorization Consent Entity
@@ -164,7 +170,10 @@ The following listing shows the `AuthorizationConsent` entity, which is used to
 
 [[sample.jpa.entity.authorizationConsent]]
 .Authorization Consent Entity
-include::code:AuthorizationConsent[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/entity/authorizationConsent/AuthorizationConsent.java[]
+----
 
 [[create-spring-data-repositories]]
 == Create Spring Data repositories
@@ -182,7 +191,10 @@ The following listing shows the `ClientRepository`, which is able to find a <<cl
 
 [[sample.jpa.repository.client]]
 .Client Repository
-include::code:ClientRepository[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/repository/client/ClientRepository.java[]
+----
 
 [[authorization-repository]]
 === Authorization Repository
@@ -192,7 +204,10 @@ It also allows querying a combination of token fields.
 
 [[sample.jpa.repository.authorization]]
 .Authorization Repository
-include::code:AuthorizationRepository[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/repository/authorization/AuthorizationRepository.java[]
+----
 
 [[authorization-consent-repository]]
 === Authorization Consent Repository
@@ -201,7 +216,10 @@ The following listing shows the `AuthorizationConsentRepository`, which is able
 
 [[sample.jpa.repository.authorizationConsent]]
 .Authorization Consent Repository
-include::code:AuthorizationConsentRepository[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/repository/authorizationConsent/AuthorizationConsentRepository.java[]
+----
 
 [[implement-core-services]]
 == Implement core services
@@ -224,7 +242,10 @@ The following listing shows the `JpaRegisteredClientRepository`, which uses a <<
 
 [[sample.jpa.service.client]]
 .`RegisteredClientRepository` Implementation
-include::code:JpaRegisteredClientRepository[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/service/client/JpaRegisteredClientRepository.java[]
+----
 
 [[authorization-service]]
 === Authorization Service
@@ -233,7 +254,10 @@ The following listing shows the `JpaOAuth2AuthorizationService`, which uses an <
 
 [[sample.jpa.service.authorization]]
 .`OAuth2AuthorizationService` Implementation
-include::code:JpaOAuth2AuthorizationService[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/service/authorization/JpaOAuth2AuthorizationService.java[]
+----
 
 [[authorization-consent-service]]
 === Authorization Consent Service
@@ -242,4 +266,7 @@ The following listing shows the `JpaOAuth2AuthorizationConsentService`, which us
 
 [[sample.jpa.service.authorizationConsent]]
 .`OAuth2AuthorizationConsentService` Implementation
-include::code:JpaOAuth2AuthorizationConsentService[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/jpa/service/authorizationConsent/JpaOAuth2AuthorizationConsentService.java[]
+----

+ 20 - 5
docs/src/docs/asciidoc/guides/how-to-userinfo.adoc

@@ -22,7 +22,10 @@ Before customizing the response, you need to enable the UserInfo endpoint.
 The following listing shows how to enable the {spring-security-reference-base-url}/servlet/oauth2/resource-server/jwt.html[OAuth2 resource server configuration].
 
 [[sample.userinfo]]
-include::code:EnableUserInfoSecurityConfig[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/userinfo/EnableUserInfoSecurityConfig.java[]
+----
 
 TIP: Click on the "Expand folded text" icon in the code sample above to display the full example.
 
@@ -50,7 +53,10 @@ The preferred way to customize the user info response is to add standard claims
 The following listing shows how to add claims to the `id_token`.
 
 [[sample.userinfo.idtoken]]
-include::code:IdTokenCustomizerConfig[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/userinfo/idtoken/IdTokenCustomizerConfig.java[]
+----
 
 This configuration provides the following:
 
@@ -59,7 +65,10 @@ This configuration provides the following:
 
 The following listing shows a custom service for looking up user info in a domain-specific way:
 
-include::code:OidcUserInfoService[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/userinfo/idtoken/OidcUserInfoService.java[]
+----
 
 [[customize-user-info-mapper]]
 === Customize the User Info Mapper
@@ -70,7 +79,10 @@ The mapper implementation receives an instance of `OidcUserInfoAuthenticationCon
 The following listing shows how to use the customization option that is available while working directly with the `OAuth2AuthorizationServerConfigurer`.
 
 [[sample.userinfo.jwt]]
-include::code:JwtUserInfoMapperSecurityConfig[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/userinfo/jwt/JwtUserInfoMapperSecurityConfig.java[]
+----
 
 This configuration maps claims from the access token (which is a JWT when using the xref:{docs-dir}/getting-started.adoc#sample.gettingStarted[Getting Started config]) to populate the user info response and provides the following:
 
@@ -83,6 +95,9 @@ This configuration maps claims from the access token (which is a JWT when using
 The user info mapper is not limited to mapping claims from a JWT, but this is a simple example that demonstrates the customization option.
 Similar to the <<customize-id-token,example shown earlier>> where we customize claims of the ID token, you can customize claims of the access token itself ahead of time, as in the following example:
 
-include::code:JwtTokenCustomizerConfig[]
+[source,java]
+----
+include::{examples-dir}/src/main/java/sample/userinfo/jwt/JwtTokenCustomizerConfig.java[]
+----
 
 Whether you customize the user info response directly or use this example and customize the access token, you can look up information in a database, perform an LDAP query, make a request to another service, or use any other means of obtaining the information you want to be presented in the user info response.