Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
0aedb57d
Commit
0aedb57d
authored
Oct 19, 2020
by
keita.onoguchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
カート機能途中
parent
1c0b08d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
61 deletions
+60
-61
SecurityConfig.java
src/main/java/com/example/SecurityConfig.java
+44
-44
EcsiteRestController.java
src/main/java/com/example/api/EcsiteRestController.java
+3
-3
Cart.java
src/main/java/com/example/domain/Cart.java
+13
-14
No files found.
src/main/java/com/example/SecurityConfig.java
View file @
0aedb57d
//
package com.example;
//
//
import org.springframework.context.annotation.Bean;
//
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//
import org.springframework.security.config.annotation.web.builders.WebSecurity;
//
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//
import org.springframework.security.crypto.password.PasswordEncoder;
//
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
//
//
//
@EnableWebSecurity
//
public class SecurityConfig extends WebSecurityConfigurerAdapter{
//
//
@Override
//
public void configure(WebSecurity web) throws Exception{
//
web.debug(false).ignoring().antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**");
//
}
//
//
@Override
//
protected void configure(HttpSecurity http) throws Exception {
//
http
//
.authorizeRequests()
//
.mvcMatchers("/limited/login","/limited/signUp").permitAll() //ログイン前でもアクセス可能なURLの指定
//
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
//
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定s
//
.and()
//
.formLogin()
//
.loginProcessingUrl("/login") //ログイン処理でpostするURL
//
.loginPage("/limited/login") //ログインページのURL
//
.defaultSuccessUrl("/limited/top", true) //ログイン成功時のURL
//
.usernameParameter("email").passwordParameter("password") //ログインのパラメーター指定
//
.and()
//
.logout()
//
.invalidateHttpSession(true)
//
.deleteCookies("JSESSIONID") //ログアウト時キャッシュを削除する処理
//
.logoutSuccessUrl("/limited/login"); //ログアウト後に表示するURL
//
}
//
//
@Bean //パスワードのハッシュか
//
PasswordEncoder passwordEncoder(){
//
return new Pbkdf2PasswordEncoder();
//
}
//
}
package
com
.
example
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.builders.WebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.Pbkdf2PasswordEncoder
;
@EnableWebSecurity
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
debug
(
false
).
ignoring
().
antMatchers
(
"/images/**"
,
"/js/**"
,
"/css/**"
,
"/fonts/**"
);
}
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
mvcMatchers
(
"/limited/login"
,
"/limited/signUp"
).
permitAll
()
//ログイン前でもアクセス可能なURLの指定
.
mvcMatchers
(
"/limited/admin/**"
).
hasRole
(
"ADMIN"
)
//ADMIN権限のユーザーのみアクセスできるURLの指定
.
anyRequest
().
authenticated
()
//ログイン前は他のアドレスにログインできないよう指定s
.
and
()
.
formLogin
()
.
loginProcessingUrl
(
"/login"
)
//ログイン処理でpostするURL
.
loginPage
(
"/limited/login"
)
//ログインページのURL
.
defaultSuccessUrl
(
"/limited/top"
,
true
)
//ログイン成功時のURL
.
usernameParameter
(
"email"
).
passwordParameter
(
"password"
)
//ログインのパラメーター指定
.
and
()
.
logout
()
.
invalidateHttpSession
(
true
)
.
deleteCookies
(
"JSESSIONID"
)
//ログアウト時キャッシュを削除する処理
.
logoutSuccessUrl
(
"/limited/login"
);
//ログアウト後に表示するURL
}
@Bean
//パスワードのハッシュか
PasswordEncoder
passwordEncoder
(){
return
new
Pbkdf2PasswordEncoder
();
}
}
src/main/java/com/example/api/EcsiteRestController.java
View file @
0aedb57d
...
...
@@ -21,7 +21,7 @@ import com.example.service.LoginUserDetailsService;
@RestController
@RequestMapping
(
"limited"
)
@SessionAttributes
(
names
=
"cart"
)
//
@SessionAttributes(names ="cart")
public
class
EcsiteRestController
{
@Autowired
LoginUserDetailsService
loginUserDetailsService
;
...
...
@@ -44,8 +44,8 @@ public class EcsiteRestController {
}
@PostMapping
(
"inputCart"
)
public
void
inputCart
(
@RequestBody
CartData
data
,
Model
model
,
Cart
cart
)
{
System
.
out
.
print
(
data
.
getShoesId
()
);
public
void
inputCart
(
@RequestBody
CartData
data
,
Model
model
)
{
Cart
cart
=
new
Cart
(
);
cart
.
setCart
(
data
.
getShoesId
(),
data
.
getQuantity
());
//return cart.getCart();
}
...
...
src/main/java/com/example/domain/Cart.java
View file @
0aedb57d
...
...
@@ -3,7 +3,6 @@ package com.example.domain;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.context.annotation.ScopedProxyMode
;
import
org.springframework.stereotype.Component
;
...
...
@@ -13,17 +12,15 @@ import com.example.service.ShoesService;
import
lombok.Getter
;
import
lombok.Setter
;
//
@Component
//
@Scope(value= "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Component
@Scope
(
value
=
"session"
,
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
@Getter
@Setter
public
class
Cart
/*implements Serializable*/
{
public
class
Cart
implements
Serializable
{
/**
*
*/
//private static final long serialVersionUID = 1L;
@Autowired
ShoesService
shoesService
;
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
shoesId
;
private
String
photo
;
...
...
@@ -37,14 +34,16 @@ public class Cart /*implements Serializable*/{
public
void
setCart
(
Integer
shoesId
,
Integer
quantity
)
{
System
.
out
.
println
(
shoesId
);
Shoes
shoes
=
new
Shoes
();
ShoesService
shoesService
=
new
ShoesService
();
shoes
=
shoesService
.
findOne
(
shoesId
);
this
.
shoesId
=
shoesId
;
this
.
photo
=
shoes
.
getPhoto
();
this
.
shoesName
=
shoes
.
getName
();
this
.
shoesSize
=
shoes
.
getSize
();
this
.
quantity
=
quantity
;
this
.
price
=
shoes
.
getPrice
()
*
quantity
;
System
.
out
.
print
(
this
.
price
);
//System.out.println(shoes);
// this.shoesId = shoesId;
// this.photo = shoes.getPhoto();
// this.shoesName = shoes.getName();
// this.shoesSize = shoes.getSize();
// this.quantity = quantity;
// this.price = shoes.getPrice() * quantity;
// System.out.print(this.price);
}
public
ArrayList
<
Cart
>
getCart
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment