/*
 * Copyright 2010-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.sambrannen.spring.events;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;

import com.sambrannen.spring.events.service.EventService;
import com.sambrannen.spring.events.web.EventsController;

/**
 * Central configuration for the <em>Spring Events</em> sample application,
 * powered by Spring Boot.
 *
 * @author Sam Brannen
 * @since 1.0
 */
@SpringBootApplication(scanBasePackageClasses = { EventService.class, EventsController.class })
@EnableGlobalMethodSecurity(prePostEnabled = true)
// Extend WebMvcAutoConfiguration so that static web content is served when
// launching the application as a Java Application within the Eclipse IDE.
public class Application extends WebMvcAutoConfiguration {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@Autowired
	void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
		auth.inMemoryAuthentication()
			.withUser("admin").password("test").roles("ADMIN", "ACTUATOR");
	}

}

@@ -21,9 +21,9 @@
 -201
-6
+8
  the
@@ -1130,16 +1130,89 @@
 ecurity;
+%0Aimport org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 %0A%0Aimport
@@ -2015,16 +2015,36 @@
 ption %7B%0A
+%09%09// @formatter:off%0A
 %09%09auth.i
@@ -2075,42 +2075,210 @@
 %09%09%09.
-withUser(%22admin%22).password(%22test%22)
+passwordEncoder(new BCryptPasswordEncoder())%0A%09%09%09.withUser(%22admin%22)%0A%09%09%09%09// %22test%22 is encoded using BCryptPasswordEncoder%0A%09%09%09%09.password(%22$2a$10$ygTOAyJCpUirdPv9NufL9.IEBz1OHwSdD88Faf/0ZE6.MxWEsTWjW%22)%0A%09%09%09%09
 .rol
@@ -2302,14 +2302,33 @@
 ATOR%22);%0A
+%09%09// @formatter:on%0A
 %09%7D%0A%0A%7D%0A

Use BCryptPasswordEncoder with Spring Security 5