├── dio-spring-security ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── spring │ │ │ └── security │ │ │ ├── DioSpringSecurityApplication.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── controller │ │ │ └── WelcomeController.java │ │ │ ├── config │ │ │ └── WebSecurityConfig.java │ │ │ ├── init │ │ │ └── StartApplication.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── dio │ │ └── spring │ │ └── security │ │ └── DioSpringSecurityApplicationTests.java └── pom.xml ├── springboot-web ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springbootweb │ │ │ ├── SpringbootWebApplication.java │ │ │ ├── model │ │ │ └── Usuario.java │ │ │ ├── controller │ │ │ └── UsuarioController.java │ │ │ └── repository │ │ │ └── UsuarioRepository.java │ └── test │ │ └── java │ │ └── dio │ │ └── springbootweb │ │ └── SpringbootWebApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── spring-primeiros-passos ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── MyApplication.java │ │ │ ├── Calculadora.java │ │ │ └── SpringPrimeirosPassosApplication.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.springframework.ide.eclipse.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── .project ├── pom.xml └── .classpath ├── spring-web-security-database ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── spring │ │ │ └── security │ │ │ ├── DioSpringSecurityApplication.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── controller │ │ │ └── WelcomeController.java │ │ │ ├── init │ │ │ └── StartApplication.java │ │ │ ├── config │ │ │ ├── SecurityDatabaseService.java │ │ │ └── WebSecurityConfig.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── dio │ │ └── spring │ │ └── security │ │ └── DioSpringSecurityApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── springboot-web-swagger ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springbootweb │ │ │ ├── SpringbootWebApplication.java │ │ │ ├── model │ │ │ └── Usuario.java │ │ │ ├── controller │ │ │ └── UsuarioController.java │ │ │ ├── repository │ │ │ └── UsuarioRepository.java │ │ │ └── SwaggerConfig.java │ └── test │ │ └── java │ │ └── dio │ │ └── springbootweb │ │ └── SpringbootWebApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── spring-scopes-singleton-prototype ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── app │ │ │ ├── Beans.java │ │ │ ├── Remetente.java │ │ │ └── SistemaMensagem.java │ │ │ └── SpringPrimeirosPassosApplication.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java └── pom.xml ├── spring-web-security-configure-adapter ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── spring │ │ │ └── security │ │ │ ├── DioSpringSecurityApplication.java │ │ │ ├── WelcomeController.java │ │ │ └── WebSecurityConfig.java │ └── test │ │ └── java │ │ └── dio │ │ └── spring │ │ └── security │ │ └── DioSpringSecurityApplicationTests.java └── pom.xml ├── README.md ├── perfil.jpeg ├── spring-data-jpa-hibernate ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── SpringPrimeirosPassosApplication.java │ │ │ └── app │ │ │ ├── SistemaUsuario.java │ │ │ └── model │ │ │ └── Usuario.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.springframework.ide.eclipse.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── .project ├── pom.xml └── .classpath ├── java-interfaces ├── src │ ├── Regiao.java │ ├── LocacaoVeiculo.java │ ├── EstudandoArrays.java │ ├── CadastroCliente.java │ └── Estado.java └── java-interfaces.iml ├── spring-data-jpa-repository ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.springframework.ide.eclipse.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ ├── test │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ └── SpringPrimeirosPassosApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── dio │ │ └── springboot │ │ ├── SpringPrimeirosPassosApplication.java │ │ └── app │ │ ├── SistemaUsuario.java │ │ └── model │ │ └── Usuario.java ├── .project ├── pom.xml └── .classpath ├── spring-properties-value ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.springframework.ide.eclipse.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── SpringPrimeirosPassosApplication.java │ │ │ └── app │ │ │ └── SistemaMensagem.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java ├── .project ├── pom.xml └── .classpath ├── spring-configuration-properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── SpringPrimeirosPassosApplication.java │ │ │ └── app │ │ │ ├── SistemaMensagem.java │ │ │ └── Rementente.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java └── pom.xml ├── dio-spring-data-jpa ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── aula │ │ │ ├── AulaSpringDataJpaApplication.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── StartApp.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── dio │ │ └── aula │ │ └── AulaSpringDataJpaApplicationTests.java └── pom.xml ├── spring-ioc-di-beans-autowired ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── springboot │ │ │ ├── app │ │ │ ├── Beans.java │ │ │ ├── ConversorJson.java │ │ │ └── ViaCepResponse.java │ │ │ └── SpringPrimeirosPassosApplication.java │ └── test │ │ └── java │ │ └── dio │ │ └── springboot │ │ └── SpringPrimeirosPassosApplicationTests.java └── pom.xml ├── dio-spring-data-jpa-exception-handler ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── dio │ │ │ └── aula │ │ │ ├── handler │ │ │ ├── BusinessException.java │ │ │ ├── ResponseError.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── AulaSpringDataJpaApplication.java │ │ │ ├── controller │ │ │ ├── CodigoPostalService.java │ │ │ └── CodigoPostalController.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── StartApp.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── dio │ │ └── aula │ │ └── AulaSpringDataJpaApplicationTests.java └── pom.xml ├── dio-spring-security-jwt ├── src │ ├── test │ │ └── java │ │ │ └── dio │ │ │ └── dio │ │ │ └── spring │ │ │ └── security │ │ │ └── jwt │ │ │ └── DioSpringSecurityJwtApplicationTests.java │ └── main │ │ ├── java │ │ └── dio │ │ │ └── dio │ │ │ └── spring │ │ │ └── security │ │ │ └── jwt │ │ │ ├── DioSpringSecurityJwtApplication.java │ │ │ ├── dtos │ │ │ ├── Sessao.java │ │ │ └── Login.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── controller │ │ │ ├── WelcomeController.java │ │ │ ├── UserController.java │ │ │ └── LoginController.java │ │ │ ├── security │ │ │ ├── SecurityConfig.java │ │ │ ├── JWTObject.java │ │ │ ├── JWTCreator.java │ │ │ ├── JWTFilter.java │ │ │ └── WebSecurityConfig.java │ │ │ ├── service │ │ │ └── UserService.java │ │ │ └── model │ │ │ └── User.java │ │ └── resources │ │ └── application.properties └── pom.xml └── .gitignore /dio-spring-security/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-primeiros-passos/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dio-springboot 2 | Curso de Springboot para a digital Innovation one 3 | -------------------------------------------------------------------------------- /perfil.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/perfil.jpeg -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.show-sql: true -------------------------------------------------------------------------------- /java-interfaces/src/Regiao.java: -------------------------------------------------------------------------------- 1 | public enum Regiao { 2 | NORTE, 3 | NORDESTE, 4 | SUL, 5 | SUDESTE 6 | ; 7 | } 8 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-properties-value/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /spring-properties-value/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-properties-value/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | nome=Digital Innovation One 2 | email=noreply@dio.com.br 3 | telefones=1145651725,1187651343 -------------------------------------------------------------------------------- /spring-primeiros-passos/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-properties-value/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-web/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/springboot-web/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-web-swagger/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/springboot-web-swagger/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-primeiros-passos/src/main/java/dio/springboot/MyApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | public class MyApplication { 4 | private Calculadora calculadora; 5 | } -------------------------------------------------------------------------------- /spring-configuration-properties/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | remetente.nome=NoReply - DIO 2 | remetente.email=noreply@dio.com.br 3 | remetente.telefones=1145651725,1187651343 -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/dio-spring-data-jpa/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-web-security-database/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/spring-web-security-database/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | //https://viacep.com.br/ws/01001000/json/ 3 | //https://mvnrepository.com/artifact/com.google.code.gson/gson/2.8.8 4 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalinnovationone/dio-springboot/HEAD/dio-spring-data-jpa-exception-handler/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /spring-properties-value/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /spring-primeiros-passos/src/main/java/dio/springboot/Calculadora.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | public class Calculadora { 4 | public int somar(int numero1, int numero2){ 5 | return numero1 + numero2; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-interfaces/src/LocacaoVeiculo.java: -------------------------------------------------------------------------------- 1 | public class LocacaoVeiculo { 2 | public static void main(String[] args) { 3 | Estado rj = Estado.RJ; 4 | System.out.println(rj.getNome()); 5 | System.out.println(rj.getSigla()); 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /springboot-web/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /springboot-web-swagger/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-web-security-database/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /java-interfaces/src/EstudandoArrays.java: -------------------------------------------------------------------------------- 1 | public class EstudandoArrays { 2 | public static void main(String[] args) { 3 | String [] alunos = new String[]{"MARCOS","FERNANDA"}; 4 | for(String aluno:alunos){ 5 | System.out.println(aluno); 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/test/java/dio/aula/AulaSpringDataJpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AulaSpringDataJpaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /java-interfaces/src/CadastroCliente.java: -------------------------------------------------------------------------------- 1 | public class CadastroCliente { 2 | public static void main(String[] args) { 3 | Estado sp = Estado.SP; 4 | System.out.println(sp.getNome()); 5 | System.out.println(sp.getSigla()); 6 | Estado ma = Estado.MA; 7 | System.out.println(ma.getRegiao()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /springboot-web/src/test/java/dio/springbootweb/SpringbootWebApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringbootWebApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/test/java/dio/springbootweb/SpringbootWebApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringbootWebApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/test/java/dio/aula/AulaSpringDataJpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AulaSpringDataJpaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-security/src/test/java/dio/spring/security/DioSpringSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DioSpringSecurityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-primeiros-passos/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-properties-value/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-configuration-properties/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/test/java/dio/springboot/SpringPrimeirosPassosApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringPrimeirosPassosApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-web-security-database/src/test/java/dio/spring/security/DioSpringSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DioSpringSecurityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/src/test/java/dio/spring/security/DioSpringSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DioSpringSecurityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/test/java/dio/dio/spring/security/jwt/DioSpringSecurityJwtApplicationTests.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DioSpringSecurityJwtApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/main/java/dio/springboot/app/Beans.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import com.google.gson.Gson; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | public class Beans { 9 | @Bean 10 | public Gson gson(){ 11 | return new Gson(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/handler/BusinessException.java: -------------------------------------------------------------------------------- 1 | package dio.aula.handler; 2 | 3 | public class BusinessException extends RuntimeException { 4 | public BusinessException(String mensagem) { 5 | super(mensagem); 6 | } 7 | public BusinessException(String mensagem, Object ... params) { 8 | super(String.format(mensagem, params)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/main/java/dio/aula/AulaSpringDataJpaApplication.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AulaSpringDataJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AulaSpringDataJpaApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springboot-web/src/main/java/dio/springbootweb/SpringbootWebApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootWebApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootWebApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.show-sql: true 2 | #spring.jpa.hibernate.ddl-auto:update 3 | 4 | ##PostgreSQL Database Connection Properties 5 | #spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 6 | #spring.datasource.driverClassName=org.postgresql.Driver 7 | #spring.datasource.url=jdbc:postgresql://localhost:5432/usuarios_db 8 | #spring.datasource.username=postgres 9 | #spring.datasource.password=postgres -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/java/dio/springbootweb/SpringbootWebApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootWebApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootWebApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/AulaSpringDataJpaApplication.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AulaSpringDataJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AulaSpringDataJpaApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/DioSpringSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DioSpringSecurityApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DioSpringSecurityApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-primeiros-passos/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeirosPassosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/DioSpringSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DioSpringSecurityApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DioSpringSecurityApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeirosPassosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeirosPassosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-properties-value/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeirosPassosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-configuration-properties/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringPrimeirosPassosApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/src/main/java/dio/spring/security/DioSpringSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DioSpringSecurityApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DioSpringSecurityApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /java-interfaces/java-interfaces.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/DioSpringSecurityJwtApplication.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DioSpringSecurityJwtApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DioSpringSecurityJwtApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | security.config.prefix=Bearer 2 | security.config.key=SECRET_KEY 3 | security.config.expiration=3600000 4 | 5 | ##H2 Database Connection Properties 6 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 7 | spring.datasource.driverClassName=org.h2.Driver 8 | spring.datasource.url=jdbc:h2:mem:testdb 9 | spring.datasource.username=sa 10 | spring.datasource.password=sa 11 | spring.jpa.show-sql: true 12 | spring.h2.console.enabled=true 13 | -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/main/java/dio/springboot/app/ConversorJson.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import com.google.gson.Gson; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class ConversorJson { 9 | @Autowired 10 | private Gson gson; 11 | public ViaCepResponse converter(String json ){ 12 | ViaCepResponse response = gson.fromJson(json,ViaCepResponse.class); 13 | return response; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/dtos/Sessao.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.dtos; 2 | 3 | public class Sessao { 4 | private String login; 5 | private String token; 6 | 7 | public String getLogin() { 8 | return login; 9 | } 10 | 11 | public void setLogin(String login) { 12 | this.login = login; 13 | } 14 | 15 | public String getToken() { 16 | return token; 17 | } 18 | 19 | public void setToken(String token) { 20 | this.token = token; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springboot-web/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /springboot-web-swagger/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-web-security-database/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/controller/CodigoPostalService.java: -------------------------------------------------------------------------------- 1 | package dio.aula.controller; 2 | 3 | import dio.aula.handler.BusinessException; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | 7 | @Service 8 | public class CodigoPostalService { 9 | public String buscarCidade(String ibge){ 10 | if(ibge==null || ibge.isEmpty()) 11 | throw new BusinessException("O campo IBGE precisa ser informado"); 12 | else 13 | return "São Paulo"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.repository; 2 | 3 | import dio.spring.security.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface UserRepository extends JpaRepository { 9 | @Query("SELECT e FROM User e JOIN FETCH e.roles WHERE e.username= (:username)") 10 | public User findByUsername(@Param("username") String username); 11 | } 12 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/dtos/Login.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.dtos; 2 | 3 | public class Login { 4 | private String username; 5 | private String password; 6 | 7 | public String getUsername() { 8 | return username; 9 | } 10 | 11 | public void setUsername(String username) { 12 | this.username = username; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.repository; 2 | 3 | import dio.spring.security.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface UserRepository extends JpaRepository { 9 | @Query("SELECT e FROM User e JOIN FETCH e.roles WHERE e.username= (:username)") 10 | public User findByUsername(@Param("username") String username); 11 | } 12 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/controller/CodigoPostalController.java: -------------------------------------------------------------------------------- 1 | package dio.aula.controller; 2 | 3 | import dio.aula.handler.BusinessException; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | @RestController 7 | @RequestMapping("/cep") 8 | public class CodigoPostalController { 9 | @GetMapping("/{ibge}") 10 | public String getCidade(@PathVariable String ibge){ 11 | if(ibge.equals("3550308")) 12 | return "São Paulo"; 13 | else 14 | throw new BusinessException("Não localizamos nenhuma cidade com o código informado."); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /spring-properties-value/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | *.idea/ 5 | *.idea 6 | 7 | # Log file 8 | *.log 9 | 10 | # BlueJ files 11 | *.ctxt 12 | 13 | # Mobile Tools for Java (J2ME) 14 | .mtj.tmp/ 15 | 16 | # Package Files # 17 | *.jar 18 | *.war 19 | *.nar 20 | *.ear 21 | *.zip 22 | *.tar.gz 23 | *.rar 24 | 25 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 26 | hs_err_pid* 27 | /.idea/compiler.xml 28 | /.idea/encodings.xml 29 | /.idea/oficial.iml 30 | /mvnw.cmd 31 | /mvnw 32 | /.idea/modules.xml 33 | /.idea/misc.xml 34 | /.idea/vcs.xml 35 | /.mvn/wrapper/MavenWrapperDownloader.java 36 | target/ 37 | /target 38 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.repository; 2 | 3 | import dio.dio.spring.security.jwt.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface UserRepository extends JpaRepository { 9 | @Query("SELECT e FROM User e JOIN FETCH e.roles WHERE e.username= (:username)") 10 | public User findByUsername(@Param("username") String username); 11 | 12 | boolean existsByUsername(String username); 13 | } 14 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/main/java/dio/springboot/app/Beans.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Scope; 6 | 7 | @Configuration 8 | public class Beans { 9 | @Bean 10 | @Scope("prototype") 11 | public Remetente remetente(){ 12 | System.out.println("CRIANDO UM OBJETO REMETENTE"); 13 | Remetente remetente = new Remetente(); 14 | remetente.setEmail("noreply@dio.com.br"); 15 | remetente.setNome("Digital Innovation One"); 16 | return remetente; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | @RestController 6 | public class WelcomeController { 7 | @GetMapping 8 | public String welcome(){ 9 | return "Welcome to My Spring Boot Web API"; 10 | } 11 | @GetMapping("/users") 12 | public String users() { 13 | return "Authorized user"; 14 | } 15 | @GetMapping("/managers") 16 | public String managers() { 17 | return "Authorized manager"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/src/main/java/dio/springboot/app/SistemaUsuario.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.stereotype.Component; 5 | 6 | import dio.springboot.app.model.Usuario; 7 | 8 | @Component 9 | public class SistemaUsuario implements CommandLineRunner { 10 | 11 | @Override 12 | public void run(String... args) throws Exception { 13 | Usuario usuario = new Usuario(); 14 | usuario.setEmail("gleyson@dio.com.br"); 15 | usuario.setLogin("gleyson"); 16 | usuario.setNomeCompleto("GLEYSON SAMPAIO"); 17 | usuario.setSenha("diospringjpa"); 18 | //repositório de persistência ?? 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-interfaces/src/Estado.java: -------------------------------------------------------------------------------- 1 | public enum Estado { 2 | SP("sp","SAO PAULO",Regiao.SUDESTE), 3 | RJ("rj","RIO DE JANEIRO", Regiao.SUDESTE), 4 | MA("ma","MARANHÃO",Regiao.NORDESTE) 5 | ; 6 | private String nome; 7 | private String sigla; 8 | private Regiao regiao; 9 | 10 | private Estado(String sigla,String nome, Regiao regiao){ 11 | this.sigla=sigla; 12 | this.nome = nome; 13 | this.regiao = regiao; 14 | } 15 | public String getNome() { 16 | return nome; 17 | } 18 | 19 | 20 | public String getSigla() { 21 | return sigla; 22 | } 23 | 24 | public Regiao getRegiao() { 25 | return regiao; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.controller; 2 | 3 | import org.springframework.security.access.prepost.PreAuthorize; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class WelcomeController { 9 | @GetMapping 10 | public String welcome(){ 11 | return "Welcome to My Spring Boot Web API"; 12 | } 13 | @GetMapping("/users") 14 | public String users() { 15 | return "Authorized user"; 16 | } 17 | @GetMapping("/managers") 18 | public String managers() { 19 | return "Authorized manager"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/src/main/java/dio/spring/security/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.springframework.security.access.prepost.PreAuthorize; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class WelcomeController { 9 | @GetMapping 10 | public String welcome(){ 11 | return "Welcome to My Spring Boot Web API"; 12 | } 13 | @GetMapping("/users") 14 | public String users() { 15 | return "Authorized user"; 16 | } 17 | @GetMapping("/managers") 18 | public String managers() { 19 | return "Authorized manager"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/main/java/dio/aula/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package dio.aula.repository; 2 | 3 | import dio.aula.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | import java.util.List; 9 | 10 | public interface UserRepository extends JpaRepository { 11 | //Query Method 12 | List findByNameContaining(String name); 13 | 14 | //Query Method 15 | User findByUsername(String username); 16 | 17 | //Query Override 18 | @Query("SELECT u FROM User u WHERE u.name LIKE %:name%") 19 | List filtrarPorNome(@Param("name") String name); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.controller; 2 | 3 | import org.springframework.security.access.prepost.PreAuthorize; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class WelcomeController { 9 | @GetMapping 10 | public String welcome(){ 11 | return "Welcome to My Spring Boot Web API"; 12 | } 13 | @GetMapping("/users") 14 | public String users() { 15 | return "Authorized user"; 16 | } 17 | @GetMapping("/managers") 18 | public String managers() { 19 | return "Authorized manager"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/main/java/dio/springboot/app/Remetente.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | public class Remetente { 4 | private String nome; 5 | private String email; 6 | 7 | public String getNome() { 8 | return nome; 9 | } 10 | 11 | public void setNome(String nome) { 12 | this.nome = nome; 13 | } 14 | 15 | public String getEmail() { 16 | return email; 17 | } 18 | 19 | public void setEmail(String email) { 20 | this.email = email; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "Remetente{" + 26 | "nome='" + nome + '\'' + 27 | ", email='" + email + '\'' + 28 | '}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package dio.aula.repository; 2 | 3 | import dio.aula.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | import java.util.List; 9 | 10 | public interface UserRepository extends JpaRepository { 11 | //Query Method 12 | List findByNameContaining(String name); 13 | 14 | //Query Method 15 | User findByUsername(String username); 16 | 17 | //Query Override 18 | @Query("SELECT u FROM User u WHERE u.name LIKE %:name%") 19 | List filtrarPorNome(@Param("name") String name); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/main/java/dio/springboot/app/SistemaMensagem.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class SistemaMensagem { 8 | @Autowired 9 | private Remetente noreply; 10 | @Autowired 11 | private Remetente techTeam; 12 | public void enviarConfirmacaoCadastro(){ 13 | System.out.println(noreply); 14 | System.out.println("Seu cadastro foi aprovado"); 15 | } 16 | public void enviarMensagemBoasVindas(){ 17 | techTeam.setEmail("tech@dio.com.br"); 18 | System.out.println(techTeam); 19 | System.out.println("Bem-vindo à Tech Elite"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/security/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.security; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ConfigurationProperties(prefix = "security.config") 8 | public class SecurityConfig { 9 | public static String PREFIX; 10 | public static String KEY; 11 | public static Long EXPIRATION; 12 | 13 | public void setPrefix(String prefix){ 14 | PREFIX = prefix; 15 | } 16 | public void setKey(String key){ 17 | KEY = key; 18 | } 19 | public void setExpiration(Long expiration){ 20 | EXPIRATION = expiration; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-configuration-properties/src/main/java/dio/springboot/app/SistemaMensagem.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public class SistemaMensagem implements CommandLineRunner { 12 | @Autowired 13 | private Rementente rementente; 14 | @Override 15 | public void run(String... args) throws Exception { 16 | System.out.println("Mensagem enviada por: " + rementente.getNome() 17 | + "\nE-mail:" + rementente.getEmail() + "\nCom telefones para contato: " 18 | + rementente.getTelefones()); 19 | System.out.println("Seu cadastro foi aprovado"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.controller; 2 | 3 | import dio.dio.spring.security.jwt.model.User; 4 | import dio.dio.spring.security.jwt.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("/users") 13 | public class UserController { 14 | @Autowired 15 | private UserService service; 16 | @PostMapping 17 | public void postUser(@RequestBody User user){ 18 | service.createUser(user); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/service/UserService.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.service; 2 | 3 | import dio.dio.spring.security.jwt.model.User; 4 | import dio.dio.spring.security.jwt.repository.UserRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.crypto.password.PasswordEncoder; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class UserService { 11 | @Autowired 12 | private UserRepository repository; 13 | @Autowired 14 | private PasswordEncoder encoder; 15 | public void createUser(User user){ 16 | String pass = user.getPassword(); 17 | //criptografando antes de salvar no banco 18 | user.setPassword(encoder.encode(pass)); 19 | repository.save(user); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import dio.springboot.app.SistemaMensagem; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @SpringBootApplication 10 | public class SpringPrimeirosPassosApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 14 | } 15 | @Bean 16 | public CommandLineRunner run(SistemaMensagem sistema) throws Exception { 17 | return args -> { 18 | sistema.enviarConfirmacaoCadastro(); 19 | sistema.enviarMensagemBoasVindas(); 20 | sistema.enviarConfirmacaoCadastro(); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/java/dio/springbootweb/model/Usuario.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.model; 2 | 3 | public class Usuario { 4 | private String login; 5 | private String password; 6 | public Usuario() {} 7 | public Usuario(String login, String password) { 8 | this.login = login; 9 | this.password = password; 10 | } 11 | public String getLogin() { 12 | return login; 13 | } 14 | public void setLogin(String login) { 15 | this.login = login; 16 | } 17 | public String getPassword() { 18 | return password; 19 | } 20 | public void setPassword(String password) { 21 | this.password = password; 22 | } 23 | @Override 24 | public String toString() { 25 | return "User{" + 26 | "login='" + login + '\'' + 27 | ", password='" + password + '\'' + 28 | '}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/handler/ResponseError.java: -------------------------------------------------------------------------------- 1 | package dio.aula.handler; 2 | 3 | import java.util.Date; 4 | 5 | public class ResponseError { 6 | private Date timestamp = new Date(); 7 | private String status = "error"; 8 | private int statusCode = 400; 9 | private String error; 10 | 11 | public String getError() { 12 | return error; 13 | } 14 | public void setError(String error) { 15 | this.error = error; 16 | } 17 | 18 | public Date getTimestamp() { 19 | return timestamp; 20 | } 21 | public String getStatus() { 22 | return status; 23 | } 24 | 25 | public void setStatus(String status) { 26 | this.status = status; 27 | } 28 | 29 | public int getStatusCode() { 30 | return statusCode; 31 | } 32 | 33 | public void setStatusCode(int statusCode) { 34 | this.statusCode = statusCode; 35 | } 36 | } -------------------------------------------------------------------------------- /springboot-web/src/main/java/dio/springbootweb/model/Usuario.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.model; 2 | 3 | public class Usuario { 4 | private String login; 5 | private String password; 6 | 7 | public Usuario() { 8 | } 9 | 10 | public Usuario(String login, String password) { 11 | this.login = login; 12 | this.password = password; 13 | } 14 | 15 | public String getLogin() { 16 | return login; 17 | } 18 | 19 | public void setLogin(String login) { 20 | this.login = login; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | public void setPassword(String password) { 28 | this.password = password; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "User{" + 34 | "login='" + login + '\'' + 35 | ", password='" + password + '\'' + 36 | '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-properties-value/src/main/java/dio/springboot/app/SistemaMensagem.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class SistemaMensagem implements CommandLineRunner { 13 | @Value("${name:NoReply-DIO}") 14 | private String nome; 15 | @Value("${email}") 16 | private String email; 17 | @Value("${telefones}") 18 | private List telefones = 19 | new ArrayList<>(Arrays.asList(new Long[]{11956781254L})); 20 | 21 | @Override 22 | public void run(String... args) throws Exception { 23 | System.out.println("Mensagem enviada por: " + nome 24 | + "\nE-mail:" + email 25 | + "\nCom telefones para contato: " + telefones); 26 | System.out.println("Seu cadastro foi aprovado"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/src/main/java/dio/springboot/app/model/Usuario.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app.model; 2 | 3 | public class Usuario { 4 | private Integer id; 5 | 6 | private String nomeCompleto; 7 | 8 | private String email; 9 | 10 | private String login; 11 | 12 | private String senha; 13 | 14 | public String getNomeCompleto() { 15 | return nomeCompleto; 16 | } 17 | 18 | public void setNomeCompleto(String nomeCompleto) { 19 | this.nomeCompleto = nomeCompleto; 20 | } 21 | 22 | public String getEmail() { 23 | return email; 24 | } 25 | 26 | public void setEmail(String email) { 27 | this.email = email; 28 | } 29 | 30 | public String getLogin() { 31 | return login; 32 | } 33 | 34 | public void setLogin(String login) { 35 | this.login = login; 36 | } 37 | 38 | public String getSenha() { 39 | return senha; 40 | } 41 | 42 | public void setSenha(String senha) { 43 | this.senha = senha; 44 | } 45 | 46 | public Integer getId() { 47 | return id; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring-properties-value 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.babel.editor.rbeBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jdt.core.javanature 31 | org.eclipse.m2e.core.maven2Nature 32 | com.jaspersoft.studio.babel.editor.rbeNature 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring-properties-value 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.babel.editor.rbeBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jdt.core.javanature 31 | org.eclipse.m2e.core.maven2Nature 32 | com.jaspersoft.studio.babel.editor.rbeNature 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring-primeiros-passos 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.babel.editor.rbeBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jdt.core.javanature 31 | org.eclipse.m2e.core.maven2Nature 32 | com.jaspersoft.studio.babel.editor.rbeNature 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-properties-value/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring-properties-value 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.babel.editor.rbeBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jdt.core.javanature 31 | org.eclipse.m2e.core.maven2Nature 32 | com.jaspersoft.studio.babel.editor.rbeNature 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/main/java/dio/springboot/SpringPrimeirosPassosApplication.java: -------------------------------------------------------------------------------- 1 | package dio.springboot; 2 | 3 | import com.google.gson.Gson; 4 | import dio.springboot.app.ConversorJson; 5 | import dio.springboot.app.ViaCepResponse; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Bean; 10 | 11 | @SpringBootApplication 12 | public class SpringPrimeirosPassosApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringPrimeirosPassosApplication.class, args); 16 | } 17 | @Bean 18 | public CommandLineRunner run(ConversorJson conversor) throws Exception { 19 | return args -> { 20 | String json = "{\"cep\": \"01001-000\",\"logradouro\": \"Praça da Sé\",\"localidade\": \"São Paulo\"}"; 21 | ViaCepResponse response = conversor.converter(json); 22 | System.out.println("Dados do CEP: " + response); 23 | }; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-configuration-properties/src/main/java/dio/springboot/app/Rementente.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | @Configuration 9 | @ConfigurationProperties(prefix = "remetente") 10 | public class Rementente { 11 | private String nome; 12 | private String email; 13 | private List telefones; 14 | 15 | public String getNome() { 16 | return nome; 17 | } 18 | 19 | public void setNome(String nome) { 20 | this.nome = nome; 21 | } 22 | 23 | public String getEmail() { 24 | return email; 25 | } 26 | 27 | public void setEmail(String email) { 28 | this.email = email; 29 | } 30 | 31 | public List getTelefones() { 32 | return telefones; 33 | } 34 | 35 | public void setTelefones(List telefones) { 36 | this.telefones = telefones; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/main/java/dio/aula/StartApp.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import dio.aula.model.User; 4 | import dio.aula.repository.UserRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.List; 10 | 11 | @Component 12 | public class StartApp implements CommandLineRunner { 13 | @Autowired 14 | private UserRepository repository; 15 | @Override 16 | public void run(String... args) throws Exception { 17 | List users = repository.findByNameContaining("GLEYSON"); 18 | for(User u: users){ 19 | System.out.println(u); 20 | } 21 | } 22 | private void insertUser(){ 23 | User user = new User(); 24 | user.setName("GABRIEL NUNES"); 25 | user.setUsername("gabriel"); 26 | user.setPassword("santos"); 27 | repository.save(user); 28 | 29 | for(User u: repository.findAll()){ 30 | System.out.println(u); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/src/main/java/dio/springboot/app/ViaCepResponse.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | public class ViaCepResponse { 4 | private String cep; 5 | private String logradouro; 6 | private String localidade; 7 | 8 | public String getCep() { 9 | return cep; 10 | } 11 | 12 | public void setCep(String cep) { 13 | this.cep = cep; 14 | } 15 | 16 | public String getLogradouro() { 17 | return logradouro; 18 | } 19 | 20 | public void setLogradouro(String logradouro) { 21 | this.logradouro = logradouro; 22 | } 23 | 24 | public String getLocalidade() { 25 | return localidade; 26 | } 27 | 28 | public void setLocalidade(String localidade) { 29 | this.localidade = localidade; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "ViaCepResponse{" + 35 | "cep='" + cep + '\'' + 36 | ", logradouro='" + logradouro + '\'' + 37 | ", localidade='" + localidade + '\'' + 38 | '}'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/StartApp.java: -------------------------------------------------------------------------------- 1 | package dio.aula; 2 | 3 | import dio.aula.model.User; 4 | import dio.aula.repository.UserRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.List; 10 | 11 | @Component 12 | public class StartApp implements CommandLineRunner { 13 | @Autowired 14 | private UserRepository repository; 15 | @Override 16 | public void run(String... args) throws Exception { 17 | List users = repository.findByNameContaining("GLEYSON"); 18 | for(User u: users){ 19 | System.out.println(u); 20 | } 21 | } 22 | private void insertUser(){ 23 | User user = new User(); 24 | user.setName("GABRIEL NUNES"); 25 | user.setUsername("gabriel"); 26 | user.setPassword("santos"); 27 | repository.save(user); 28 | 29 | for(User u: repository.findAll()){ 30 | System.out.println(u); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /springboot-web/src/main/java/dio/springbootweb/controller/UsuarioController.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.controller; 2 | 3 | import dio.springbootweb.model.Usuario; 4 | import dio.springbootweb.repository.UsuarioRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.util.List; 9 | 10 | @RestController 11 | public class UsuarioController { 12 | @Autowired 13 | private UsuarioRepository repository; 14 | 15 | @PostMapping("/usuarios") 16 | public void post(@RequestBody Usuario usuario){ 17 | repository.save(usuario); 18 | } 19 | @PutMapping("/usuarios") 20 | public void put(@RequestBody Usuario usuario){ 21 | repository.update(usuario); 22 | } 23 | @GetMapping("/usuarios") 24 | public List getAll(){ 25 | return repository.listAll(); 26 | } 27 | @GetMapping("/usuario/{id}") 28 | public Usuario getOne(@PathVariable("id") Integer id){ 29 | return repository.finById(id); 30 | } 31 | @DeleteMapping("/usuarios/{id}") 32 | public void delete(@PathVariable("id") Integer id){ 33 | repository.remove(id); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/java/dio/springbootweb/controller/UsuarioController.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.controller; 2 | 3 | import dio.springbootweb.model.Usuario; 4 | import dio.springbootweb.repository.UsuarioRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.util.List; 9 | 10 | @RestController 11 | public class UsuarioController { 12 | @Autowired 13 | private UsuarioRepository repository; 14 | 15 | @PostMapping("/usuarios") 16 | public void post(@RequestBody Usuario usuario){ 17 | repository.save(usuario); 18 | } 19 | @PutMapping("/usuarios") 20 | public void put(@RequestBody Usuario usuario){ 21 | repository.update(usuario); 22 | } 23 | @GetMapping("/usuarios") 24 | public List getAll(){ 25 | return repository.listAll(); 26 | } 27 | @GetMapping("/usuario/{id}") 28 | public Usuario getOne(@PathVariable("id") Integer id){ 29 | return repository.finById(id); 30 | } 31 | @DeleteMapping("/usuarios/{id}") 32 | public void delete(@PathVariable("id") Integer id){ 33 | repository.remove(id); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/src/main/java/dio/springboot/app/SistemaUsuario.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.stereotype.Component; 5 | 6 | import dio.springboot.app.model.Usuario; 7 | 8 | @Component 9 | public class SistemaUsuario implements CommandLineRunner { 10 | @Override 11 | public void run(String... args) throws Exception { 12 | Usuario gleyson = criarUsuarioGleyson(); 13 | Usuario admin = criarUsuarioAdmin(); 14 | 15 | Iterable usuarios = null; 16 | usuarios.forEach(u->System.out.println(u.getNomeCompleto() + " - " + u.getLogin())); 17 | 18 | } 19 | private Usuario criarUsuarioGleyson() { 20 | Usuario usuario = new Usuario(); 21 | usuario.setEmail("gleyson@dio.com.br"); 22 | usuario.setLogin("gleyson"); 23 | usuario.setNomeCompleto("GLEYSON SAMPAIO"); 24 | usuario.setSenha("diospringjpa"); 25 | return usuario; 26 | } 27 | private Usuario criarUsuarioAdmin() { 28 | Usuario usuario = new Usuario(); 29 | usuario.setEmail("admin@dio.com.br"); 30 | usuario.setLogin("admin"); 31 | usuario.setNomeCompleto("ADMINISTRADOR"); 32 | usuario.setSenha("masterpass"); 33 | return usuario; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.http.HttpMethod; 5 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 9 | 10 | 11 | @Configuration 12 | @EnableWebSecurity 13 | @EnableGlobalMethodSecurity(prePostEnabled = true) 14 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 15 | @Override 16 | protected void configure(HttpSecurity http) throws Exception { 17 | http.authorizeRequests() 18 | .antMatchers("/").permitAll() 19 | .antMatchers(HttpMethod.POST,"/login").permitAll() 20 | .antMatchers("/managers").hasAnyRole("MANAGERS") 21 | .antMatchers("/users").hasAnyRole("USERS","MANAGERS") 22 | .anyRequest().authenticated().and().httpBasic(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/security/JWTObject.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.security; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | public class JWTObject { 8 | private String subject; //nome do usuario 9 | private Date issuedAt; //data de criação do token 10 | private Date expiration; // data de expiração do token 11 | private List roles; //perfis de acesso 12 | 13 | public String getSubject() { 14 | return subject; 15 | } 16 | 17 | public void setSubject(String subject) { 18 | this.subject = subject; 19 | } 20 | 21 | public Date getIssuedAt() { 22 | return issuedAt; 23 | } 24 | 25 | public void setIssuedAt(Date issuedAt) { 26 | this.issuedAt = issuedAt; 27 | } 28 | 29 | public Date getExpiration() { 30 | return expiration; 31 | } 32 | 33 | public void setExpiration(Date expiration) { 34 | this.expiration = expiration; 35 | } 36 | 37 | public List getRoles() { 38 | return roles; 39 | } 40 | 41 | public void setRoles(List roles) { 42 | this.roles = roles; 43 | } 44 | 45 | public void setRoles(String... roles){ 46 | this.roles = Arrays.asList(roles); 47 | } 48 | } -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/init/StartApplication.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.init; 2 | import dio.spring.security.model.User; 3 | import dio.spring.security.repository.UserRepository; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | @Component 10 | public class StartApplication implements CommandLineRunner { 11 | @Autowired 12 | private UserRepository repository; 13 | @Transactional 14 | @Override 15 | public void run(String... args) throws Exception { 16 | User user = repository.findByUsername("admin"); 17 | if(user==null){ 18 | user = new User(); 19 | user.setName("ADMIN"); 20 | user.setUsername("admin"); 21 | user.setPassword("master123"); 22 | user.getRoles().add("MANAGERS"); 23 | repository.save(user); 24 | } 25 | user = repository.findByUsername("user"); 26 | if(user ==null){ 27 | user = new User(); 28 | user.setName("USER"); 29 | user.setUsername("user"); 30 | user.setPassword("user123"); 31 | user.getRoles().add("USERS"); 32 | repository.save(user); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/init/StartApplication.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.init; 2 | import dio.spring.security.model.User; 3 | import dio.spring.security.repository.UserRepository; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | @Component 10 | public class StartApplication implements CommandLineRunner { 11 | @Autowired 12 | private UserRepository repository; 13 | @Transactional 14 | @Override 15 | public void run(String... args) throws Exception { 16 | User user = repository.findByUsername("admin"); 17 | if(user==null){ 18 | user = new User(); 19 | user.setName("ADMIN"); 20 | user.setUsername("admin"); 21 | user.setPassword("master123"); 22 | user.getRoles().add("MANAGERS"); 23 | repository.save(user); 24 | } 25 | user = repository.findByUsername("user"); 26 | if(user ==null){ 27 | user = new User(); 28 | user.setName("USER"); 29 | user.setUsername("user"); 30 | user.setPassword("user123"); 31 | user.getRoles().add("USERS"); 32 | repository.save(user); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /dio-spring-data-jpa/src/main/java/dio/aula/model/User.java: -------------------------------------------------------------------------------- 1 | package dio.aula.model; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | @Table(name = "tab_user") 7 | public class User { 8 | @Id 9 | @GeneratedValue(strategy = GenerationType.IDENTITY) 10 | @Column(name = "user_id") 11 | private Integer id; 12 | @Column(length = 50, nullable = false) 13 | private String name; 14 | @Column(length = 20, nullable = false) 15 | private String username; 16 | @Column(length = 100, nullable = false) 17 | private String password; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getUsername() { 28 | return username; 29 | } 30 | 31 | public void setUsername(String username) { 32 | this.username = username; 33 | } 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | public void setPassword(String password) { 40 | this.password = password; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "User{" + 46 | "id=" + id + 47 | ", name='" + name + '\'' + 48 | ", username='" + username + '\'' + 49 | ", password='" + password + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /springboot-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | springboot-web 13 | 0.0.1-SNAPSHOT 14 | springboot-web 15 | Modelo de um web services baseado em REST 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/model/User.java: -------------------------------------------------------------------------------- 1 | package dio.aula.model; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | @Table(name = "tab_user") 7 | public class User { 8 | @Id 9 | @GeneratedValue(strategy = GenerationType.IDENTITY) 10 | @Column(name = "user_id") 11 | private Integer id; 12 | @Column(length = 50, nullable = false) 13 | private String name; 14 | @Column(length = 20, nullable = false) 15 | private String username; 16 | @Column(length = 100, nullable = false) 17 | private String password; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getUsername() { 28 | return username; 29 | } 30 | 31 | public void setUsername(String username) { 32 | this.username = username; 33 | } 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | public void setPassword(String password) { 40 | this.password = password; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "User{" + 46 | "id=" + id + 47 | ", name='" + name + '\'' + 48 | ", username='" + username + '\'' + 49 | ", password='" + password + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-primeiros-passos/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-primeiros-passos 13 | 0.0.1-SNAPSHOT 14 | spring-primeiros-passos 15 | Primeiros passos com Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-properties-value/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-properties-value 13 | 0.0.1-SNAPSHOT 14 | spring-properties-value 15 | Spring Boot Application Properties Value 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-data-jpa-hibernate 13 | 0.0.1-SNAPSHOT 14 | spring-data-jpa-hibernate 15 | Spring Boot Application Data JPA - HIBERNATE 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/java/dio/springbootweb/repository/UsuarioRepository.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.repository; 2 | 3 | import dio.springbootweb.model.Usuario; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Repository 10 | public class UsuarioRepository { 11 | public void save(Usuario usuario){ 12 | System.out.println("SAVE - Recebendo o usuário na camada de repositório"); 13 | System.out.println(usuario); 14 | } 15 | public void update(Usuario usuario){ 16 | System.out.println("UPDATE - Recebendo o usuário na camada de repositório"); 17 | System.out.println(usuario); 18 | } 19 | public void remove(Integer id){ 20 | System.out.println(String.format("DELETE/id - Recebendo o id: %d para excluir um usuário", id)); 21 | System.out.println(id); 22 | } 23 | public List listAll(){ 24 | System.out.println("LIST - Listando os usários do sistema"); 25 | List usuarios = new ArrayList<>(); 26 | usuarios.add(new Usuario("gleyson","password")); 27 | usuarios.add(new Usuario("frank","masterpass")); 28 | return usuarios; 29 | } 30 | public Usuario finById(Integer id){ 31 | System.out.println(String.format("FIND/id - Recebendo o id: %d para localizar um usuário", id)); 32 | return new Usuario("gleyson","password"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /springboot-web/src/main/java/dio/springbootweb/repository/UsuarioRepository.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb.repository; 2 | 3 | import dio.springbootweb.model.Usuario; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | import java.util.stream.Collectors; 11 | 12 | @Repository 13 | public class UsuarioRepository { 14 | 15 | public void save(Usuario usuario){ 16 | System.out.println("SAVE - Recebendo o usuário na camada de repositório"); 17 | System.out.println(usuario); 18 | } 19 | public void update(Usuario usuario){ 20 | System.out.println("UPDATE - Recebendo o usuário na camada de repositório"); 21 | System.out.println(usuario); 22 | } 23 | public void remove(Integer id){ 24 | System.out.println(String.format("DELETE/id - Recebendo o id: %d para excluir um usuário", id)); 25 | System.out.println(id); 26 | } 27 | public List listAll(){ 28 | List usuarios = new ArrayList<>(); 29 | usuarios.add(new Usuario("gleyson","password")); 30 | usuarios.add(new Usuario("frank","masterpass")); 31 | return usuarios; 32 | } 33 | public Usuario finById(Integer id){ 34 | System.out.println(String.format("GET/id - Recebendo o id: %d para localizar um usuário", id)); 35 | return new Usuario("gleyson","password"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-configuration-properties/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-configuration-properties 13 | 0.0.1-SNAPSHOT 14 | spring-configuration-properties 15 | Spring Boot Application Configuration Properties 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/src/main/java/dio/springboot/app/model/Usuario.java: -------------------------------------------------------------------------------- 1 | package dio.springboot.app.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name = "tab_usuario") 12 | public class Usuario { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private Integer id; 16 | 17 | @Column(name = "nome_completo", length = 50, nullable = false) 18 | private String nomeCompleto; 19 | 20 | private String email; 21 | 22 | @Column(length = 20, nullable = false) 23 | private String login; 24 | 25 | @Column(length = 100, nullable = false) 26 | private String senha; 27 | 28 | public String getNomeCompleto() { 29 | return nomeCompleto; 30 | } 31 | 32 | public void setNomeCompleto(String nomeCompleto) { 33 | this.nomeCompleto = nomeCompleto; 34 | } 35 | 36 | public String getEmail() { 37 | return email; 38 | } 39 | 40 | public void setEmail(String email) { 41 | this.email = email; 42 | } 43 | 44 | public String getLogin() { 45 | return login; 46 | } 47 | 48 | public void setLogin(String login) { 49 | this.login = login; 50 | } 51 | 52 | public String getSenha() { 53 | return senha; 54 | } 55 | 56 | public void setSenha(String senha) { 57 | this.senha = senha; 58 | } 59 | 60 | public Integer getId() { 61 | return id; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /dio-spring-data-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | access-control 13 | 0.0.1-SNAPSHOT 14 | access-control 15 | Demo project for Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | 26 | org.postgresql 27 | postgresql 28 | runtime 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-data-jpa-repository 13 | 0.0.1-SNAPSHOT 14 | spring-data-jpa-repository 15 | Spring Boot Application Data JPA - Repository 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-data-jpa 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/config/SecurityDatabaseService.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.config; 2 | import dio.spring.security.model.User; 3 | import dio.spring.security.repository.UserRepository; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.core.GrantedAuthority; 6 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | @Service 15 | public class SecurityDatabaseService implements UserDetailsService { 16 | @Autowired 17 | private UserRepository userRepository; 18 | @Override 19 | public UserDetails loadUserByUsername(String username) { 20 | User userEntity = userRepository.findByUsername(username); 21 | if (userEntity == null) { 22 | throw new UsernameNotFoundException(username); 23 | } 24 | Set authorities = new HashSet(); 25 | userEntity.getRoles().forEach(role -> { 26 | authorities.add(new SimpleGrantedAuthority("ROLE_" + role)); 27 | }); 28 | UserDetails user = new org.springframework.security.core.userdetails.User(userEntity.getUsername(), 29 | userEntity.getPassword(), 30 | authorities); 31 | return user; 32 | } 33 | } -------------------------------------------------------------------------------- /spring-ioc-di-beans-autowired/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | spring-ioc-di-beans-autowired 13 | 0.0.1-SNAPSHOT 14 | spring-ioc-di-beans-autowired 15 | Spring Boot IoC - DI - Beans - Autowired 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | com.google.code.gson 34 | gson 35 | 2.8.8 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-scopes-singleton-prototype/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.5.4 10 | 11 | 12 | dio 13 | spring-scopes-singleton-prototype 14 | 0.0.1-SNAPSHOT 15 | spring-scopes-singleton-prototype 16 | Spring Boot Scopes Singleton Prototype 17 | 18 | 1.8 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | 33 | 34 | com.google.code.gson 35 | gson 36 | 2.8.8 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/model/User.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | @Table(name = "tab_user") 9 | public class User { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | @Column(name = "id_user") 13 | private Integer id; 14 | @Column(length = 50, nullable = false) 15 | private String name; 16 | @Column(length = 20, nullable = false) 17 | private String username; 18 | @Column(length = 100, nullable = false) 19 | private String password; 20 | @ElementCollection(fetch = FetchType.EAGER) 21 | @CollectionTable(name = "tab_user_roles", joinColumns = @JoinColumn(name = "user_id")) 22 | @Column(name = "role_id") 23 | private List roles = new ArrayList<>(); 24 | 25 | public Integer getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Integer id) { 30 | this.id = id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public String getUsername() { 42 | return username; 43 | } 44 | 45 | public void setUsername(String username) { 46 | this.username = username; 47 | } 48 | 49 | public String getPassword() { 50 | return password; 51 | } 52 | 53 | public void setPassword(String password) { 54 | this.password = password; 55 | } 56 | 57 | public List getRoles() { 58 | return roles; 59 | } 60 | 61 | public void setRoles(List roles) { 62 | this.roles = roles; 63 | } 64 | } -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.5 9 | 10 | 11 | dio 12 | dio-spring-security 13 | 0.0.1-SNAPSHOT 14 | spring-web-security-configure-adapter 15 | Dio Spring Security 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-security 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-test 32 | test 33 | 34 | 35 | org.springframework.security 36 | spring-security-test 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | aula-spring-data-jpa-exception-handler 13 | 0.0.1-SNAPSHOT 14 | aula-spring-data-jpa 15 | Demo project for Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | 26 | org.postgresql 27 | postgresql 28 | runtime 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /spring-web-security-configure-adapter/src/main/java/dio/spring/security/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.http.HttpMethod; 5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 6 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | 11 | 12 | @Configuration 13 | @EnableWebSecurity 14 | @EnableGlobalMethodSecurity(prePostEnabled = true) 15 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 16 | @Override 17 | protected void configure(HttpSecurity http) throws Exception { 18 | http.authorizeRequests() 19 | .antMatchers("/").permitAll() 20 | .antMatchers(HttpMethod.POST,"/login").permitAll() 21 | .antMatchers("/managers").hasAnyRole("MANAGERS") 22 | .antMatchers("/users").hasAnyRole("USERS","MANAGERS") 23 | .anyRequest().authenticated().and().formLogin(); 24 | } 25 | @Override 26 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 27 | auth.inMemoryAuthentication() 28 | .withUser("user") 29 | .password("{noop}user123") 30 | .roles("USERS") 31 | .and() 32 | .withUser("admin") 33 | .password("{noop}master123") 34 | .roles("MANAGERS"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /springboot-web-swagger/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | dio 12 | springboot-web-swagger 13 | 0.0.1-SNAPSHOT 14 | springboot-web-swagger 15 | Modelo de um web services baseado em REST com Swagger 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | io.springfox 34 | springfox-swagger2 35 | 2.9.2 36 | 37 | 38 | io.springfox 39 | springfox-swagger-ui 40 | 2.9.2 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /dio-spring-security/src/main/java/dio/spring/security/model/User.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | @Table(name = "tab_user") 9 | public class User { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | @Column(name = "id_user") 13 | private Integer id; 14 | @Column(length = 50, nullable = false) 15 | private String name; 16 | @Column(length = 20, nullable = false) 17 | private String username; 18 | @Column(length = 100, nullable = false) 19 | private String password; 20 | @ElementCollection(fetch = FetchType.EAGER) 21 | @CollectionTable(name = "tab_user_roles", joinColumns = @JoinColumn(name = "user_id")) 22 | @Column(name = "role_id") 23 | private List roles = new ArrayList<>(); 24 | 25 | public User(){ 26 | 27 | } 28 | public User(String username){ 29 | this.username = username; 30 | } 31 | 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Integer id) { 37 | this.id = id; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getUsername() { 49 | return username; 50 | } 51 | 52 | public void setUsername(String username) { 53 | this.username = username; 54 | } 55 | 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | public void setPassword(String password) { 61 | this.password = password; 62 | } 63 | 64 | public List getRoles() { 65 | return roles; 66 | } 67 | 68 | public void setRoles(List roles) { 69 | this.roles = roles; 70 | } 71 | } -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/model/User.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | @Table(name = "tab_user") 9 | public class User { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | @Column(name = "id_user") 13 | private Integer id; 14 | @Column(length = 50, nullable = false) 15 | private String name; 16 | @Column(length = 20, nullable = false) 17 | private String username; 18 | @Column(length = 100, nullable = false) 19 | private String password; 20 | @ElementCollection(fetch = FetchType.EAGER) 21 | @CollectionTable(name = "tab_user_roles", joinColumns = @JoinColumn(name = "user_id")) 22 | @Column(name = "role_id") 23 | private List roles = new ArrayList<>(); 24 | 25 | public User(){ 26 | 27 | } 28 | public User(String username){ 29 | this.username = username; 30 | } 31 | 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Integer id) { 37 | this.id = id; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getUsername() { 49 | return username; 50 | } 51 | 52 | public void setUsername(String username) { 53 | this.username = username; 54 | } 55 | 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | public void setPassword(String password) { 61 | this.password = password; 62 | } 63 | 64 | public List getRoles() { 65 | return roles; 66 | } 67 | 68 | public void setRoles(List roles) { 69 | this.roles = roles; 70 | } 71 | } -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/security/JWTCreator.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.security; 2 | 3 | import java.util.Arrays; 4 | import java.util.Date; 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | 8 | import io.jsonwebtoken.Claims; 9 | import io.jsonwebtoken.ExpiredJwtException; 10 | import io.jsonwebtoken.Jwts; 11 | import io.jsonwebtoken.MalformedJwtException; 12 | import io.jsonwebtoken.SignatureAlgorithm; 13 | import io.jsonwebtoken.SignatureException; 14 | import io.jsonwebtoken.UnsupportedJwtException; 15 | 16 | public class JWTCreator { 17 | public static final String HEADER_AUTHORIZATION = "Authorization"; 18 | public static final String ROLES_AUTHORITIES = "authorities"; 19 | 20 | public static String create(String prefix,String key, JWTObject jwtObject) { 21 | String token = Jwts.builder().setSubject(jwtObject.getSubject()).setIssuedAt(jwtObject.getIssuedAt()).setExpiration(jwtObject.getExpiration()) 22 | .claim(ROLES_AUTHORITIES, checkRoles(jwtObject.getRoles())).signWith(SignatureAlgorithm.HS512, key).compact(); 23 | return prefix + " " + token; 24 | } 25 | public static JWTObject create(String token,String prefix,String key) 26 | throws ExpiredJwtException, UnsupportedJwtException, MalformedJwtException, SignatureException { 27 | JWTObject object = new JWTObject(); 28 | token = token.replace(prefix, ""); 29 | Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody(); 30 | object.setSubject(claims.getSubject()); 31 | object.setExpiration(claims.getExpiration()); 32 | object.setIssuedAt(claims.getIssuedAt()); 33 | object.setRoles((List) claims.get(ROLES_AUTHORITIES)); 34 | return object; 35 | 36 | } 37 | private static List checkRoles(List roles) { 38 | return roles.stream().map(s -> "ROLE_".concat(s.replaceAll("ROLE_",""))).collect(Collectors.toList()); 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /dio-spring-security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.5 9 | 10 | 11 | dio 12 | dio-spring-security 13 | 0.0.1-SNAPSHOT 14 | dio-spring-security 15 | Dio Spring Security 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-security 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-data-jpa 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | com.h2database 34 | h2 35 | runtime 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.springframework.security 45 | spring-security-test 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-maven-plugin 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spring-web-security-database/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.5 9 | 10 | 11 | dio 12 | dio-spring-security 13 | 0.0.1-SNAPSHOT 14 | spring-web-security-database 15 | Dio Spring Security 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-security 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-data-jpa 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | com.h2database 34 | h2 35 | runtime 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.springframework.security 45 | spring-security-test 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-maven-plugin 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spring-primeiros-passos/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-properties-value/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-data-jpa-hibernate/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-data-jpa-repository/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.5 9 | 10 | 11 | dio 12 | dio-spring-security-jwt 13 | 0.0.1-SNAPSHOT 14 | dio-spring-security-jwt 15 | Demo project for Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-security 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | com.h2database 35 | h2 36 | 37 | 38 | 39 | io.jsonwebtoken 40 | jjwt 41 | 0.7.0 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | org.springframework.security 50 | spring-security-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /springboot-web-swagger/src/main/java/dio/springbootweb/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package dio.springbootweb; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashSet; 5 | 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import springfox.documentation.builders.ApiInfoBuilder; 10 | import springfox.documentation.builders.PathSelectors; 11 | import springfox.documentation.builders.RequestHandlerSelectors; 12 | import springfox.documentation.service.Contact; 13 | import springfox.documentation.spi.DocumentationType; 14 | import springfox.documentation.spring.web.plugins.Docket; 15 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 16 | 17 | @Configuration 18 | @EnableSwagger2 19 | public class SwaggerConfig { 20 | private Contact contato() { 21 | return new Contact( 22 | "Seu nome", 23 | "http://www.seusite.com.br", 24 | "voce@seusite.com.br"); 25 | } 26 | private ApiInfoBuilder informacoesApi() { 27 | 28 | ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder(); 29 | 30 | apiInfoBuilder.title("Title - Rest API"); 31 | apiInfoBuilder.description("API exemplo de uso de Springboot REST API"); 32 | apiInfoBuilder.version("1.0"); 33 | apiInfoBuilder.termsOfServiceUrl("Termo de uso: Open Source"); 34 | apiInfoBuilder.license("Licença - Sua Empresa"); 35 | apiInfoBuilder.licenseUrl("http://www.seusite.com.br"); 36 | apiInfoBuilder.contact(this.contato()); 37 | 38 | return apiInfoBuilder; 39 | 40 | } 41 | @Bean 42 | public Docket detalheApi() { 43 | Docket docket = new Docket(DocumentationType.SWAGGER_2); 44 | 45 | docket 46 | .select() 47 | .apis(RequestHandlerSelectors.basePackage("dio.springbootweb.controller")) 48 | .paths(PathSelectors.any()) 49 | .build() 50 | .apiInfo(this.informacoesApi().build()) 51 | .consumes(new HashSet(Arrays.asList("application/json"))) 52 | .produces(new HashSet(Arrays.asList("application/json"))); 53 | 54 | return docket; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.controller; 2 | 3 | import dio.dio.spring.security.jwt.dtos.Login; 4 | import dio.dio.spring.security.jwt.dtos.Sessao; 5 | import dio.dio.spring.security.jwt.model.User; 6 | import dio.dio.spring.security.jwt.repository.UserRepository; 7 | import dio.dio.spring.security.jwt.security.JWTCreator; 8 | import dio.dio.spring.security.jwt.security.JWTObject; 9 | import dio.dio.spring.security.jwt.security.SecurityConfig; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.security.crypto.password.PasswordEncoder; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RestController; 15 | import java.util.Date; 16 | @RestController 17 | public class LoginController { 18 | @Autowired 19 | private PasswordEncoder encoder; 20 | @Autowired 21 | private SecurityConfig securityConfig; 22 | @Autowired 23 | private UserRepository repository; 24 | 25 | @PostMapping("/login") 26 | public Sessao logar(@RequestBody Login login){ 27 | User user = repository.findByUsername(login.getUsername()); 28 | if(user!=null) { 29 | boolean passwordOk = encoder.matches(login.getPassword(), user.getPassword()); 30 | if (!passwordOk) { 31 | throw new RuntimeException("Senha inválida para o login: " + login.getUsername()); 32 | } 33 | //Estamos enviando um objeto Sessão para retornar mais informações do usuário 34 | Sessao sessao = new Sessao(); 35 | sessao.setLogin(user.getUsername()); 36 | 37 | JWTObject jwtObject = new JWTObject(); 38 | jwtObject.setIssuedAt(new Date(System.currentTimeMillis())); 39 | jwtObject.setExpiration((new Date(System.currentTimeMillis() + SecurityConfig.EXPIRATION))); 40 | jwtObject.setRoles(user.getRoles()); 41 | sessao.setToken(JWTCreator.create(SecurityConfig.PREFIX, SecurityConfig.KEY, jwtObject)); 42 | return sessao; 43 | }else { 44 | throw new RuntimeException("Erro ao tentar fazer login"); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-web-security-database/src/main/java/dio/spring/security/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package dio.spring.security.config; 2 | 3 | import dio.spring.security.config.SecurityDatabaseService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.HttpMethod; 7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 12 | import org.springframework.security.crypto.password.NoOpPasswordEncoder; 13 | 14 | 15 | @Configuration 16 | @EnableWebSecurity 17 | @EnableGlobalMethodSecurity(prePostEnabled = true) 18 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 19 | @Autowired 20 | private SecurityDatabaseService securityService; 21 | 22 | @Autowired 23 | public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception { 24 | auth.userDetailsService(securityService).passwordEncoder(NoOpPasswordEncoder.getInstance()); 25 | } 26 | 27 | @Override 28 | protected void configure(HttpSecurity http) throws Exception { 29 | http.authorizeRequests() 30 | .antMatchers("/").permitAll() 31 | .antMatchers(HttpMethod.POST,"/login").permitAll() 32 | .antMatchers("/managers").hasAnyRole("MANAGERS") 33 | .antMatchers("/users").hasAnyRole("USERS","MANAGERS") 34 | .anyRequest().authenticated().and().httpBasic(); 35 | } 36 | /* 37 | @Override 38 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 39 | auth.inMemoryAuthentication() 40 | .withUser("user") 41 | .password("{noop}user123") 42 | .roles("USERS") 43 | .and() 44 | .withUser("admin") 45 | .password("{noop}master123") 46 | .roles("MANAGERS"); 47 | } 48 | */ 49 | 50 | } 51 | -------------------------------------------------------------------------------- /dio-spring-data-jpa-exception-handler/src/main/java/dio/aula/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package dio.aula.handler; 2 | 3 | import javax.annotation.Resource; 4 | import org.springframework.cglib.proxy.UndeclaredThrowableException; 5 | import org.springframework.context.MessageSource; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.ExceptionHandler; 11 | import org.springframework.web.bind.annotation.RestControllerAdvice; 12 | import org.springframework.web.context.request.WebRequest; 13 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 14 | @RestControllerAdvice 15 | public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { 16 | @Resource 17 | private MessageSource messageSource; 18 | private HttpHeaders headers(){ 19 | HttpHeaders headers = new HttpHeaders(); 20 | headers.setContentType(MediaType.APPLICATION_JSON); 21 | return headers; 22 | } 23 | private ResponseError responseError(String message,HttpStatus statusCode){ 24 | ResponseError responseError = new ResponseError(); 25 | responseError.setStatus("error"); 26 | responseError.setError(message); 27 | responseError.setStatusCode(statusCode.value()); 28 | return responseError; 29 | } 30 | @ExceptionHandler(Exception.class) 31 | private ResponseEntity handleGeneral(Exception e, WebRequest request) { 32 | if (e.getClass().isAssignableFrom(UndeclaredThrowableException.class)) { 33 | UndeclaredThrowableException exception = (UndeclaredThrowableException) e; 34 | return handleBusinessException((BusinessException) exception.getUndeclaredThrowable(), request); 35 | } else { 36 | String message = messageSource.getMessage("error.server", new Object[]{e.getMessage()}, null); 37 | ResponseError error = responseError(message,HttpStatus.INTERNAL_SERVER_ERROR); 38 | return handleExceptionInternal(e, error, headers(), HttpStatus.INTERNAL_SERVER_ERROR, request); 39 | } 40 | } 41 | @ExceptionHandler({BusinessException.class}) 42 | private ResponseEntity handleBusinessException(BusinessException e, WebRequest request) { 43 | ResponseError error = responseError(e.getMessage(),HttpStatus.CONFLICT); 44 | return handleExceptionInternal(e, error, headers(), HttpStatus.CONFLICT, request); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/security/JWTFilter.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.security; 2 | import java.io.IOException; 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.http.HttpStatus; 13 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 14 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 15 | import org.springframework.security.core.context.SecurityContextHolder; 16 | import org.springframework.web.filter.OncePerRequestFilter; 17 | 18 | import io.jsonwebtoken.ExpiredJwtException; 19 | import io.jsonwebtoken.MalformedJwtException; 20 | import io.jsonwebtoken.SignatureException; 21 | import io.jsonwebtoken.UnsupportedJwtException; 22 | 23 | public class JWTFilter extends OncePerRequestFilter { 24 | @Override 25 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) 26 | throws ServletException, IOException { 27 | //obtem o token da request com AUTHORIZATION 28 | String token = request.getHeader(JWTCreator.HEADER_AUTHORIZATION); 29 | //esta implementação só esta validando a integridade do token 30 | try { 31 | if(token!=null && !token.isEmpty()) { 32 | JWTObject tokenObject = JWTCreator.create(token,SecurityConfig.PREFIX, SecurityConfig.KEY); 33 | 34 | List authorities = authorities(tokenObject.getRoles()); 35 | 36 | UsernamePasswordAuthenticationToken userToken = 37 | new UsernamePasswordAuthenticationToken( 38 | tokenObject.getSubject(), 39 | null, 40 | authorities); 41 | 42 | SecurityContextHolder.getContext().setAuthentication(userToken); 43 | 44 | }else { 45 | SecurityContextHolder.clearContext(); 46 | } 47 | filterChain.doFilter(request, response); 48 | }catch (ExpiredJwtException | UnsupportedJwtException | MalformedJwtException | SignatureException e) { 49 | e.printStackTrace(); 50 | response.setStatus(HttpStatus.FORBIDDEN.value()); 51 | return; 52 | } 53 | } 54 | private List authorities(List roles){ 55 | return roles.stream().map(SimpleGrantedAuthority::new) 56 | .collect(Collectors.toList()); 57 | } 58 | } -------------------------------------------------------------------------------- /dio-spring-security-jwt/src/main/java/dio/dio/spring/security/jwt/security/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package dio.dio.spring.security.jwt.security; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.HttpMethod; 7 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.config.http.SessionCreationPolicy; 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 13 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 14 | import org.h2.server.web.WebServlet; 15 | 16 | @Configuration 17 | @EnableWebSecurity 18 | @EnableGlobalMethodSecurity(prePostEnabled = true) 19 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 20 | @Bean 21 | public BCryptPasswordEncoder encoder(){ 22 | return new BCryptPasswordEncoder(); 23 | } 24 | 25 | private static final String[] SWAGGER_WHITELIST = { 26 | "/v2/api-docs", 27 | "/swagger-resources", 28 | "/swagger-resources/**", 29 | "/configuration/ui", 30 | "/configuration/security", 31 | "/swagger-ui.html", 32 | "/webjars/**" 33 | }; 34 | @Override 35 | protected void configure(HttpSecurity http) throws Exception { 36 | http.headers().frameOptions().disable(); 37 | http.cors().and().csrf().disable() 38 | .addFilterAfter(new JWTFilter(), UsernamePasswordAuthenticationFilter.class) 39 | .authorizeRequests() 40 | .antMatchers(SWAGGER_WHITELIST).permitAll() 41 | .antMatchers("/h2-console/**").permitAll() 42 | .antMatchers(HttpMethod.POST,"/login").permitAll() 43 | .antMatchers(HttpMethod.POST,"/users").permitAll() 44 | .antMatchers(HttpMethod.GET,"/users").hasAnyRole("USERS","MANAGERS") 45 | .antMatchers("/managers").hasAnyRole("MANAGERS") 46 | .anyRequest().authenticated() 47 | .and() 48 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); 49 | } 50 | @Bean //HABILITANDO ACESSAR O H2-DATABSE NA WEB 51 | public ServletRegistrationBean h2servletRegistration(){ 52 | ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet()); 53 | registrationBean.addUrlMappings("/h2-console/*"); 54 | return registrationBean; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /springboot-web/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /springboot-web-swagger/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /spring-web-security-database/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /springboot-web/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /springboot-web-swagger/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /spring-web-security-database/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /springboot-web/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /springboot-web-swagger/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /spring-web-security-database/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------