Skip to content

Commit b9468cd

Browse files
committedApr 20, 2021
added docker configuration
1 parent 999e0f9 commit b9468cd

28 files changed

+232
-236
lines changed
 

‎.DS_Store

0 Bytes
Binary file not shown.

‎AWS_AMI_KEY.pem

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIIEogIBAAKCAQEAkESStV6hMMSMdmWIupISR58qAET1iFOXIV3qV83VWsBdaQ8o
3+
JZQJq7SjxI00JLuUHXwPzMhElmKx+d6nxQMv9xOdwgCDvj0Juir8xHqfLhnyV3vi
4+
K7SRbE9fpUGcx2vafbc6E1gnxZz5LibTB5QvqeiSs/jTOQ2cKCzSbChG0R+8jF1Y
5+
1Y9zIFs8HwjeXLQQsbDwi21nMfGRoCEDlHoXZYy1JmbQyu3V3Lld26A+Ye/P/8ju
6+
EgQP5gZd3YaTnIknJDCqdHZyHbCoNumBFWY57RGFByj/CHs4NTJqN7bZ/EUHS498
7+
uM3j00dVvPUp/UcvSKfrGzC+Qgmj/6FUt3KQiQIDAQABAoIBAGBrhEX1pfOrGVm0
8+
CIrxP4hgxziA3j0r6PEjDJF8fyD1OjkSKTncVA5PX7joyrXWLGr8VK8AFl8QPXUL
9+
q8NPmwoeMSzNHT/TGaI0QtWqQqMUMlTn9kRRnXPvJLSVQoxB+DhXclglbgd0H1IK
10+
HraNAsIjL5FbNwiFoR10v3oL/TCcbWvgGxxdYF8HW3GlC87bdPMtsQmzz7uJYzNt
11+
4pjWUaAHgaWNkL5EkKqfn9zCKUIox2USnKCOI9eTLteSRAho7m913E1CmSOQ/GrE
12+
QMIPrV2KpSCX1p9SGqGo+zgm+I1R/YDQ7yaE2Gw2YiiwB6vF7FiXs2ICyCfij3yI
13+
7158apECgYEAxkvAvny6nMgseamiiFEMbWhGpL/RuMlndA5qxKZfqyZkq1XdnH9N
14+
Sh1rochIWLEE6oF2C+Zgl+f+P3hItD0jkAC3Xy99+vGrJ8GtR/DQPWNPyqLJ1JM+
15+
jfHIT5Ru2q3s97OUVwdnMYqaleg1RS9Sa8m1CJTEcJiObXXYfz1l/C0CgYEAuj/y
16+
va5IXQ38oifHx962y0cb0zN6wYql4oKq18M3RmaZ1zqmSQz1mNyK5U6dC3aEmExz
17+
nXXO3lbLMqeDXgn+2smm6yFxFZhbRwe7gpElpoWJcMca40aER4mX0MRWV3noFb/K
18+
wQdMq7JYuZgsxWERRGPY1ecEHEVpVQpsChxj800CgYBrA2a5ZkavZbfa0JlOR68V
19+
PDkjoAFmYArcrwsfpUnr64RYkrZORsVHQilb3eJtOtsUU1mJgoKOeDzVs+xImNYg
20+
WMKdM9whGVrs0bDaKjO3bWkaSk/x0KTppZocmFZa3ZIM+3UKoowmSE60p+RXufoZ
21+
AXoZb2+z9CCpIff8cv4e4QKBgALIP8ULnHMfaV22wGpA7nQc7NJ722KWwqGemBS/
22+
Cs1XbQblDmTa97Q/3ydLxFbOf26S/cslXmC95S0tiW3XMmJsTr0Gc90BuKNX/zoV
23+
Fv3k0sfHgaRRglpbONRainumC4x/n/TAOin6cQ7cshaEu7BM2YlgeRQ/CTLHBBQm
24+
lmulAoGAK0Hr7PfFHr4ggrONTRLMu9lbvnRTdy69zR6ifHkuyF6wsJ/sbsUt0NcS
25+
lWUuZxXNHUZriOmRhhsanc45THFK+KWt++kig+afAo+MIN+tEzbfcABHV3LwXyI7
26+
vUrndFRYvq38NCh6a8a4MqpolqE5WrxUhtMcnHJBOFAeH2Hs0TA=
27+
-----END RSA PRIVATE KEY-----

‎Dockerfile

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
FROM 3.8.1-jdk-11-slim AS build
1+
#FROM maven:3.6.0-jdk-11-slim AS build
2+
FROM maven:3.6.1-jdk-8-slim AS build
23
RUN mkdir -p workspace
34
WORKDIR workspace
45
COPY pom.xml /workspace
56
COPY src /workspace/src
67
COPY frontend /workspace/frontend
7-
COPY data2.csv /workspace/data.csv
8-
RUN mvn -f pom.xml clean package
9-
10-
FROM openjdk:11-alpine
8+
COPY data2.csv /workspace
9+
RUN mvn -f pom.xml clean install -DskipTests=true
10+
##RUN ./mvnw clean package -DskipTests
11+
#
12+
##FROM adoptopenjdk/openjdk11:alpine-jre
13+
FROM openjdk:8-alpine
1114
COPY --from=build /workspace/target/*.jar app.jar
15+
#EXPOSE 8080
16+
#ENTRYPOINT ["java","-jar","app.jar"]
17+
18+
19+
#FROM adoptopenjdk/openjdk11:alpine-jre
20+
21+
#COPY target/*.jar app.jar
1222
EXPOSE 8080
13-
ENTRYPOINT ["java","-jar","app.jar"]
23+
ENTRYPOINT ["java","-jar","app.jar"]

‎docker-compose.yml

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,48 @@ version: '3'
22

33
services:
44

5-
data-postgres:
6-
image: "postgres:13.2-alpine"
7-
container_name: data-postgres
8-
9-
volumes:
10-
- flamup-data:var/lib/postgres/data
11-
12-
5+
db:
6+
image: "postgres:9.6-alpine"
7+
container_name: db
8+
restart: always
139

1410
ports:
1511
- 5432:5432
1612

13+
# volumes:
14+
# - postgres_data:/var/lib/postgresql/data
15+
1716
environment:
1817
- POSTGRES_DB=flamup
1918
- POSTGRES_USER=postgres
2019
- POSTGRES_PASSWORD=postgres
20+
- PGDATA=/var/lib/postgresql/data/pgdata
2121

2222

2323
flamup:
24-
build: .
24+
build: ./
25+
image: "thesyncoder/flamup:0.0.1"
2526
container_name: flamup
2627
environment:
27-
- DB_SERVER=data-postgres
28+
- DB_SERVER:db
2829
- POSTGRES_DB=flamup
2930
- POSTGRES_USER=postgres
3031
- POSTGRES_PASSWORD=postgres
3132
ports:
3233
- 8080:8080 # Forward the exposed port 8080 on the container to port 8080 on the host machine
33-
links:
34-
- data-postgres
34+
35+
depends_on:
36+
- db
37+
38+
3539

3640
volumes:
37-
flamup-data:
41+
postgres_data:
42+
43+
44+
45+
46+
3847

3948

4049

‎frontend/src/Components/DressShow.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ const DressCard = ({dress}) => {
3030
<Paper outlined elevation={10} className={classes.paper} >
3131
<Grid container alignItems="center" direction="column">
3232
<Grid item container justify="center">
33-
<img src={`https://${dress.image}`} className={classes.image} />
33+
<img src={`https://${dress.c_image}`} className={classes.image} />
3434
</Grid>
3535
<Grid item >
36-
<Typography variant="subtitle1" color="textSecondary">{dress.dresstype}</Typography>
36+
<Typography variant="subtitle1" color="textSecondary">{dress.b_dresstype}</Typography>
3737
</Grid>
38-
{dress.arrival.toLowerCase() === "new" ?
38+
{dress.e_arrival.toLowerCase() === "new" ?
3939
<Grid item>
4040
<Typography variant="h5" color="primary">New Arrival</Typography>
4141
</Grid>
4242
: <Grid></Grid>
4343
}
4444
{
45-
dress.arrival.toLowerCase() === "old" ?
45+
dress.e_arrival.toLowerCase() === "old" ?
4646
<Grid item>
4747
<Typography variant="h5">Price :
4848
<span style={{textDecoration:"line-through"}}>
49-
{dress.price}</span>
50-
{' '} <span style={{ color: "red" }}>{dress.discount}</span></Typography>
49+
{dress.d_price}</span>
50+
{' '} <span style={{ color: "red" }}>{dress.f_discount}</span></Typography>
5151
</Grid>
52-
: <Grid>{dress.price}</Grid>
52+
: <Grid>{dress.d_price}</Grid>
5353
}
5454
</Grid>
5555
</Paper>

‎frontend/src/Pages/CartScreen.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { withRouter } from "react-router";
1818
const useStyles = makeStyles({
1919
table: {
2020
minWidth: 650,
21+
marginTop :"3em"
2122
},
2223
});
2324

@@ -112,13 +113,13 @@ function BasicTable() {
112113
{products && products.map((row,i) => {
113114
const display = row.quantity <= 0;
114115
return (
115-
<TableRow key={row.name} >
116+
<TableRow key={row.b_dresstype} >
116117
<TableCell component="th" scope="row">
117-
{row.product.dresstype}
118+
{row.product.b_dresstype}
118119
</TableCell>
119120
<TableCell align="right">{row.quantity}</TableCell>
120-
<TableCell align="right">{row.product.arrival.toLowerCase() === 'old' ?
121-
'Rs.' + row.product.discount : row.product.price }</TableCell>
121+
<TableCell align="right">{row.product.e_arrival.toLowerCase() === 'old' ?
122+
'Rs.' + row.product.f_discount : row.product.d_price }</TableCell>
122123
<TableCell align="right">
123124
<ButtonGroup>
124125
<Button onClick={() => handleInc(i, row.id)}>+</Button>

‎frontend/src/Pages/Products.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const Products = () => {
170170

171171

172172
const handlePersist = () => {
173-
var msg = dress.arrival.toLowerCase() === 'old' ? "O" : "N";
173+
var msg = dress.e_arrival.toLowerCase() === 'old' ? "O" : "N";
174174
axios.get(SESSION_PERSIST_URL + msg)
175175
.then(response => {
176176
console.log(response);
@@ -183,23 +183,21 @@ const Products = () => {
183183
justify="center"
184184
direction="column" >
185185
<Grid item >
186-
<img src={`https://${dress.image}`} className={classes.mimage} />
186+
<img src={`https://${dress.c_image}`} className={classes.mimage} />
187187
</Grid>
188188
<Grid item>
189-
<Typography variant="h4">{dress.dresstype}</Typography>
190-
</Grid>
191-
<Grid item>
192-
<Typography variant="h4">{dress.dresstypeype}</Typography>
189+
<Typography variant="h4">{dress.b_dresstype}</Typography>
193190
</Grid>
191+
194192
{
195-
dress.arrival.toLowerCase() === "old" ?
193+
dress.e_arrival.toLowerCase() === "old" ?
196194
<Grid item>
197195
<Typography variant="h5">Price :
198196
<span style={{ textDecoration: "line-through" }}>
199-
{dress.price}</span>
200-
{' '} <span style={{ color: "red" }}>{dress.discount}</span></Typography>
197+
{dress.d_price}</span>
198+
{' '} <span style={{ color: "red" }}>{dress.f_discount}</span></Typography>
201199
</Grid>
202-
: <Grid>{dress.price}</Grid>
200+
: <Grid>{dress.d_price}</Grid>
203201
}
204202
<Grid container spacing={2}>
205203
<Grid item>
@@ -270,7 +268,7 @@ const Products = () => {
270268
<TextField label="Search for dress types"
271269
value={search} onChange={handleChange}
272270
onKeyDown={handleKeyDown}
273-
placeholder="Enter any dress type like denim .."fullWidth autoFocus />
271+
placeholder="Enter any dress type like denim .." fullWidth autoFocus />
274272
</Grid>
275273
</Grid>
276274

‎package.json

-7
This file was deleted.

‎pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<name>spring</name>
1515
<description>Demo project for Spring Boot</description>
1616
<properties>
17-
<java.version>11</java.version>
17+
<java.version>8</java.version>
1818
<frontend-maven-plugin.version>1.11.3</frontend-maven-plugin.version>
1919
<node.version>v14.16.0</node.version>
2020
<npm.version>6.14.11</npm.version>

‎src/main/java/com/flamup/spring/Application.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.domain.EntityScan;
6+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
57

68
@SpringBootApplication
9+
@EntityScan("com.flamup.spring.Models")
10+
@EnableJpaRepositories("com.flamup.spring.Repositories")
711
public class Application {
812

913
public static void main(String[] args) {
10-
11-
// SpringApplication.run(Application.class, args);
12-
SpringApplication application = new SpringApplication(Application.class);
13-
application.setAdditionalProfiles("ssl");
14-
application.run(args);
14+
SpringApplication.run(Application.class, args);
1515
}
1616

1717
}

‎src/main/java/com/flamup/spring/Controllers/AuthController.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33

44
import com.flamup.spring.auth.AppUserService;
5-
import com.flamup.spring.auth.ApplicationUser;
5+
import com.flamup.spring.Models.ApplicationUser;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.security.authentication.AnonymousAuthenticationToken;
88
import org.springframework.security.core.Authentication;
99
import org.springframework.security.core.context.SecurityContextHolder;
10-
import org.springframework.security.core.userdetails.UserDetails;
1110
import org.springframework.web.bind.annotation.GetMapping;
1211
import org.springframework.web.bind.annotation.RequestMapping;
1312
import org.springframework.web.bind.annotation.RestController;

‎src/main/java/com/flamup/spring/auth/AppUserRole.java renamed to ‎src/main/java/com/flamup/spring/Models/AppUserRole.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.flamup.spring.auth;
1+
package com.flamup.spring.Models;
22

33

44
public enum AppUserRole {

‎src/main/java/com/flamup/spring/auth/ApplicationUser.java renamed to ‎src/main/java/com/flamup/spring/Models/ApplicationUser.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
package com.flamup.spring.auth;
1+
package com.flamup.spring.Models;
22

33

4-
import com.sun.istack.NotNull;
54
import lombok.*;
65
import org.springframework.security.core.GrantedAuthority;
76
import org.springframework.security.core.authority.SimpleGrantedAuthority;

‎src/main/java/com/flamup/spring/Models/LoginRequest.java

-16
This file was deleted.

‎src/main/java/com/flamup/spring/Models/Product.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
@Entity
88
@Table(name = "clothes")
9-
@AllArgsConstructor
10-
@NoArgsConstructor
119
@Getter
1210
@Setter
11+
@NoArgsConstructor
12+
@AllArgsConstructor
1313
@ToString
1414
public class Product {
1515

@@ -21,12 +21,19 @@ public enum sex{
2121
@Id
2222
Long id;
2323
@Enumerated(EnumType.STRING)
24-
sex sex;
25-
String dresstype;
26-
String image;
27-
String price;
28-
String arrival;
29-
int discount;
24+
25+
@Column(name = "sex")
26+
sex a_sex;
27+
@Column(name = "dresstype")
28+
String b_dresstype;
29+
@Column(name = "image")
30+
String c_image;
31+
@Column(name = "price")
32+
String d_price;
33+
@Column(name = "arrival")
34+
String e_arrival;
35+
@Column(name = "discount")
36+
int f_discount;
3037

3138

3239
}

‎src/main/java/com/flamup/spring/Models/RegistrationRequest.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.flamup.spring.Models;
22

33

4-
import com.flamup.spring.auth.ApplicationUser.Gender;
54
import lombok.*;
65

76

‎src/main/java/com/flamup/spring/auth/ApplicationUserRepository.java renamed to ‎src/main/java/com/flamup/spring/Repositories/ApplicationUserRepository.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package com.flamup.spring.auth;
1+
package com.flamup.spring.Repositories;
22

3+
import com.flamup.spring.Models.ApplicationUser;
34
import org.springframework.data.jpa.repository.JpaRepository;
45
import org.springframework.stereotype.Repository;
56

‎src/main/java/com/flamup/spring/Repositories/ProductRepository.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616
@Transactional
1717
public interface ProductRepository extends JpaRepository<Product, Long> {
1818

19-
Optional<Product> findProductByDresstype(String dresstype);
2019

2120
Optional<Product> findProductById( Long id);
2221

23-
@Query("select p from Product p where LOWER(p.dresstype) LIKE LOWER(CONCAT('%', :type, '%'))")
24-
List<Product> findProductsByDresstype(@Param("type") String type);
22+
@Query("select p from Product p where LOWER(p.b_dresstype) LIKE LOWER(CONCAT('%', :type, '%'))")
23+
List<Product> findProductsByB_Dresstype(@Param("type") String type);
2524

26-
@Query(value = "select p from Product p where LOWER(p.sex)=lower(:sex) order by p.arrival desc ")
27-
Page<Product> findProductBySex(@Param("sex") String sex, Pageable paging);
25+
@Query(value = "select p from Product p where LOWER(p.a_sex)=lower(:sex) order by p.e_arrival desc ")
26+
Page<Product> findProductByA_sex(@Param("sex") String sex, Pageable paging);
2827

29-
@Query(value = "select p from Product p where LOWER(p.arrival)=LOWER(:arrival) and LOWER(p.sex)=LOWER(:sex)")
30-
List<Product> findProductsByArrivalAndSex(@Param("arrival") String arrival, @Param("sex") String sex);
28+
@Query(value = "select p from Product p where LOWER(p.e_arrival)=LOWER(:arrival) and LOWER(p.a_sex)=LOWER(:sex)")
29+
List<Product> findProductsByE_arrivalAndA_sex(@Param("arrival") String arrival, @Param("sex") String sex);
3130

3231

3332
}

‎src/main/java/com/flamup/spring/Services/CartService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ public HashMap<String, Object> getProducts(){
8888
hs.put("products" , orders);
8989
int price =0;
9090
for ( OrderItem order : orders ){
91-
if ( order.getProduct().getArrival().toLowerCase(Locale.ROOT).equals("old")){
92-
price += order.getQuantity() * order.getProduct().getDiscount();
91+
if ( order.getProduct().getE_arrival().toLowerCase(Locale.ROOT).equals("old")){
92+
price += order.getQuantity() * order.getProduct().getF_discount();
9393
}
9494
else {
95-
price += order.getQuantity() * sanitizePrice(order.getProduct().getPrice());
95+
price += order.getQuantity() * sanitizePrice(order.getProduct().getD_price());
9696
}
9797
}
9898
hs.put("total", price);

‎src/main/java/com/flamup/spring/Services/ProductService.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ public ProductService(ProductRepository productRepository) {
2424
this.productRepository = productRepository;
2525
}
2626

27-
public Product getByDressType( String dresstype ){
28-
return productRepository.findProductByDresstype(dresstype)
29-
.orElseThrow(() -> new IllegalStateException("Dress not found"));
30-
}
27+
// public Product getByDressType( String dresstype ){
28+
// return productRepository.findProductByB_dresstype(dresstype)
29+
// .orElseThrow(() -> new IllegalStateException("Dress not found"));
30+
// }
3131

3232
public List<Product> getProductsByDressType( String dresstype){
33-
return productRepository.findProductsByDresstype(dresstype);
33+
return productRepository.findProductsByB_Dresstype(dresstype);
3434
}
3535

3636

3737
public HashMap<String, Object> getProductsBySex(String sex, Integer pageSize, Integer page, Map<Boolean, Long> countBySex){
3838

3939
Pageable paging = PageRequest.of(page , pageSize);
40-
Page<Product> prods = productRepository.findProductBySex(sex, paging);
41-
List<Product> newProds = productRepository.findProductsByArrivalAndSex("new" ,sex);
40+
Page<Product> prods = productRepository.findProductByA_sex(sex, paging);
41+
List<Product> newProds = productRepository.findProductsByE_arrivalAndA_sex("new" ,sex);
4242
Integer totalPages = prods.getTotalPages();
4343
List<Product> products = prods.getContent();
4444
products = rearrange(products, countBySex, newProds);

‎src/main/java/com/flamup/spring/Services/RegistrationService.java

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.flamup.spring.Services;
22

3-
import com.flamup.spring.Models.LoginRequest;
43
import com.flamup.spring.Models.RegistrationRequest;
5-
import com.flamup.spring.auth.AppUserRole;
4+
import com.flamup.spring.Models.AppUserRole;
65
import com.flamup.spring.auth.AppUserService;
7-
import com.flamup.spring.auth.ApplicationUser;
6+
import com.flamup.spring.Models.ApplicationUser;
87
import lombok.AllArgsConstructor;
98
import org.springframework.stereotype.Service;
109

@@ -44,19 +43,5 @@ else if ( request.getGender().toUpperCase(Locale.ROOT).equals("FEMALE")){
4443
}
4544

4645

47-
public ApplicationUser login(LoginRequest request ){
48-
System.out.println("Delete me line 48" + request);
49-
ApplicationUser user = appUserService.loginUser( new ApplicationUser(
50-
"",
51-
"",
52-
"",
53-
request.getPassword(),
54-
request.getEmail(),
55-
AppUserRole.USER,
56-
ApplicationUser.Gender.MALE
57-
));
58-
user.setPassword("");
59-
return user;
6046

61-
}
6247
}

‎src/main/java/com/flamup/spring/auth/AppUserService.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.flamup.spring.auth;
22

3+
import com.flamup.spring.Models.ApplicationUser;
4+
import com.flamup.spring.Repositories.ApplicationUserRepository;
35
import org.springframework.beans.factory.annotation.Autowired;
46
import org.springframework.security.core.userdetails.UserDetails;
57
import org.springframework.security.core.userdetails.UserDetailsService;
@@ -37,7 +39,7 @@ public UserDetails loadUserByUsername(String email) throws UsernameNotFoundExcep
3739

3840
public String signupUser( ApplicationUser applicationUser){
3941
boolean userExists = applicationUserRepository
40-
.findApplicationUsersByEmail(applicationUser.getEmail())
42+
.findApplicationUsersByEmail(applicationUser.getUsername())
4143
.isPresent();
4244

4345
if ( userExists ){
@@ -53,24 +55,5 @@ public String signupUser( ApplicationUser applicationUser){
5355
}
5456

5557

56-
public ApplicationUser loginUser(ApplicationUser applicationUser){
5758

58-
System.out.println("loginUser" + applicationUser);
59-
System.out.println("Helllllooooooo");
60-
61-
62-
Optional<ApplicationUser> appUser = applicationUserRepository
63-
.findApplicationUsersByEmail(applicationUser.getEmail());
64-
65-
66-
if (appUser.isPresent()){
67-
throw new IllegalStateException("Email does not exist");
68-
}
69-
ApplicationUser oldAppUser = appUser.get();
70-
if (bCryptPasswordEncoder.matches(applicationUser.getPassword(), oldAppUser.getPassword())){
71-
return oldAppUser;
72-
}
73-
else
74-
throw new IllegalStateException("Password is incorrect");
75-
}
7659
}

‎src/main/java/com/flamup/spring/security/WebSecurityConfig.java

+1-19
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
//import javax.sql.DataSource;
2222

23-
import static com.flamup.spring.auth.AppUserRole.*;
23+
import static com.flamup.spring.Models.AppUserRole.*;
2424

2525
@Configuration
2626
@EnableWebSecurity
@@ -38,10 +38,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
3838
@Autowired
3939
private CustomLogoutHandler logoutHandler;
4040

41-
42-
43-
44-
4541
@Autowired
4642
public WebSecurityConfig(PasswordEncoder passwordEncoder, AppUserService appUserService) {
4743
this.passwordEncoder = passwordEncoder;
@@ -55,26 +51,16 @@ public void configure(WebSecurity registry) throws Exception {
5551
.antMatchers("/actuator/**")
5652
.antMatchers("/swagger-ui.html")
5753
.antMatchers("/webjars/**");
58-
59-
6054
}
6155

6256
@Override
6357
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
6458
auth.authenticationProvider(daoAuthenticationProvider());
6559

66-
67-
// auth.jdbcAuthentication().dataSource(dataSource)
68-
// .usersByUsernameQuery("SELECT EMAIL AS PRINCIPAL, PASSWORD AS CREDENTIALS, true FROM APPLICATION_USER WHERE EMAIL=?")
69-
// .authoritiesByUsernameQuery("SELECT EMAIL AS PRINCIPAL, APP_USER_ROLE AS ROLE FROM APPLICATION_USER WHERE EMAIL=?")
70-
// .passwordEncoder(passwordEncoder).rolePrefix("ROLE_");
71-
72-
// auth.jdbcAuthentication().dataSource(dataSource)
7360
}
7461

7562

7663

77-
7864
@Override
7965
protected void configure(HttpSecurity http) throws Exception {
8066
http.
@@ -83,7 +69,6 @@ protected void configure(HttpSecurity http) throws Exception {
8369
.antMatchers("/","/static/**", "index*", "/css/*", "/js/*","/media/*","*.ico","*.png").permitAll()
8470
.antMatchers("/api/register").permitAll()
8571
.antMatchers("/api/auth").permitAll()
86-
// .antMatchers("/api/login").permitAll()
8772
.antMatchers("/api/persist/**").authenticated()
8873

8974
.antMatchers("/api/v1/**").authenticated()
@@ -104,9 +89,6 @@ protected void configure(HttpSecurity http) throws Exception {
10489
.addLogoutHandler(logoutHandler)
10590
.logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK));
10691

107-
108-
109-
11092
}
11193

11294

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
server.error.include-message=always
4+
server.error.include-binding-errors=always
5+
6+
7+
spring.datasource.url=jdbc:postgresql://db:5432/flamup
8+
spring.datasource.username=postgres
9+
spring.datasource.password=postgres
10+
11+
spring.jpa.hibernate.ddl-auto=update
12+
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
13+
spring.jpa.properties.hibernate.format-sql=true
14+
spring.jpa.show-sql=true
15+
16+
17+
spring.session.jdbc.initialize-schema=always
18+
spring.session.jdbc.table-name=SPRING_SESSION
19+
spring.session.store-type=jdbc

‎src/main/resources/application.yml

+57-55
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,59 @@
1-
2-
server:
3-
error:
4-
include-message: always
5-
include-binding-errors: always
6-
7-
8-
9-
10-
11-
12-
spring:
13-
datasource:
14-
password: papai120499
15-
url: jdbc:postgresql://localhost:5432/flamup
16-
username: shuvayan
17-
18-
jpa:
19-
hibernate:
20-
ddl-auto: update
21-
properties:
22-
hibernate:
23-
dialect: org.hibernate.dialect.PostgreSQLDialect
24-
format_sql: true
25-
show-sql: true
26-
27-
session:
28-
store-type: jdbc
29-
jdbc:
30-
table-name: SPRING_SESSION
31-
initialize-schema: never
32-
33-
34-
35-
36-
37-
38-
39-
40-
41-
# mail:
42-
# host: localhost
43-
# port: 1025
44-
# username: hello
45-
# password: hello
461
#
2+
#server:
3+
# error:
4+
# include-message: always
5+
# include-binding-errors: always
6+
#
7+
#
8+
#spring:
9+
# datasource:
10+
## password: papai120499
11+
## url: jdbc:postgresql://localhost:5432/testdb
12+
## username: shuvayan
13+
# url : jdbc:postgresql://${DB_SERVER}/${POSTGRES_DB}
14+
# username : ${POSTGRES_USER}
15+
# password : ${POSTGRES_PASSWORD}
16+
#
17+
# jpa:
18+
# hibernate:
19+
# ddl-auto: update
4720
# properties:
48-
# mail:
49-
# smtp:
50-
# ssl:
51-
# trust: "*"
52-
# auth: true
53-
# starttls:
54-
# enable: true
55-
# connectiontimeout: 5000
56-
# timeout: 3000
57-
# writetimeout: 5000
21+
# hibernate:
22+
# dialect: org.hibernate.dialect.PostgreSQLDialect
23+
# format_sql: true
24+
# jdbc:
25+
# lob:
26+
# non_contextual_creation: true
27+
# show-sql: true
28+
#
29+
# session:
30+
# store-type: jdbc
31+
# jdbc:
32+
# table-name: SPRING_SESSION
33+
# initialize-schema: always
34+
#
35+
#
36+
#
37+
#
38+
#
39+
#
40+
#
41+
#
42+
#
43+
## mail:
44+
## host: localhost
45+
## port: 1025
46+
## username: hello
47+
## password: hello
48+
##
49+
## properties:
50+
## mail:
51+
## smtp:
52+
## ssl:
53+
## trust: "*"
54+
## auth: true
55+
## starttls:
56+
## enable: true
57+
## connectiontimeout: 5000
58+
## timeout: 3000
59+
## writetimeout: 5000

‎src/main/resources/data-postgres.sql

+19-20
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,28 @@ create table if not exists clothes
3434

3535
create sequence student_sequence start 1 increment 1;
3636

37-
38-
39-
40-
41-
-- CREATE TABLE if not exists SPRING_SESSION (
42-
-- PRIMARY_ID CHAR(36) NOT NULL,
43-
-- SESSION_ID CHAR(36) NOT NULL,
44-
-- CREATION_TIME BIGINT NOT NULL,
45-
-- LAST_ACCESS_TIME BIGINT NOT NULL,
46-
-- MAX_INACTIVE_INTERVAL INT NOT NULL,
47-
-- EXPIRY_TIME BIGINT NOT NULL,
48-
-- PRINCIPAL_NAME VARCHAR(100),
49-
-- CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
37+
--
38+
-- CREATE TABLE SPRING_SESSION (
39+
-- PRIMARY_ID CHAR(36) NOT NULL,
40+
-- SESSION_ID CHAR(36) NOT NULL,
41+
-- CREATION_TIME BIGINT NOT NULL,
42+
-- LAST_ACCESS_TIME BIGINT NOT NULL,
43+
-- MAX_INACTIVE_INTERVAL INT NOT NULL,
44+
-- EXPIRY_TIME BIGINT NOT NULL,
45+
-- PRINCIPAL_NAME VARCHAR(100),
46+
-- CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
5047
-- );
5148
--
5249
-- CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID);
5350
-- CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
5451
-- CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME);
5552
--
56-
-- CREATE TABLE if not exists SPRING_SESSION_ATTRIBUTES (
57-
-- SESSION_PRIMARY_ID CHAR(36) NOT NULL,
58-
-- ATTRIBUTE_NAME VARCHAR(200) NOT NULL,
59-
-- ATTRIBUTE_BYTES BLOB NOT NULL,
60-
-- CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
61-
-- CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES TESTDB.SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
62-
-- );
53+
-- CREATE TABLE SPRING_SESSION_ATTRIBUTES (
54+
-- SESSION_PRIMARY_ID CHAR(36) NOT NULL,
55+
-- ATTRIBUTE_NAME VARCHAR(200) NOT NULL,
56+
-- ATTRIBUTE_BYTES BYTEA NOT NULL,
57+
-- CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
58+
-- CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
59+
-- );
60+
61+

‎ssl-key.p12

-2.67 KB
Binary file not shown.

‎work.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
obj = {
9-
'sex':[],
9+
'a_sex':[],
1010
'dresstype':[],
1111
'image':[],
1212
'price':[],
@@ -21,7 +21,7 @@ def sanitizePrice(price):
2121

2222

2323
for content in men_content:
24-
temp = pd.DataFrame( { 'sex' : ['MALE'] ,
24+
temp = pd.DataFrame( { 'a_sex' : ['MALE'] ,
2525
'dresstype' :[content['dressType']],
2626
'image' : [content['image']],
2727
'price' : [content['price']],
@@ -34,7 +34,7 @@ def sanitizePrice(price):
3434

3535

3636
for content in f_content:
37-
temp = pd.DataFrame( { 'sex' : ['FEMALE'] ,
37+
temp = pd.DataFrame( { 'a_sex' : ['FEMALE'] ,
3838
'dresstype' :[content['dressType']],
3939
'image' : [content['image']],
4040
'price' : [content['price']],

0 commit comments

Comments
 (0)
Please sign in to comment.