├── flow.png ├── apigateway ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── application.yml │ │ └── java │ │ │ └── tr │ │ │ └── com │ │ │ └── softtech │ │ │ └── bestcommerce │ │ │ └── apigateway │ │ │ ├── security │ │ │ ├── JwtDetails.java │ │ │ ├── JwtValidator.java │ │ │ ├── JwtConstants.java │ │ │ └── JwtGenerator.java │ │ │ ├── ApiGatewayApplication.java │ │ │ └── filters │ │ │ ├── ValidateJwtFilter.java │ │ │ └── AddJwtFilter.java │ └── test │ │ └── java │ │ └── tr │ │ └── com │ │ └── softtech │ │ └── bestcommerce │ │ └── apigateway │ │ ├── ApiGatewayApplicationTests.java │ │ └── security │ │ ├── JwtGeneratorTest.java │ │ └── JwtValidatorTest.java ├── README.md ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── .idea ├── vcs.xml ├── modules.xml ├── Softtech-BestCommerce-Case.iml └── workspace.xml ├── signin ├── src │ ├── main │ │ ├── resources │ │ │ ├── data.sql │ │ │ └── application.properties │ │ └── java │ │ │ └── tr │ │ │ └── com │ │ │ └── softtech │ │ │ └── bestcommerce │ │ │ └── signin │ │ │ ├── dtos │ │ │ └── UserDto.java │ │ │ ├── security │ │ │ └── JwtConstants.java │ │ │ ├── services │ │ │ ├── SignInService.java │ │ │ └── impl │ │ │ │ └── SignInServiceImpl.java │ │ │ ├── models │ │ │ └── Credentials.java │ │ │ ├── SignInApplication.java │ │ │ ├── repositories │ │ │ └── UserRepository.java │ │ │ ├── entities │ │ │ └── User.java │ │ │ ├── exceptions │ │ │ └── NotFoundException.java │ │ │ ├── mappers │ │ │ └── UserMapper.java │ │ │ └── controllers │ │ │ └── SignInController.java │ └── test │ │ └── java │ │ └── tr │ │ └── com │ │ └── softtech │ │ └── bestcommerce │ │ └── signin │ │ ├── SignInApplicationTests.java │ │ ├── mappers │ │ └── UserMapperTest.java │ │ └── controllers │ │ └── SignInControllerTest.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── README.md ├── pom.xml ├── mvnw.cmd └── mvnw ├── listproducts ├── src │ ├── main │ │ ├── java │ │ │ └── tr │ │ │ │ └── com │ │ │ │ └── softtech │ │ │ │ └── bestcommerce │ │ │ │ └── listproducts │ │ │ │ ├── enums │ │ │ │ ├── PaymentOptions.java │ │ │ │ ├── DeliveryOptions.java │ │ │ │ └── ProductCategory.java │ │ │ │ ├── params │ │ │ │ └── ListProductsParams.java │ │ │ │ ├── services │ │ │ │ ├── ListProductsService.java │ │ │ │ └── impl │ │ │ │ │ └── ListProductServiceImpl.java │ │ │ │ ├── ListProductsApplication.java │ │ │ │ ├── repositories │ │ │ │ └── ProductRepository.java │ │ │ │ ├── search │ │ │ │ └── ProductSpecification.java │ │ │ │ ├── dtos │ │ │ │ └── ProductDto.java │ │ │ │ ├── exceptions │ │ │ │ └── ConstraintViolationExceptionHandler.java │ │ │ │ ├── mappers │ │ │ │ ├── ProductMapper.java │ │ │ │ └── ListProductsParamMapper.java │ │ │ │ ├── entities │ │ │ │ └── Product.java │ │ │ │ └── controllers │ │ │ │ └── ListProductsController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── data.sql │ └── test │ │ └── java │ │ └── tr │ │ └── com │ │ └── softtech │ │ └── bestcommerce │ │ └── listproducts │ │ ├── ListProductsApplicationTests.java │ │ └── mappers │ │ ├── ListProductsParamMapperTest.java │ │ └── ProductMapperTest.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── README.md ├── pom.xml ├── mvnw.cmd └── mvnw ├── .gitignore ├── .github └── workflows │ └── build.yml ├── LICENSE ├── README.md └── BestCommerce.postman_collection.json /flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilhan-mstf/BestCommerce-Case/master/flow.png -------------------------------------------------------------------------------- /apigateway/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | jwt.shortExpiration=21600000 2 | jwt.longExpiration=21600000 -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /signin/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | insert into user 2 | values(10001, 'mustafa@softtech.com.tr', 'mustafa', 'pass1234'); 3 | 4 | insert into user 5 | values(10002, 'ahmet@softtech.com.tr', 'ahmet', 'pass1234'); -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/enums/PaymentOptions.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.enums; 2 | 3 | public enum PaymentOptions { 4 | DIRECT, 5 | INSTALLMENTS 6 | } 7 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/enums/DeliveryOptions.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.enums; 2 | 3 | public enum DeliveryOptions { 4 | NORMAL_DELIVERY, 5 | FAST_DELIVERY 6 | } 7 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/enums/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.enums; 2 | 3 | public enum ProductCategory { 4 | ELECTRONICS, 5 | FASHION, 6 | FOOD 7 | } 8 | -------------------------------------------------------------------------------- /apigateway/README.md: -------------------------------------------------------------------------------- 1 | # API Gateway 2 | - Routes requests to related service. 3 | - Creates JWT and validates JWT. 4 | 5 | ## API Properties 6 | - Server port is defined in `application.properties`. 7 | - Routing definitions can be found on `application.yml`. -------------------------------------------------------------------------------- /signin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /apigateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /listproducts/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/dtos/UserDto.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.dtos; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class UserDto { 7 | 8 | private String name; 9 | private String email; 10 | } 11 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/security/JwtDetails.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class JwtDetails { 7 | 8 | private String subject; 9 | private long expiration; 10 | } 11 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/security/JwtConstants.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.security; 2 | 3 | public class JwtConstants { 4 | 5 | public static final String HEADER_JWT_SUBJECT = "X-JWT-Subject"; 6 | public static final String HEADER_JWT_REMEMBER = "X-JWT-Remember"; 7 | } 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /signin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | 3 | spring.datasource.url=jdbc:h2:mem:testdb 4 | spring.datasource.driverClassName=org.h2.Driver 5 | spring.datasource.username=admin 6 | spring.datasource.password= 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | spring.h2.console.enabled=true 9 | spring.h2.console.path=/h2 -------------------------------------------------------------------------------- /signin/src/test/java/tr/com/softtech/bestcommerce/signin/SignInApplicationTests.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SignInApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/services/SignInService.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.services; 2 | 3 | import tr.com.softtech.bestcommerce.signin.models.Credentials; 4 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 5 | 6 | public interface SignInService { 7 | 8 | UserDto signIn(Credentials credentials); 9 | } 10 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/models/Credentials.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.models; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | @Data 7 | @NoArgsConstructor 8 | public class Credentials { 9 | 10 | private String email; 11 | private String password; 12 | private String remember; 13 | } 14 | -------------------------------------------------------------------------------- /apigateway/src/test/java/tr/com/softtech/bestcommerce/apigateway/ApiGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApiGatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.idea/Softtech-BestCommerce-Case.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /listproducts/src/test/java/tr/com/softtech/bestcommerce/listproducts/ListProductsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ListProductsApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | .history -------------------------------------------------------------------------------- /listproducts/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8082 2 | 3 | spring.datasource.url=jdbc:h2:mem:testdb 4 | spring.datasource.driverClassName=org.h2.Driver 5 | spring.datasource.username=admin 6 | spring.datasource.password= 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | spring.h2.console.enabled=true 9 | spring.h2.console.path=/h2 10 | 11 | product.search.inventoryThreshold=4 -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/params/ListProductsParams.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.params; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class ListProductsParams { 9 | 10 | private Long userId; 11 | private int page; 12 | private int size; 13 | private String[] sort; 14 | } 15 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/SignInApplication.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SignInApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SignInApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/services/ListProductsService.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.services; 2 | 3 | import tr.com.softtech.bestcommerce.listproducts.dtos.ProductDto; 4 | import tr.com.softtech.bestcommerce.listproducts.params.ListProductsParams; 5 | 6 | import java.util.List; 7 | 8 | public interface ListProductsService { 9 | 10 | List listProducts(ListProductsParams params); 11 | } 12 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/ApiGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ApiGatewayApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ApiGatewayApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/repositories/UserRepository.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import tr.com.softtech.bestcommerce.signin.entities.User; 5 | 6 | import java.util.Optional; 7 | 8 | public interface UserRepository extends JpaRepository { 9 | 10 | Optional findByEmailAndPassword(String email, String password); 11 | } 12 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/ListProductsApplication.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ListProductsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ListProductsApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /apigateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | cloud: 5 | gateway: 6 | routes: 7 | - id: signin 8 | uri: http://localhost:8081 9 | predicates: 10 | - Path=/v1/signin 11 | filters: 12 | - AddJwtFilter 13 | - id: products 14 | uri: http://localhost:8082 15 | predicates: 16 | - Path=/v1/products 17 | filters: 18 | - ValidateJwtFilter 19 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/entities/User.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.entities; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | 9 | @Data 10 | @Entity 11 | public class User { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | private String name; 18 | private String email; 19 | private String password; 20 | } 21 | -------------------------------------------------------------------------------- /signin/.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 | -------------------------------------------------------------------------------- /apigateway/.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 | -------------------------------------------------------------------------------- /listproducts/.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 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.NOT_FOUND) 7 | public class NotFoundException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public NotFoundException(Class clazz, String id) { 12 | super(clazz.getSimpleName() + ":" + id); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/repositories/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | import org.springframework.stereotype.Repository; 6 | import tr.com.softtech.bestcommerce.listproducts.entities.Product; 7 | 8 | @Repository 9 | public interface ProductRepository extends 10 | JpaRepository, 11 | JpaSpecificationExecutor { } 12 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/mappers/UserMapper.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.mappers; 2 | 3 | import org.springframework.stereotype.Component; 4 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 5 | import tr.com.softtech.bestcommerce.signin.entities.User; 6 | 7 | @Component 8 | public class UserMapper { 9 | 10 | public UserDto entityToDto(User user) { 11 | if (user == null) { 12 | return null; 13 | } 14 | UserDto userDto = new UserDto(); 15 | userDto.setEmail(user.getEmail()); 16 | userDto.setName(user.getName()); 17 | return userDto; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/search/ProductSpecification.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.search; 2 | 3 | import org.springframework.data.jpa.domain.Specification; 4 | import tr.com.softtech.bestcommerce.listproducts.entities.Product; 5 | 6 | public class ProductSpecification { 7 | 8 | public static Specification userEqualTo(Long userId) { 9 | return (root, query, cb) -> 10 | cb.equal(root.get("userId"), userId); 11 | } 12 | 13 | public static Specification inventoryGreaterThan(int num) { 14 | return (root, query, cb) -> 15 | cb.greaterThan(root.get("inventory"), num); 16 | } 17 | } -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/dtos/ProductDto.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.dtos; 2 | 3 | import lombok.Data; 4 | import tr.com.softtech.bestcommerce.listproducts.enums.DeliveryOptions; 5 | import tr.com.softtech.bestcommerce.listproducts.enums.PaymentOptions; 6 | import tr.com.softtech.bestcommerce.listproducts.enums.ProductCategory; 7 | 8 | @Data 9 | public class ProductDto { 10 | 11 | private Long id; 12 | 13 | private String name; 14 | 15 | private String description; 16 | 17 | private int inventory; 18 | 19 | private int price; 20 | 21 | private ProductCategory productCategory; 22 | 23 | private PaymentOptions paymentOptions; 24 | 25 | private DeliveryOptions deliveryOptions; 26 | } 27 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/security/JwtValidator.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | import io.jsonwebtoken.JwtException; 4 | import io.jsonwebtoken.Jwts; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class JwtValidator { 10 | 11 | @Autowired 12 | private JwtConstants jwtConstants; 13 | 14 | public boolean validate(String token) { 15 | try { 16 | Jwts.parserBuilder() 17 | .setSigningKey(jwtConstants.getKey()) 18 | .build() 19 | .parseClaimsJws(token); 20 | return true; 21 | } catch (JwtException e) { 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Build and Tests 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 1.11 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 1.11 23 | - name: Run tests of sign in service 24 | working-directory: ./signin 25 | run: mvn test 26 | - name: Run tests of list products service 27 | working-directory: ./listproducts 28 | run: mvn test 29 | - name: Run tests of api gateway 30 | working-directory: ./apigateway 31 | run: mvn test -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/security/JwtConstants.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | import io.jsonwebtoken.SignatureAlgorithm; 4 | import io.jsonwebtoken.security.Keys; 5 | import lombok.Getter; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.security.Key; 10 | 11 | @Component 12 | public class JwtConstants { 13 | 14 | public static final String HEADER_JWT = "X-JWT"; 15 | public static final String HEADER_JWT_SUBJECT = "X-JWT-Subject"; 16 | public static final String HEADER_JWT_REMEMBER = "X-JWT-Remember"; 17 | 18 | @Getter 19 | @Value("${jwt.shortExpiration}") 20 | private long shortExpiration; 21 | 22 | @Getter 23 | @Value("${jwt.longExpiration}") 24 | private long longExpiration; 25 | 26 | @Getter 27 | private Key key = Keys.secretKeyFor(SignatureAlgorithm.HS256); 28 | } 29 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/security/JwtGenerator.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | import io.jsonwebtoken.Jwts; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Date; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | @Component 12 | public class JwtGenerator { 13 | 14 | @Autowired 15 | private JwtConstants jwtTokenConstants; 16 | 17 | public String generate(JwtDetails details) { 18 | Map claims = new HashMap<>(); 19 | return Jwts.builder() 20 | .setClaims(claims) 21 | .setSubject(details.getSubject()) 22 | .setIssuedAt(new Date()) 23 | .setExpiration(new Date(new Date().getTime() + details.getExpiration())) 24 | .signWith(jwtTokenConstants.getKey()) 25 | .compact(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /signin/README.md: -------------------------------------------------------------------------------- 1 | # Sign in API 2 | - Checks user credentials and return success or error http status. 3 | - Passes JWT variables on the http header. 4 | - Uses in-memory database H2. 5 | 6 | ## API Properties 7 | - Server port is defined in `application.properties`. 8 | - Sample data can be found in `data.sql`. This is executed during startup automatically. 9 | 10 | ## Sample request 11 | ``` 12 | curl --location --request POST 'http://localhost:8080/v1/signin' \ 13 | --header 'Content-Type: application/json' \ 14 | --data-raw '{ 15 | "email": "mustafa@softtech.com.tr", 16 | "password": "pass", 17 | "remember": "true" 18 | }' 19 | ``` 20 | 21 | # Open points to further development 22 | - Encrypt user password 23 | - Move `JwtConstants` to a shared lib to be used in `apigateway` 24 | - Integrate this API to Authentication and Authorization solution such as KeyCloak 25 | - `id` and `email` can be added to JWT 26 | 27 | # Notes 28 | - There is no need to check password length during sign in. It should be done on sign up. -------------------------------------------------------------------------------- /listproducts/README.md: -------------------------------------------------------------------------------- 1 | # List Products API 2 | - List authenticated merchant's products 3 | - Swagger documentation can be generated with provided annotations. 4 | - It uses in memory database H2. 5 | 6 | ## API Properties 7 | - Server port is defined in `application.properties`. 8 | - Sample data can be found in `data.sql`. This is executed during startup automatically. 9 | 10 | # Sample Requests 11 | ```shell script 12 | curl --location --request GET 'http://localhost:8080/v1/products?userId=10001&size=10&page=0&sort=price,asc,inventory,desc' \ 13 | --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJnZWVldyIsImlhdCI6MTYwMDM2MDQ3MCwiZXhwIjoxNjAwMzgyMDcwfQ.kDlZ-tj6-URO8VVBLdstUwCxADHXKwo32Dbbj4pGdgA' 14 | ``` 15 | 16 | # Further points to develop 17 | - Merchant/user id authorization check. 18 | - Merchant/user id can be read from JWT or if more advanced Authorzation mechanism is used, it can be retrieved from the Authorization server. 19 | - This is also can be done on API Gateway by passing/overriding userId. 20 | - Return json error when parameter validation fails. -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/exceptions/ConstraintViolationExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.exceptions; 2 | 3 | import org.springframework.http.HttpHeaders; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.ControllerAdvice; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.context.request.WebRequest; 9 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 10 | 11 | import javax.validation.ConstraintViolationException; 12 | 13 | @ControllerAdvice 14 | public class ConstraintViolationExceptionHandler extends ResponseEntityExceptionHandler { 15 | 16 | @ExceptionHandler(value = {ConstraintViolationException.class}) 17 | protected ResponseEntity handleConstraintViolation(ConstraintViolationException e, WebRequest request) { 18 | return handleExceptionInternal(e, e.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST, request); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/mappers/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.mappers; 2 | 3 | import org.springframework.stereotype.Component; 4 | import tr.com.softtech.bestcommerce.listproducts.dtos.ProductDto; 5 | import tr.com.softtech.bestcommerce.listproducts.entities.Product; 6 | 7 | @Component 8 | public class ProductMapper { 9 | 10 | public ProductDto entityToDto(Product product) { 11 | if (product == null) { 12 | return null; 13 | } 14 | 15 | ProductDto productDto = new ProductDto(); 16 | productDto.setId(product.getId()); 17 | productDto.setName(product.getName()); 18 | productDto.setDescription(product.getDescription()); 19 | productDto.setInventory(product.getInventory()); 20 | productDto.setPrice(product.getPrice()); 21 | productDto.setDeliveryOptions(product.getDeliveryOptions()); 22 | productDto.setPaymentOptions(product.getPaymentOptions()); 23 | productDto.setProductCategory(product.getProductCategory()); 24 | return productDto; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mustafa İlhan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /apigateway/src/test/java/tr/com/softtech/bestcommerce/apigateway/security/JwtGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit.jupiter.SpringExtension; 8 | 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | 11 | @SpringBootTest 12 | @ExtendWith(SpringExtension.class) 13 | public class JwtGeneratorTest { 14 | 15 | @Autowired 16 | private JwtGenerator jwtGenerator; 17 | 18 | @Autowired 19 | private JwtValidator jwtValidator; 20 | 21 | @Test 22 | public void shouldGenerate_ValidJwt() { 23 | JwtDetails jwtDetails = new JwtDetails(); 24 | jwtDetails.setExpiration(100000); 25 | jwtDetails.setSubject("hede"); 26 | 27 | String token = jwtGenerator.generate(jwtDetails); 28 | 29 | boolean val = jwtValidator.validate(token); 30 | 31 | assertThat(val).isTrue(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/entities/Product.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.entities; 2 | 3 | import lombok.Data; 4 | import tr.com.softtech.bestcommerce.listproducts.enums.DeliveryOptions; 5 | import tr.com.softtech.bestcommerce.listproducts.enums.PaymentOptions; 6 | import tr.com.softtech.bestcommerce.listproducts.enums.ProductCategory; 7 | 8 | import javax.persistence.*; 9 | 10 | @Data 11 | @Entity 12 | public class Product { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column(name = "user_id") 19 | private Long userId; 20 | 21 | private String name; 22 | 23 | private String description; 24 | 25 | private int inventory; 26 | 27 | private int price; 28 | 29 | @Enumerated(EnumType.STRING) 30 | @Column(name = "product_category") 31 | private ProductCategory productCategory; 32 | 33 | @Enumerated(EnumType.STRING) 34 | @Column(name = "payment_options") 35 | private PaymentOptions paymentOptions; 36 | 37 | @Enumerated(EnumType.STRING) 38 | @Column(name = "delivery_options") 39 | private DeliveryOptions deliveryOptions; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /listproducts/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO product (id, user_id, name, description, inventory, price, product_category, payment_options, delivery_options) 2 | VALUES (1, 10001, 'iPhone 11', 'the best iPhone ever', 10, 999, 'ELECTRONICS', 'INSTALLMENTS', 'FAST_DELIVERY'); 3 | 4 | INSERT INTO product (id, user_id, name, description, inventory, price, product_category, payment_options, delivery_options) 5 | VALUES (2, 10001, 'iPhone 10', 'the best iPhone ever', 11, 999, 'ELECTRONICS', 'INSTALLMENTS', 'FAST_DELIVERY'); 6 | 7 | INSERT INTO product (id, user_id, name, description, inventory, price, product_category, payment_options, delivery_options) 8 | VALUES (3, 10001, 'iPhone 9', 'the best iPhone ever', 12, 599, 'ELECTRONICS', 'INSTALLMENTS', 'FAST_DELIVERY'); 9 | 10 | INSERT INTO product (id, user_id, name, description, inventory, price, product_category, payment_options, delivery_options) 11 | VALUES (4, 10001, 'iPhone 8', 'the best iPhone ever', 9, 599, 'ELECTRONICS', 'INSTALLMENTS', 'FAST_DELIVERY'); 12 | 13 | INSERT INTO product (id, user_id, name, description, inventory, price, product_category, payment_options, delivery_options) 14 | VALUES (5, 10001, 'iPhone 7', 'the best iPhone ever', 1, 599, 'ELECTRONICS', 'INSTALLMENTS', 'FAST_DELIVERY'); -------------------------------------------------------------------------------- /listproducts/src/test/java/tr/com/softtech/bestcommerce/listproducts/mappers/ListProductsParamMapperTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.mappers; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.test.context.junit.jupiter.SpringExtension; 9 | import tr.com.softtech.bestcommerce.listproducts.params.ListProductsParams; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | 13 | @SpringBootTest 14 | @ExtendWith(SpringExtension.class) 15 | public class ListProductsParamMapperTest { 16 | 17 | @Autowired 18 | private ListProductsParamMapper listProductsParamMapper; 19 | 20 | @Test 21 | public void whenValidParams_ThenShouldReturnPageable() { 22 | ListProductsParams params = new ListProductsParams( 23 | 1L,1,1, new String[] {"id", "desc"}); 24 | 25 | Pageable pageable = listProductsParamMapper.paramsToPageable(params); 26 | 27 | assertThat(pageable).isNotNull(); 28 | assertThat(pageable.getPageSize()).isEqualTo(params.getSize()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/services/impl/SignInServiceImpl.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.services.impl; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 7 | import tr.com.softtech.bestcommerce.signin.entities.User; 8 | import tr.com.softtech.bestcommerce.signin.exceptions.NotFoundException; 9 | import tr.com.softtech.bestcommerce.signin.mappers.UserMapper; 10 | import tr.com.softtech.bestcommerce.signin.models.Credentials; 11 | import tr.com.softtech.bestcommerce.signin.repositories.UserRepository; 12 | import tr.com.softtech.bestcommerce.signin.services.SignInService; 13 | 14 | @Service 15 | @RequiredArgsConstructor 16 | public class SignInServiceImpl implements SignInService { 17 | 18 | @Autowired 19 | private UserRepository userRepository; 20 | 21 | @Autowired 22 | private UserMapper userMapper; 23 | 24 | @Override 25 | public UserDto signIn(Credentials credentials) { 26 | User user = userRepository 27 | .findByEmailAndPassword(credentials.getEmail(), credentials.getPassword()) 28 | .orElseThrow(() -> new NotFoundException(User.class, credentials.getEmail())); 29 | 30 | return userMapper.entityToDto(user); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BestCommerce Case 2 | 3 | ![Build and Tests](https://github.com/ilhan-mstf/Softtech-BestCommerce-Case/workflows/Build%20and%20Tests/badge.svg) 4 | 5 | ## Scope 6 | - Sign in 7 | - List products 8 | 9 | ## Services 10 | - Sign in service 11 | - Spring Boot 12 | - H2 in memory db 13 | - List products service 14 | - Spring Boot 15 | - H2 in memory db 16 | - API Gateway 17 | - Spring Boot 18 | 19 | ## Basic flow 20 | - All requests are routed through API Gateway. 21 | - JWT is created by API Gateway after `sign in` request. 22 | - JWT is validated by API Gateway. 23 | - User should sign in and read JWT from reponse header. 24 | - Then, user should add JWT to the header of the requests. 25 | 26 | ![flow.png](flow.png) 27 | 28 | ## Notes 29 | - For this MVP there is no need to introduce Message Queues since current features don't require event driven architecture. It can be added later on if required. 30 | - Each service has its own db. 31 | - Each service can be deployable different docker image since they don't depend each other. 32 | - In the case of docker images port details should consider `application.properties` and `application.yml` files. 33 | 34 | ## Points to further development 35 | - Service registery can be added. Each service should add itself to the service registery and then api gateway routes request according the list fetched from service registery. 36 | - Advanced authentication and authorization service can be used (Keycloak). 37 | -------------------------------------------------------------------------------- /signin/src/test/java/tr/com/softtech/bestcommerce/signin/mappers/UserMapperTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.mappers; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit.jupiter.SpringExtension; 8 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 9 | import tr.com.softtech.bestcommerce.signin.entities.User; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | 13 | @SpringBootTest 14 | @ExtendWith(SpringExtension.class) 15 | public class UserMapperTest { 16 | 17 | @Autowired 18 | private UserMapper userMapper; 19 | 20 | @Test 21 | public void whenNonNullUser_thenShouldReturnUserDto() { 22 | User user = new User(); 23 | user.setEmail("email"); 24 | user.setId(1L); 25 | user.setName("name"); 26 | user.setPassword("pass"); 27 | 28 | UserDto userDto = userMapper.entityToDto(user); 29 | 30 | assertThat(userDto.getEmail()).isEqualTo(user.getEmail()); 31 | assertThat(userDto.getName()).isEqualTo(user.getName()); 32 | } 33 | 34 | @Test 35 | public void whenNullUser_thenShouldReturnNull() { 36 | UserDto userDto = userMapper.entityToDto(null); 37 | 38 | assertThat(userDto).isNull(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/mappers/ListProductsParamMapper.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.mappers; 2 | 3 | 4 | import org.springframework.data.domain.PageRequest; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.domain.Sort; 7 | import org.springframework.data.domain.Sort.Direction; 8 | import org.springframework.data.domain.Sort.Order; 9 | import org.springframework.stereotype.Component; 10 | import tr.com.softtech.bestcommerce.listproducts.params.ListProductsParams; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | @Component 16 | public class ListProductsParamMapper { 17 | 18 | public Pageable paramsToPageable(ListProductsParams params) { 19 | return PageRequest.of( 20 | params.getPage(), 21 | params.getSize(), 22 | Sort.by(getSortOrders(params.getSort()))); 23 | } 24 | 25 | private List getSortOrders(String[] sort) { 26 | List orders = new ArrayList(); 27 | 28 | for (int i = 0; i < sort.length; i += 2) { 29 | orders.add(new Order(getDirection(sort[i+1]), sort[i])); 30 | } 31 | 32 | return orders; 33 | } 34 | 35 | private Direction getDirection(String direction) { 36 | if (direction.equals("asc")) { 37 | return Direction.ASC; 38 | } else { 39 | return Direction.DESC; 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /apigateway/src/test/java/tr/com/softtech/bestcommerce/apigateway/security/JwtValidatorTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.security; 2 | 3 | 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit.jupiter.SpringExtension; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | @SpringBootTest 13 | @ExtendWith(SpringExtension.class) 14 | public class JwtValidatorTest { 15 | 16 | @Autowired 17 | private JwtValidator jwtValidator; 18 | 19 | @Autowired 20 | private JwtGenerator jwtGenerator; 21 | 22 | @Test 23 | public void shouldNotValidateDummyText() { 24 | boolean val = jwtValidator.validate("ere the sun rises"); 25 | 26 | assertThat(val).isFalse(); 27 | } 28 | 29 | @Test 30 | public void shouldValidate_ValidJwt() { 31 | JwtDetails jwtDetails = new JwtDetails(); 32 | jwtDetails.setExpiration(100000); 33 | jwtDetails.setSubject("hede"); 34 | 35 | String token = jwtGenerator.generate(jwtDetails); 36 | 37 | boolean val = jwtValidator.validate(token); 38 | 39 | assertThat(val).isTrue(); 40 | } 41 | 42 | @Test 43 | public void shouldNotValidate_ExpiredJwt() { 44 | JwtDetails jwtDetails = new JwtDetails(); 45 | jwtDetails.setExpiration(1); 46 | jwtDetails.setSubject("hede"); 47 | 48 | String token = jwtGenerator.generate(jwtDetails); 49 | 50 | boolean val = jwtValidator.validate(token); 51 | 52 | assertThat(val).isFalse(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/controllers/ListProductsController.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.controllers; 2 | 3 | import io.swagger.annotations.Api; 4 | import io.swagger.annotations.ApiOperation; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.validation.annotation.Validated; 8 | import org.springframework.web.bind.annotation.*; 9 | import tr.com.softtech.bestcommerce.listproducts.dtos.ProductDto; 10 | import tr.com.softtech.bestcommerce.listproducts.params.ListProductsParams; 11 | import tr.com.softtech.bestcommerce.listproducts.services.ListProductsService; 12 | 13 | import javax.validation.Valid; 14 | import javax.validation.constraints.Max; 15 | import javax.validation.constraints.Min; 16 | import java.util.List; 17 | 18 | @Validated 19 | @RestController 20 | @RequestMapping(ListProductsController.ENDPOINT) 21 | @Api(produces = MediaType.APPLICATION_JSON_VALUE, tags = "List products") 22 | public class ListProductsController { 23 | 24 | public static final String ENDPOINT = "/v1/products"; 25 | 26 | @Autowired 27 | private ListProductsService listProductsService; 28 | 29 | @CrossOrigin 30 | @ApiOperation("List products") 31 | @GetMapping 32 | public List listProducts( 33 | @RequestParam Long userId, 34 | @RequestParam(defaultValue = "0") @Min(0) int page, 35 | @RequestParam(defaultValue = "10") @Min(1) @Max(100) int size, 36 | @RequestParam(defaultValue = "id,desc") String[] sort 37 | ) { 38 | ListProductsParams params = new ListProductsParams(userId, page, size, sort); 39 | return listProductsService.listProducts(params); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /signin/src/main/java/tr/com/softtech/bestcommerce/signin/controllers/SignInController.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.controllers; 2 | 3 | 4 | import io.swagger.annotations.Api; 5 | import io.swagger.annotations.ApiOperation; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.web.bind.annotation.*; 9 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 10 | import tr.com.softtech.bestcommerce.signin.models.Credentials; 11 | import tr.com.softtech.bestcommerce.signin.security.JwtConstants; 12 | import tr.com.softtech.bestcommerce.signin.services.SignInService; 13 | 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | @RestController 17 | @RequestMapping(SignInController.ENDPOINT) 18 | @Api(produces = MediaType.APPLICATION_JSON_VALUE, tags = "Sign in") 19 | public class SignInController { 20 | 21 | public static final String ENDPOINT = "/v1/signin"; 22 | 23 | @Autowired 24 | private SignInService signInService; 25 | 26 | @CrossOrigin 27 | @ApiOperation("Sign in user") 28 | @PostMapping() 29 | public UserDto signIn( 30 | @RequestBody final Credentials credentials, 31 | HttpServletResponse response 32 | ) { 33 | UserDto userDto = signInService.signIn(credentials); 34 | addJwtHeaders(response, credentials); 35 | 36 | return userDto; 37 | } 38 | 39 | private void addJwtHeaders( 40 | HttpServletResponse response, Credentials credentials 41 | ) { 42 | response.setHeader( 43 | JwtConstants.HEADER_JWT_SUBJECT, credentials.getEmail()); 44 | response.setHeader( 45 | JwtConstants.HEADER_JWT_REMEMBER, credentials.getRemember()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/filters/ValidateJwtFilter.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.filters; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.gateway.filter.GatewayFilter; 5 | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.server.ServerWebExchange; 9 | import tr.com.softtech.bestcommerce.apigateway.security.JwtValidator; 10 | 11 | import java.util.List; 12 | import java.util.Optional; 13 | 14 | @Component 15 | public class ValidateJwtFilter extends AbstractGatewayFilterFactory { 16 | 17 | @Autowired 18 | private JwtValidator jwtValidator; 19 | 20 | public ValidateJwtFilter() { 21 | super(Config.class); 22 | } 23 | 24 | @Override 25 | public GatewayFilter apply(ValidateJwtFilter.Config config) { 26 | return (exchange, chain) -> { 27 | if (!isAuthenticated(exchange)) { 28 | exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED); 29 | return exchange.getResponse().setComplete(); 30 | } 31 | 32 | return chain.filter(exchange); 33 | }; 34 | } 35 | 36 | private boolean isAuthenticated(ServerWebExchange exchange) { 37 | boolean authenticated = false; 38 | 39 | Optional> authHeader = 40 | Optional.ofNullable(exchange.getRequest() 41 | .getHeaders().get("Authorization")); 42 | if (authHeader.isPresent()) { 43 | String authorization = authHeader.get().get(0) 44 | .replace("Bearer ", ""); 45 | authenticated = jwtValidator.validate(authorization); 46 | } 47 | 48 | return authenticated; 49 | } 50 | 51 | public static class Config { 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /signin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | tr.com.softtech.bestcommerce 12 | signin 13 | 0.0.1-SNAPSHOT 14 | Sign in 15 | BestCommerce - Sign in service 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-jpa 29 | 30 | 31 | 32 | com.h2database 33 | h2 34 | runtime 35 | 36 | 37 | 38 | org.projectlombok 39 | lombok 40 | true 41 | 42 | 43 | io.springfox 44 | springfox-swagger2 45 | 2.9.2 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | org.junit.vintage 54 | junit-vintage-engine 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /listproducts/src/main/java/tr/com/softtech/bestcommerce/listproducts/services/impl/ListProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.services.impl; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.PageRequest; 8 | import org.springframework.stereotype.Service; 9 | import tr.com.softtech.bestcommerce.listproducts.dtos.ProductDto; 10 | import tr.com.softtech.bestcommerce.listproducts.entities.Product; 11 | import tr.com.softtech.bestcommerce.listproducts.mappers.ListProductsParamMapper; 12 | import tr.com.softtech.bestcommerce.listproducts.mappers.ProductMapper; 13 | import tr.com.softtech.bestcommerce.listproducts.params.ListProductsParams; 14 | import tr.com.softtech.bestcommerce.listproducts.repositories.ProductRepository; 15 | import tr.com.softtech.bestcommerce.listproducts.search.ProductSpecification; 16 | import tr.com.softtech.bestcommerce.listproducts.services.ListProductsService; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | @Service 23 | @RequiredArgsConstructor 24 | public class ListProductServiceImpl implements ListProductsService { 25 | 26 | @Value("${product.search.inventoryThreshold}") 27 | private int inventoryThreshold; 28 | 29 | @Autowired 30 | private ProductRepository productRepository; 31 | 32 | @Autowired 33 | private ProductMapper productMapper; 34 | 35 | @Autowired 36 | private ListProductsParamMapper listProductsParamMapper; 37 | 38 | @Override 39 | public List listProducts(ListProductsParams params) { 40 | Page products = productRepository.findAll( 41 | ProductSpecification.userEqualTo(params.getUserId()) 42 | .and(ProductSpecification.inventoryGreaterThan(inventoryThreshold)), 43 | listProductsParamMapper.paramsToPageable(params)); 44 | List productDtos = products 45 | .stream() 46 | .map(p -> productMapper.entityToDto(p)) 47 | .collect(Collectors.toList()); 48 | return productDtos; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /signin/src/test/java/tr/com/softtech/bestcommerce/signin/controllers/SignInControllerTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.signin.controllers; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.mockito.Mock; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.boot.test.mock.mockito.MockBean; 9 | import org.springframework.test.context.junit.jupiter.SpringExtension; 10 | import tr.com.softtech.bestcommerce.signin.dtos.UserDto; 11 | import tr.com.softtech.bestcommerce.signin.entities.User; 12 | import tr.com.softtech.bestcommerce.signin.exceptions.NotFoundException; 13 | import tr.com.softtech.bestcommerce.signin.models.Credentials; 14 | import tr.com.softtech.bestcommerce.signin.services.SignInService; 15 | 16 | import javax.servlet.http.HttpServletResponse; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.junit.jupiter.api.Assertions.assertThrows; 20 | import static org.mockito.Mockito.when; 21 | 22 | @SpringBootTest 23 | @ExtendWith(SpringExtension.class) 24 | public class SignInControllerTest { 25 | 26 | @Autowired 27 | private SignInController signInController; 28 | 29 | @MockBean 30 | private SignInService signInService; 31 | 32 | @Mock 33 | private Credentials credentials; 34 | 35 | @Mock 36 | private HttpServletResponse response; 37 | 38 | @Mock 39 | private UserDto userDto; 40 | 41 | @Test 42 | public void whenValidCredentials_thenUserShouldAuthenticated() throws Exception { 43 | when(signInService.signIn(credentials)) 44 | .thenReturn(userDto); 45 | 46 | UserDto found = signInController.signIn(credentials, response); 47 | 48 | assertThat(found).isEqualTo(userDto); 49 | } 50 | 51 | @Test() 52 | public void whenCredentialsNotValid_thenShouldThrowNotFoundException() { 53 | when(signInService.signIn(credentials)) 54 | .thenThrow(new NotFoundException(User.class, "email")); 55 | 56 | Throwable thrown = assertThrows(NotFoundException.class, 57 | () -> { 58 | signInController.signIn(credentials, response); 59 | }); 60 | 61 | assertThat(thrown.getMessage()).isEqualTo("User:email"); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /listproducts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | tr.com.softtech.bestcommerce 12 | listproducts 13 | 0.0.1-SNAPSHOT 14 | List products 15 | BestCommerce - List products service 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-jpa 29 | 30 | 31 | 32 | com.h2database 33 | h2 34 | runtime 35 | 36 | 37 | 38 | org.projectlombok 39 | lombok 40 | true 41 | 42 | 43 | io.springfox 44 | springfox-swagger2 45 | 2.9.2 46 | 47 | 48 | org.hibernate.validator 49 | hibernate-validator 50 | 6.0.10.Final 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-test 55 | test 56 | 57 | 58 | org.junit.vintage 59 | junit-vintage-engine 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 1600320853828 29 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /listproducts/src/test/java/tr/com/softtech/bestcommerce/listproducts/mappers/ProductMapperTest.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.listproducts.mappers; 2 | 3 | 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit.jupiter.SpringExtension; 9 | import tr.com.softtech.bestcommerce.listproducts.dtos.ProductDto; 10 | import tr.com.softtech.bestcommerce.listproducts.entities.Product; 11 | import tr.com.softtech.bestcommerce.listproducts.enums.DeliveryOptions; 12 | import tr.com.softtech.bestcommerce.listproducts.enums.PaymentOptions; 13 | import tr.com.softtech.bestcommerce.listproducts.enums.ProductCategory; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | @SpringBootTest 18 | @ExtendWith(SpringExtension.class) 19 | public class ProductMapperTest { 20 | 21 | @Autowired 22 | private ProductMapper productMapper; 23 | 24 | @Test 25 | public void whenNonNullProduct_thenShouldReturnPoductDto() { 26 | Product product = new Product(); 27 | product.setName("name"); 28 | product.setDeliveryOptions(DeliveryOptions.FAST_DELIVERY); 29 | product.setDescription("desc"); 30 | product.setId(1L); 31 | product.setInventory(1); 32 | product.setPaymentOptions(PaymentOptions.DIRECT); 33 | product.setPrice(1); 34 | product.setProductCategory(ProductCategory.ELECTRONICS); 35 | product.setUserId(1L); 36 | 37 | ProductDto productDto = productMapper.entityToDto(product); 38 | 39 | assertThat(productDto.getDeliveryOptions()).isEqualTo(product.getDeliveryOptions()); 40 | assertThat(productDto.getDescription()).isEqualTo(product.getDescription()); 41 | assertThat(productDto.getId()).isEqualTo(product.getId()); 42 | assertThat(productDto.getInventory()).isEqualTo(product.getInventory()); 43 | assertThat(productDto.getName()).isEqualTo(product.getName()); 44 | assertThat(productDto.getPaymentOptions()).isEqualTo(product.getPaymentOptions()); 45 | assertThat(productDto.getProductCategory()).isEqualTo(product.getProductCategory()); 46 | assertThat(productDto.getPrice()).isEqualTo(product.getPrice()); 47 | 48 | assertThat(productDto).isNotEqualTo(product); 49 | } 50 | 51 | @Test 52 | public void whenNullProduct_thenShouldReturnNull() { 53 | ProductDto productDto = productMapper.entityToDto(null); 54 | 55 | assertThat(productDto).isNull(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /apigateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | tr.com.softtech.bestcommerce 12 | apigateway 13 | 0.0.1-SNAPSHOT 14 | API Gateway 15 | BestCommerce - API Gateway 16 | 17 | 18 | 11 19 | Hoxton.SR8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-gateway 26 | 27 | 28 | 29 | org.projectlombok 30 | lombok 31 | true 32 | 33 | 34 | io.jsonwebtoken 35 | jjwt-api 36 | 0.11.2 37 | 38 | 39 | io.jsonwebtoken 40 | jjwt-impl 41 | 0.11.2 42 | runtime 43 | 44 | 45 | io.jsonwebtoken 46 | jjwt-jackson 47 | 0.11.2 48 | runtime 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.junit.vintage 57 | junit-vintage-engine 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.cloud 67 | spring-cloud-dependencies 68 | ${spring-cloud.version} 69 | pom 70 | import 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | org.springframework.boot 79 | spring-boot-maven-plugin 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /apigateway/src/main/java/tr/com/softtech/bestcommerce/apigateway/filters/AddJwtFilter.java: -------------------------------------------------------------------------------- 1 | package tr.com.softtech.bestcommerce.apigateway.filters; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.gateway.filter.GatewayFilter; 5 | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.server.reactive.ServerHttpResponse; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.server.ServerWebExchange; 10 | import reactor.core.publisher.Mono; 11 | import tr.com.softtech.bestcommerce.apigateway.security.JwtConstants; 12 | import tr.com.softtech.bestcommerce.apigateway.security.JwtDetails; 13 | import tr.com.softtech.bestcommerce.apigateway.security.JwtGenerator; 14 | 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @Component 19 | public class AddJwtFilter extends AbstractGatewayFilterFactory { 20 | 21 | @Autowired 22 | private JwtGenerator jwtTokenGenerator; 23 | 24 | @Autowired 25 | private JwtConstants jwtConstants; 26 | 27 | public AddJwtFilter() { 28 | super(Config.class); 29 | } 30 | 31 | @Override 32 | public GatewayFilter apply(Config config) { 33 | return (exchange, chain) -> 34 | chain.filter(exchange) 35 | .then(Mono.fromRunnable(() -> { 36 | handleJwt(exchange); 37 | })); 38 | } 39 | 40 | private void handleJwt(ServerWebExchange exchange) { 41 | ServerHttpResponse response = exchange.getResponse(); 42 | if (response.getStatusCode().equals(HttpStatus.OK)) { 43 | addJwt(response); 44 | } 45 | } 46 | 47 | private void addJwt(ServerHttpResponse response) { 48 | Optional optionalJwtDetails = getJwtDetails(response); 49 | if (optionalJwtDetails.isPresent()) { 50 | response.getHeaders() 51 | .add(JwtConstants.HEADER_JWT, 52 | jwtTokenGenerator.generate(optionalJwtDetails.get())); 53 | } 54 | } 55 | 56 | private Optional getJwtDetails(ServerHttpResponse response) { 57 | JwtDetails jwtDetails = null; 58 | 59 | Optional> optionalSubject = Optional 60 | .ofNullable(response.getHeaders() 61 | .get(JwtConstants.HEADER_JWT_SUBJECT)); 62 | Optional> optionalRemember = Optional 63 | .ofNullable(response.getHeaders() 64 | .get(JwtConstants.HEADER_JWT_REMEMBER)); 65 | 66 | if (optionalRemember.isPresent() 67 | && optionalSubject.isPresent()) { 68 | 69 | jwtDetails = new JwtDetails(); 70 | jwtDetails.setSubject(optionalSubject.get().get(0)); 71 | if (optionalRemember.get().get(0).equals("true")) { 72 | jwtDetails.setExpiration(jwtConstants.getLongExpiration()); 73 | } else { 74 | jwtDetails.setExpiration(jwtConstants.getShortExpiration()); 75 | } 76 | } 77 | 78 | return Optional.ofNullable(jwtDetails); 79 | } 80 | 81 | public static class Config { 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /signin/.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 | -------------------------------------------------------------------------------- /apigateway/.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 | -------------------------------------------------------------------------------- /listproducts/.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 | -------------------------------------------------------------------------------- /signin/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 | -------------------------------------------------------------------------------- /apigateway/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 | -------------------------------------------------------------------------------- /listproducts/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 | -------------------------------------------------------------------------------- /BestCommerce.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "594fd093-c38b-42b6-b64f-454a22292068", 4 | "name": "Softtech-BestCommerce", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 6 | }, 7 | "item": [ 8 | { 9 | "name": "SignIn", 10 | "item": [ 11 | { 12 | "name": "sign in", 13 | "event": [ 14 | { 15 | "listen": "test", 16 | "script": { 17 | "id": "2918b8ad-cc5a-4714-8864-b4907597b780", 18 | "exec": [ 19 | "pm.test(\"Status code is 200\", function () {", 20 | " pm.response.to.have.status(200);", 21 | "});", 22 | "pm.test(\"X-JWT-Subject is present\", function () {", 23 | " pm.response.to.have.header(\"X-JWT-Subject\");", 24 | "});", 25 | "pm.test(\"X-JWT-Remember is present\", function () {", 26 | " pm.response.to.have.header(\"X-JWT-Remember\");", 27 | "});", 28 | "pm.test(\"X-JWT is present\", function () {", 29 | " pm.response.to.have.header(\"X-JWT\");", 30 | "});" 31 | ], 32 | "type": "text/javascript" 33 | } 34 | } 35 | ], 36 | "request": { 37 | "auth": { 38 | "type": "noauth" 39 | }, 40 | "method": "POST", 41 | "header": [], 42 | "body": { 43 | "mode": "raw", 44 | "raw": "{\n \"email\": \"mustafa@softtech.com.tr\",\n \"password\": \"pass1234\",\n \"remember\": \"true\"\n}", 45 | "options": { 46 | "raw": { 47 | "language": "json" 48 | } 49 | } 50 | }, 51 | "url": { 52 | "raw": "{{baseUrl}}/v1/signin", 53 | "host": [ 54 | "{{baseUrl}}" 55 | ], 56 | "path": [ 57 | "v1", 58 | "signin" 59 | ] 60 | } 61 | }, 62 | "response": [] 63 | }, 64 | { 65 | "name": "sign in - not exist", 66 | "event": [ 67 | { 68 | "listen": "test", 69 | "script": { 70 | "id": "7edaa88c-e117-43d3-8f2c-33ebf47f879c", 71 | "exec": [ 72 | "pm.test(\"Status code is 404\", function () {", 73 | " pm.response.to.have.status(404);", 74 | "});", 75 | "pm.test(\"X-JWT-Subject is present\", function () {", 76 | " pm.response.to.not.have.header(\"X-JWT-Subject\");", 77 | "});", 78 | "pm.test(\"X-JWT-Remember is present\", function () {", 79 | " pm.response.to.not.have.header(\"X-JWT-Remember\");", 80 | "});", 81 | "pm.test(\"X-JWT is present\", function () {", 82 | " pm.response.to.have.header(\"X-JWT\");", 83 | "});" 84 | ], 85 | "type": "text/javascript" 86 | } 87 | } 88 | ], 89 | "request": { 90 | "method": "POST", 91 | "header": [], 92 | "body": { 93 | "mode": "raw", 94 | "raw": "{\n \"email\": \"asdasdas\",\n \"password\": \"pass1234\",\n \"remember\": \"true\"\n}", 95 | "options": { 96 | "raw": { 97 | "language": "json" 98 | } 99 | } 100 | }, 101 | "url": { 102 | "raw": "{{baseUrl}}/v1/signin", 103 | "host": [ 104 | "{{baseUrl}}" 105 | ], 106 | "path": [ 107 | "v1", 108 | "signin" 109 | ] 110 | } 111 | }, 112 | "response": [] 113 | } 114 | ], 115 | "protocolProfileBehavior": {} 116 | }, 117 | { 118 | "name": "List Products", 119 | "item": [ 120 | { 121 | "name": "list products", 122 | "request": { 123 | "auth": { 124 | "type": "bearer", 125 | "bearer": [ 126 | { 127 | "key": "token", 128 | "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtdXN0YWZhQHNvZnR0ZWNoLmNvbS50ciIsImlhdCI6MTYwMDQ1MTI4OSwiZXhwIjoxNjAwNDcyODg5fQ.TAqcDfu4Q6NSnin1m4yEu8npEKZqcYs3xs9L9sZOtYc", 129 | "type": "string" 130 | } 131 | ] 132 | }, 133 | "method": "GET", 134 | "header": [], 135 | "url": { 136 | "raw": "{{baseUrl}}/v1/products?userId=10001&size=10&page=0&sort=price,asc,inventory,desc", 137 | "host": [ 138 | "{{baseUrl}}" 139 | ], 140 | "path": [ 141 | "v1", 142 | "products" 143 | ], 144 | "query": [ 145 | { 146 | "key": "userId", 147 | "value": "10001" 148 | }, 149 | { 150 | "key": "size", 151 | "value": "10" 152 | }, 153 | { 154 | "key": "page", 155 | "value": "0" 156 | }, 157 | { 158 | "key": "sort", 159 | "value": "price,asc,inventory,desc" 160 | } 161 | ] 162 | } 163 | }, 164 | "response": [] 165 | }, 166 | { 167 | "name": "list products - bad request - no param", 168 | "request": { 169 | "auth": { 170 | "type": "bearer", 171 | "bearer": [ 172 | { 173 | "key": "token", 174 | "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtdXN0YWZhQHNvZnR0ZWNoLmNvbS50ciIsImlhdCI6MTYwMDQ1MTI4OSwiZXhwIjoxNjAwNDcyODg5fQ.TAqcDfu4Q6NSnin1m4yEu8npEKZqcYs3xs9L9sZOtYc", 175 | "type": "string" 176 | } 177 | ] 178 | }, 179 | "method": "GET", 180 | "header": [], 181 | "url": { 182 | "raw": "{{baseUrl}}/v1/products?userId=10001&size=10&page=0&sort=price,asc,inventory,desc", 183 | "host": [ 184 | "{{baseUrl}}" 185 | ], 186 | "path": [ 187 | "v1", 188 | "products" 189 | ], 190 | "query": [ 191 | { 192 | "key": "userId", 193 | "value": "10001" 194 | }, 195 | { 196 | "key": "size", 197 | "value": "10" 198 | }, 199 | { 200 | "key": "page", 201 | "value": "0" 202 | }, 203 | { 204 | "key": "sort", 205 | "value": "price,asc,inventory,desc" 206 | } 207 | ] 208 | } 209 | }, 210 | "response": [] 211 | }, 212 | { 213 | "name": "list products - bad request - size is 0", 214 | "event": [ 215 | { 216 | "listen": "test", 217 | "script": { 218 | "id": "a4283685-8d95-4fe2-8097-371090e4cb39", 219 | "exec": [ 220 | "pm.test(\"Status code is 400\", function () {", 221 | " pm.response.to.have.status(400);", 222 | "});" 223 | ], 224 | "type": "text/javascript" 225 | } 226 | } 227 | ], 228 | "request": { 229 | "auth": { 230 | "type": "bearer", 231 | "bearer": [ 232 | { 233 | "key": "token", 234 | "value": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtdXN0YWZhQHNvZnR0ZWNoLmNvbS50ciIsImlhdCI6MTYwMDQ1MTI4OSwiZXhwIjoxNjAwNDcyODg5fQ.TAqcDfu4Q6NSnin1m4yEu8npEKZqcYs3xs9L9sZOtYc", 235 | "type": "string" 236 | } 237 | ] 238 | }, 239 | "method": "GET", 240 | "header": [], 241 | "url": { 242 | "raw": "{{baseUrl}}/v1/products?userId=10001&size=0&page=0&sort=price,asc,inventory,desc", 243 | "host": [ 244 | "{{baseUrl}}" 245 | ], 246 | "path": [ 247 | "v1", 248 | "products" 249 | ], 250 | "query": [ 251 | { 252 | "key": "userId", 253 | "value": "10001" 254 | }, 255 | { 256 | "key": "size", 257 | "value": "0" 258 | }, 259 | { 260 | "key": "page", 261 | "value": "0" 262 | }, 263 | { 264 | "key": "sort", 265 | "value": "price,asc,inventory,desc" 266 | } 267 | ] 268 | } 269 | }, 270 | "response": [] 271 | }, 272 | { 273 | "name": "list products - unauthorized", 274 | "event": [ 275 | { 276 | "listen": "test", 277 | "script": { 278 | "id": "b84b4860-b71c-457e-bf3f-cffa85f88d52", 279 | "exec": [ 280 | "pm.test(\"Status code is 401\", function () {", 281 | " pm.response.to.have.status(401);", 282 | "});" 283 | ], 284 | "type": "text/javascript" 285 | } 286 | } 287 | ], 288 | "request": { 289 | "method": "GET", 290 | "header": [ 291 | { 292 | "key": "Authorization", 293 | "value": "Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJnZWVldyIsImlhdCI6MTYwMDM2MDQ3MCwiZXhwIjoxNjAwMzgyMDcwfQ.kDlZ-tj6-URO8VVBLdstUwCxADHXKwo32Dbbj4pGdgA", 294 | "type": "text" 295 | } 296 | ], 297 | "url": { 298 | "raw": "{{baseUrl}}/v1/products?userId=10001&size=10&page=0&sort=price,asc,inventory,desc", 299 | "host": [ 300 | "{{baseUrl}}" 301 | ], 302 | "path": [ 303 | "v1", 304 | "products" 305 | ], 306 | "query": [ 307 | { 308 | "key": "userId", 309 | "value": "10001" 310 | }, 311 | { 312 | "key": "size", 313 | "value": "10" 314 | }, 315 | { 316 | "key": "page", 317 | "value": "0" 318 | }, 319 | { 320 | "key": "sort", 321 | "value": "price,asc,inventory,desc" 322 | } 323 | ] 324 | } 325 | }, 326 | "response": [] 327 | } 328 | ], 329 | "protocolProfileBehavior": {} 330 | } 331 | ], 332 | "variable": [ 333 | { 334 | "id": "5f106cf7-9767-449a-bdb6-7ad0b9313b8d", 335 | "key": "baseUrl", 336 | "value": "http://localhost:8080" 337 | } 338 | ], 339 | "protocolProfileBehavior": {} 340 | } 341 | -------------------------------------------------------------------------------- /signin/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 | -------------------------------------------------------------------------------- /apigateway/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 | -------------------------------------------------------------------------------- /listproducts/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 | --------------------------------------------------------------------------------