This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
Pojo pojo = new SimplePojo(); | |
// this is a direct method call on the 'pojo' reference | |
pojo.foo(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimplePojo implements Pojo { | |
public void foo() { | |
// this next method invocation is a direct call on the 'this' reference | |
this.bar(); | |
} | |
public void bar() { | |
// some logic... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cem.springnativeexample; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication(proxyBeanMethods = false) | |
public class SpringNativeExampleApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(SpringNativeExampleApplication.class, args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>org.springframework.experimental</groupId> | |
<artifactId>spring-aot-maven-plugin</artifactId> | |
<version>${spring-native.version}</version> | |
<executions> | |
<execution> | |
<id>test-generate</id> | |
<goals> | |
<goal>test-generate</goal> | |
</goals> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-maven-plugin</artifactId> | |
<configuration> | |
<image> | |
<builder>paketobuildpacks/builder:tiny</builder> | |
<env> | |
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE> | |
</env> | |
</image> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>2.4.4</version> | |
<relativePath/> <!-- lookup parent from repository --> | |
</parent> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cem.oauth2.configuration.feign; | |
import com.cem.oauth2.configuration.AuthProperties; | |
import feign.RequestInterceptor; | |
import org.keycloak.OAuth2Constants; | |
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; | |
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cem.oauth2.configuration.resttemplate; | |
import com.cem.oauth2.configuration.AuthProperties; | |
import org.keycloak.OAuth2Constants; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.oauth2.client.OAuth2RestTemplate; | |
import org.springframework.security.oauth2.client.token.AccessTokenProvider; | |
import org.springframework.security.oauth2.client.token.AccessTokenProviderChain; | |
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cem.oauth2.controller; | |
import com.cem.oauth2.service.FeignServiceClient; | |
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.security.access.prepost.PreAuthorize; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.client.RestTemplate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cem.oauth2.configuration; | |
import org.keycloak.adapters.KeycloakConfigResolver; | |
import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; | |
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; | |
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |