Skip to content

Commit 966e53a

Browse files
author
eugenp
committed
formatting work
1 parent 034cde6 commit 966e53a

58 files changed

Lines changed: 1017 additions & 1131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎spring-freemarker/src/main/java/com/baeldung/freemarker/config/SpringWebConfig.java‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111

1212
@EnableWebMvc
1313
@Configuration
14-
@ComponentScan({"com.baeldung.freemarker"})
14+
@ComponentScan({ "com.baeldung.freemarker" })
1515
public class SpringWebConfig extends WebMvcConfigurerAdapter {
1616

17-
@Override
18-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
19-
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
20-
}
17+
@Override
18+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
19+
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
20+
}
2121

22-
@Bean
23-
public FreeMarkerViewResolver freemarkerViewResolver() {
24-
FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
25-
resolver.setCache(true);
26-
resolver.setPrefix("");
27-
resolver.setSuffix(".ftl");
28-
return resolver;
29-
}
22+
@Bean
23+
public FreeMarkerViewResolver freemarkerViewResolver() {
24+
FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
25+
resolver.setCache(true);
26+
resolver.setPrefix("");
27+
resolver.setSuffix(".ftl");
28+
return resolver;
29+
}
3030

31-
@Bean
32-
public FreeMarkerConfigurer freemarkerConfig() {
33-
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
34-
freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/ftl/");
35-
return freeMarkerConfigurer;
36-
}
31+
@Bean
32+
public FreeMarkerConfigurer freemarkerConfig() {
33+
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
34+
freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/ftl/");
35+
return freeMarkerConfigurer;
36+
}
3737

3838
}

‎spring-freemarker/src/main/java/com/baeldung/freemarker/config/WebConfiguration.java‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
public class WebConfiguration extends AbstractAnnotationConfigDispatcherServletInitializer {
66

7-
@Override
8-
protected Class<?>[] getServletConfigClasses() {
9-
return new Class[] { SpringWebConfig.class };
10-
}
7+
@Override
8+
protected Class<?>[] getServletConfigClasses() {
9+
return new Class[] { SpringWebConfig.class };
10+
}
1111

12-
@Override
13-
protected String[] getServletMappings() {
14-
return new String[] { "/" };
15-
}
12+
@Override
13+
protected String[] getServletMappings() {
14+
return new String[] { "/" };
15+
}
1616

17-
@Override
18-
protected Class<?>[] getRootConfigClasses() {
19-
return null;
20-
}
17+
@Override
18+
protected Class<?>[] getRootConfigClasses() {
19+
return null;
20+
}
2121

2222
}

‎spring-freemarker/src/main/java/com/baeldung/freemarker/controller/SpringController.java‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,31 @@
1616
@Controller
1717
public class SpringController {
1818

19-
private static List<Car> carList = new ArrayList<Car>();
20-
21-
@RequestMapping(value = "/", method = RequestMethod.GET)
22-
public String home(Locale locale, Model model) {
23-
return "redirect:/cars";
24-
}
25-
26-
static {
27-
carList.add(new Car("Honda", "Civic"));
28-
carList.add(new Car("Toyota", "Camry"));
29-
carList.add(new Car("Nissan", "Altima"));
30-
}
31-
32-
33-
@RequestMapping(value = "/cars", method = RequestMethod.GET)
34-
public String init(@ModelAttribute("model") ModelMap model) {
35-
model.addAttribute("carList", carList);
36-
return "index";
37-
}
38-
39-
@RequestMapping(value = "/add", method = RequestMethod.POST)
40-
public String addCar(@ModelAttribute("car") Car car) {
41-
if (null != car && null != car.getMake() && null != car.getModel()
42-
&& !car.getMake().isEmpty() && !car.getModel().isEmpty()) {
43-
carList.add(car);
44-
}
45-
return "redirect:/cars";
46-
}
47-
19+
private static List<Car> carList = new ArrayList<Car>();
20+
21+
@RequestMapping(value = "/", method = RequestMethod.GET)
22+
public String home(Locale locale, Model model) {
23+
return "redirect:/cars";
24+
}
25+
26+
static {
27+
carList.add(new Car("Honda", "Civic"));
28+
carList.add(new Car("Toyota", "Camry"));
29+
carList.add(new Car("Nissan", "Altima"));
30+
}
31+
32+
@RequestMapping(value = "/cars", method = RequestMethod.GET)
33+
public String init(@ModelAttribute("model") ModelMap model) {
34+
model.addAttribute("carList", carList);
35+
return "index";
36+
}
37+
38+
@RequestMapping(value = "/add", method = RequestMethod.POST)
39+
public String addCar(@ModelAttribute("car") Car car) {
40+
if (null != car && null != car.getMake() && null != car.getModel() && !car.getMake().isEmpty() && !car.getModel().isEmpty()) {
41+
carList.add(car);
42+
}
43+
return "redirect:/cars";
44+
}
45+
4846
}

‎spring-freemarker/src/main/java/com/baeldung/freemarker/model/Car.java‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22

33
public class Car {
44

5-
private String make;
6-
private String model;
7-
8-
public Car(){
9-
10-
}
11-
12-
public Car(String make, String model) {
13-
this.make = make;
5+
private String make;
6+
private String model;
7+
8+
public Car() {
9+
10+
}
11+
12+
public Car(String make, String model) {
13+
this.make = make;
1414
this.model = model;
1515
}
1616

17-
public String getMake() {
18-
return make;
19-
}
17+
public String getMake() {
18+
return make;
19+
}
2020

21-
public void setMake(String make) {
22-
this.make = make;
23-
}
21+
public void setMake(String make) {
22+
this.make = make;
23+
}
2424

25-
public String getModel() {
26-
return model;
27-
}
25+
public String getModel() {
26+
return model;
27+
}
2828

29-
public void setModel(String model) {
30-
this.model = model;
31-
}
29+
public void setModel(String model) {
30+
this.model = model;
31+
}
3232

3333
}

‎spring-security-basic-auth/src/main/java/org/baeldung/security/filter/configuration/CustomWebSecurityConfigurerAdapter.java‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,13 @@ public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAda
1919

2020
@Autowired
2121
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
22-
auth.inMemoryAuthentication()
23-
.withUser("user1").password("user1Pass")
24-
.authorities("ROLE_USER");
22+
auth.inMemoryAuthentication().withUser("user1").password("user1Pass").authorities("ROLE_USER");
2523
}
2624

2725
@Override
2826
protected void configure(HttpSecurity http) throws Exception {
29-
http.authorizeRequests()
30-
.antMatchers("/securityNone").permitAll()
31-
.anyRequest().authenticated()
32-
.and()
33-
.httpBasic()
34-
.authenticationEntryPoint(authenticationEntryPoint);
27+
http.authorizeRequests().antMatchers("/securityNone").permitAll().anyRequest().authenticated().and().httpBasic().authenticationEntryPoint(authenticationEntryPoint);
3528

36-
http.addFilterAfter(new CustomFilter(),
37-
BasicAuthenticationFilter.class);
29+
http.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class);
3830
}
3931
}

‎spring-security-basic-auth/src/main/java/org/baeldung/spring/SecSecurityConfig.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@Configuration
77
@ComponentScan("org.baeldung.security")
8-
//@ImportResource({ "classpath:webSecurityConfig.xml" })
8+
// @ImportResource({ "classpath:webSecurityConfig.xml" })
99
public class SecSecurityConfig {
1010

1111
public SecSecurityConfig() {

‎spring-security-custom-permission/src/main/java/org/baeldung/Application.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
@Configuration
1111
@EnableAutoConfiguration
12-
@ComponentScan(excludeFilters =
13-
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.baeldung.voter.*"))
12+
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.baeldung.voter.*"))
1413
public class Application extends SpringBootServletInitializer {
1514
public static void main(String[] args) {
1615
SpringApplication.run(Application.class, args);

‎spring-security-custom-permission/src/main/java/org/baeldung/persistence/dao/UserRepository.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
public interface UserRepository extends JpaRepository<User, Long> {
88

99
User findByUsername(final String username);
10-
10+
1111
@Transactional
1212
void removeUserByUsername(String username);
1313

‎spring-security-custom-permission/src/main/java/org/baeldung/persistence/model/User.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import javax.persistence.Table;
1616

1717
@Entity
18-
@Table(name="user_table")
18+
@Table(name = "user_table")
1919
public class User {
2020

2121
@Id

‎spring-security-custom-permission/src/main/java/org/baeldung/voter/MinuteBasedVoter.java‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ public boolean supports(Class clazz) {
2121

2222
@Override
2323
public int vote(Authentication authentication, Object object, Collection collection) {
24-
return authentication
25-
.getAuthorities()
26-
.stream()
27-
.map(GrantedAuthority::getAuthority)
28-
.filter(r -> "ROLE_USER".equals(r) && LocalDateTime.now().getMinute() % 2 != 0)
29-
.findAny()
30-
.map(s -> ACCESS_DENIED)
31-
.orElseGet(() -> ACCESS_ABSTAIN);
24+
return authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).filter(r -> "ROLE_USER".equals(r) && LocalDateTime.now().getMinute() % 2 != 0).findAny().map(s -> ACCESS_DENIED).orElseGet(() -> ACCESS_ABSTAIN);
3225
}
3326
}

0 commit comments

Comments
 (0)