Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.92 KB | None | 0 0
  1. Whitelabel Error Page
  2.  
  3. This application has no explicit mapping for /error, so you are seeing this as a fallback.
  4.  
  5. Wed Aug 23 20:14:22 CEST 2017
  6. There was an unexpected error (type=Not Found, status=404).
  7. No message available
  8.  
  9. package com.cyberdemon.springboot;
  10.  
  11. import org.springframework.boot.SpringApplication;
  12. import org.springframework.boot.autoconfigure.SpringBootApplication;
  13.  
  14. @SpringBootApplication
  15. public class SpringbootUiLoginApplication {
  16.  
  17. public static void main(String[] args) {
  18. SpringApplication.run(SpringbootUiLoginApplication.class, args);
  19. }
  20. }
  21.  
  22. package config;
  23.  
  24. import javax.sql.DataSource;
  25.  
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  28. import org.springframework.context.annotation.Configuration;
  29. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  30. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  31. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  32.  
  33. @Configuration
  34. @EnableAutoConfiguration
  35. public class SecurityConfig extends WebSecurityConfigurerAdapter {
  36.  
  37. @Autowired
  38. DataSource dataSource;
  39.  
  40. @Autowired
  41. public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
  42. auth.jdbcAuthentication().dataSource(dataSource)
  43. .usersByUsernameQuery("select username,password, enabled from users where username=?")
  44. .authoritiesByUsernameQuery("select username, role from user_roles where username=?");
  45. }
  46.  
  47. @Override
  48. protected void configure(HttpSecurity http) throws Exception {
  49. http.authorizeRequests().antMatchers("/", "/home").permitAll().antMatchers("/admin").hasRole("ADMIN")
  50. .anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout()
  51. .permitAll();
  52. http.exceptionHandling().accessDeniedPage("/403");
  53. }
  54.  
  55. }
  56.  
  57. package controller;
  58.  
  59. import org.springframework.stereotype.Controller;
  60. import org.springframework.web.bind.annotation.RequestMapping;
  61.  
  62. @Controller
  63. public class WebController {
  64.  
  65. @RequestMapping(value = { "/", "home" })
  66. public String home() {
  67. return "home";
  68. }
  69.  
  70. @RequestMapping(value = { "/welcome" })
  71. public String welcome() {
  72. return "welcome";
  73. }
  74.  
  75. @RequestMapping(value = "/admin")
  76. public String admin() {
  77. return "admin";
  78. }
  79.  
  80. @RequestMapping(value = { "/login" })
  81. public String login() {
  82. return "login";
  83. }
  84.  
  85. @RequestMapping(value = "/403")
  86. public String Error403() {
  87. return "403";
  88. }
  89.  
  90. }
  91.  
  92. <?xml version="1.0" encoding="UTF-8"?>
  93. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  95. <modelVersion>4.0.0</modelVersion>
  96.  
  97. <groupId>com.cyberdemon.springboot</groupId>
  98. <artifactId>springboot_UI_Login</artifactId>
  99. <version>0.0.1-SNAPSHOT</version>
  100. <packaging>jar</packaging>
  101.  
  102. <name>springboot_UI_Login</name>
  103. <description>Project for Spring Boot</description>
  104.  
  105. <parent>
  106. <groupId>org.springframework.boot</groupId>
  107. <artifactId>spring-boot-starter-parent</artifactId>
  108. <version>1.5.6.RELEASE</version>
  109. <relativePath/> <!-- lookup parent from repository -->
  110. </parent>
  111.  
  112. <properties>
  113. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  114. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  115. <java.version>1.8</java.version>
  116. </properties>
  117.  
  118. <dependencies>
  119. <dependency>
  120. <groupId>org.springframework.boot</groupId>
  121. <artifactId>spring-boot-starter-jdbc</artifactId>
  122. </dependency>
  123. <dependency>
  124. <groupId>org.springframework.boot</groupId>
  125. <artifactId>spring-boot-starter-security</artifactId>
  126. </dependency>
  127. <dependency>
  128. <groupId>org.springframework.boot</groupId>
  129. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  130. </dependency>
  131. <dependency>
  132. <groupId>org.springframework.boot</groupId>
  133. <artifactId>spring-boot-starter-web</artifactId>
  134. </dependency>
  135.  
  136. <dependency>
  137. <groupId>mysql</groupId>
  138. <artifactId>mysql-connector-java</artifactId>
  139. <scope>runtime</scope>
  140. </dependency>
  141. <dependency>
  142. <groupId>org.springframework.boot</groupId>
  143. <artifactId>spring-boot-starter-test</artifactId>
  144. <scope>test</scope>
  145. </dependency>
  146. <dependency>
  147. <groupId>org.springframework.security</groupId>
  148. <artifactId>spring-security-test</artifactId>
  149. <scope>test</scope>
  150. </dependency>
  151. </dependencies>
  152.  
  153. <build>
  154. <plugins>
  155. <plugin>
  156. <groupId>org.springframework.boot</groupId>
  157. <artifactId>spring-boot-maven-plugin</artifactId>
  158. </plugin>
  159. </plugins>
  160. </build>
  161.  
  162.  
  163. </project>
  164.  
  165. spring.datasource.url=jdbc:mysql://localhost:3306/testdb
  166. spring.datasource.username=root
  167. spring.datasource.password=toor
  168.  
  169. . ____ _ __ _ _
  170. /\ / ___'_ __ _ _(_)_ __ __ _
  171. ( ( )___ | '_ | '_| | '_ / _` |
  172. \/ ___)| |_)| | | | | || (_| | ) ) ) )
  173. ' |____| .__|_| |_|_| |___, | / / / /
  174. =========|_|==============|___/=/_/_/_/
  175. :: Spring Boot :: (v1.5.6.RELEASE)
  176.  
  177. 2017-08-23 19:57:05.949 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : Starting SpringbootUiLoginApplication on DESKTOP-CYBERDEMON with PID 7496 (started by GD in C:UsersmeDocumentsworkspace-stsspringboot_ui_login)
  178. 2017-08-23 19:57:05.949 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : No active profile set, falling back to default profiles: default
  179. 2017-08-23 19:57:06.121 INFO 7496 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6cc7b4de: startup date [Wed Aug 23 19:57:06 CEST 2017]; root of context hierarchy
  180. 2017-08-23 19:57:07.293 INFO 7496 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
  181. 2017-08-23 19:57:07.300 INFO 7496 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  182. 2017-08-23 19:57:07.300 INFO 7496 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
  183. 2017-08-23 19:57:07.409 INFO 7496 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  184. 2017-08-23 19:57:07.409 INFO 7496 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1288 ms
  185. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
  186. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  187. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
  188. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
  189. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
  190. 2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
  191. 2017-08-23 19:57:07.847 INFO 7496 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6cc7b4de: startup date [Wed Aug 23 19:57:06 CEST 2017]; root of context hierarchy
  192. 2017-08-23 19:57:07.894 INFO 7496 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
  193. 2017-08-23 19:57:07.894 INFO 7496 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
  194. 2017-08-23 19:57:07.925 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  195. 2017-08-23 19:57:07.925 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  196. 2017-08-23 19:57:07.956 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  197. 2017-08-23 19:57:08.519 INFO 7496 --- [ main] b.a.s.AuthenticationManagerConfiguration :
  198.  
  199. Using default security password: 21cf3953-b4e3-48ac-87fa-9041c41b3ff8
  200.  
  201. 2017-08-23 19:57:08.567 INFO 7496 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
  202. 2017-08-23 19:57:08.645 INFO 7496 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@12fcc71f, org.springframework.security.web.context.SecurityContextPersistenceFilter@5d43409a, org.springframework.security.web.header.HeaderWriterFilter@76563d26, org.springframework.security.web.authentication.logout.LogoutFilter@102ecc22, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@4eba373c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6ede46f6, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@10a0fe30, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5679e96b, org.springframework.security.web.session.SessionManagementFilter@23b8d9f3, org.springframework.security.web.access.ExceptionTranslationFilter@261ea657, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6cd64ee8]
  203. 2017-08-23 19:57:08.864 INFO 7496 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
  204. 2017-08-23 19:57:08.911 INFO 7496 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
  205. 2017-08-23 19:57:08.926 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : Started SpringbootUiLoginApplication in 3.164 seconds (JVM running for 3.428)
  206. 2017-08-23 19:57:24.008 INFO 7496 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
  207. 2017-08-23 19:57:24.008 INFO 7496 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
  208. 2017-08-23 19:57:24.021 INFO 7496 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 13 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement