teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

mailsend\.html追記

2017/07/01 07:26

投稿

heavyuseman
heavyuseman

スコア42

title CHANGED
File without changes
body CHANGED
@@ -114,4 +114,29 @@
114
114
 
115
115
  }
116
116
 
117
+ ```
118
+ ```html
119
+ mailsend.html
120
+ <!DOCTYPE html>
121
+ <html xmlns:th="http://www.thymeleaf.org">
122
+ <head>
123
+ <title>top page</title>
124
+ <meta http-equiv="Content-Type"
125
+ content="text/html" charset="UTF-8"/>
126
+
127
+ <!-- css -->
128
+
129
+ <style>
130
+ html { height: 100% }
131
+ body { height: 100%; margin: 0; padding: 0 }
132
+ #map { height: 100% }
133
+ </style>
134
+ </head>
135
+ <body>
136
+ <h1>メール送信完了</h1>
137
+ <form action="/mailsend" method="POST">
138
+ <button>メール送信</button>
139
+ </form>
140
+ </body>
141
+ </html>
117
142
  ```

2

security\.config\.javaを追記

2017/07/01 07:26

投稿

heavyuseman
heavyuseman

スコア42

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,7 @@
2
2
  springframeworkでメール機能実装しており、質問があります。
3
3
  下記の通りに
4
4
  ```html
5
+ First.html
5
6
  <form action="/mailsend" method="POST">
6
7
  <button>メール送信</button>
7
8
  </form>
@@ -43,4 +44,74 @@
43
44
  }
44
45
  }
45
46
 
47
+ ```
48
+ ```java
49
+ Securityconfig.java
50
+ package com.tuyano.springboot.springsecurity;
51
+
52
+ import org.springframework.context.annotation.Bean;
53
+ import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
54
+ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
55
+ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
56
+ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
57
+ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
58
+
59
+ import javax.sql.DataSource;
60
+
61
+ import org.springframework.beans.factory.annotation.Autowired;
62
+ import org.springframework.beans.factory.annotation.Qualifier;
63
+
64
+
65
+
66
+ @EnableWebSecurity
67
+ public class SecurityConfig extends WebSecurityConfigurerAdapter{
68
+ @Autowired
69
+ private DataSource dataSource;
70
+
71
+ private static final String USER_QUERY="select name, password, 1 from Newaccount where name = ?";
72
+ private static final
73
+ String ROLES_QUERY="select username, authority from AUTHORITIES where username = ?";
74
+
75
+ @Override
76
+ protected void configure(HttpSecurity http) throws Exception{
77
+ http
78
+ .authorizeRequests()
79
+ .antMatchers("/First.html").permitAll()
80
+ .antMatchers("/sucess.html").permitAll()
81
+ .antMatchers("/failure.html").permitAll()
82
+ .antMatchers("/mailsend.html").permitAll()
83
+ .antMatchers("/js/**").permitAll()
84
+ .antMatchers("/templates/**").hasAnyAuthority("ROLE_ADMIN")
85
+ .anyRequest().authenticated()
86
+ .and()
87
+ .formLogin()
88
+ .loginPage("/First.html")
89
+ .loginProcessingUrl("/processLogin")
90
+ .defaultSuccessUrl("/sucess.html")
91
+ .failureUrl("/failure.html")
92
+ .usernameParameter("name")
93
+ .passwordParameter("password")
94
+ .and()
95
+ .logout()
96
+ .logoutUrl("/processLogout")
97
+ .logoutSuccessUrl("/First.html")
98
+ .and()
99
+ .csrf()
100
+ .disable();
101
+
102
+ }
103
+ @Override
104
+ public void configure(AuthenticationManagerBuilder auth) throws Exception {
105
+ auth.jdbcAuthentication()
106
+ .dataSource(dataSource)
107
+ .usersByUsernameQuery(USER_QUERY)
108
+ .authoritiesByUsernameQuery(ROLES_QUERY);
109
+ //passwordEncoder(new BCryptPasswordEncoder());
110
+ //.authoritiesByUsernameQuery(
111
+ // "select mail_address, role from accounts where mail_address = ?");
112
+ }
113
+
114
+
115
+ }
116
+
46
117
  ```

1

メール送信のクラス名を記載

2017/07/01 07:14

投稿

heavyuseman
heavyuseman

スコア42

title CHANGED
File without changes
body CHANGED
@@ -12,6 +12,7 @@
12
12
  原因が不明ですのでご教授宜しくお願いします。
13
13
  下記がメール送信するためのjavaソースとなります。
14
14
  ```java
15
+ Mailsend.java
15
16
  package com.tuyano.springboot.mail;
16
17
 
17
18
  import org.springframework.beans.factory.annotation.Autowired;