diff --git a/src/main/java/com/hendisantika/adminlte/model/AbstractModel.java b/src/main/java/com/hendisantika/adminlte/model/AbstractModel.java index ed4a693d..08a2a2ec 100644 --- a/src/main/java/com/hendisantika/adminlte/model/AbstractModel.java +++ b/src/main/java/com/hendisantika/adminlte/model/AbstractModel.java @@ -1,9 +1,10 @@ package com.hendisantika.adminlte.model; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; + import java.io.Serializable; @MappedSuperclass diff --git a/src/main/java/com/hendisantika/adminlte/model/Customers.java b/src/main/java/com/hendisantika/adminlte/model/Customers.java index c93e50bc..2895061f 100644 --- a/src/main/java/com/hendisantika/adminlte/model/Customers.java +++ b/src/main/java/com/hendisantika/adminlte/model/Customers.java @@ -1,9 +1,14 @@ package com.hendisantika.adminlte.model; -import lombok.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; -import javax.persistence.Column; -import javax.persistence.Entity; import java.util.Date; @Entity diff --git a/src/main/java/com/hendisantika/adminlte/security/WebSecurityConfig.java b/src/main/java/com/hendisantika/adminlte/security/WebSecurityConfig.java index db8c2bb4..af3ce6e2 100644 --- a/src/main/java/com/hendisantika/adminlte/security/WebSecurityConfig.java +++ b/src/main/java/com/hendisantika/adminlte/security/WebSecurityConfig.java @@ -1,17 +1,18 @@ package com.hendisantika.adminlte.security; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.JdbcUserDetailsManager; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import javax.sql.DataSource; @@ -20,32 +21,32 @@ @Configuration @EnableWebSecurity -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { +public class WebSecurityConfig { @Autowired private DataSource datasource; - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/bower_components/**", "/dist/**", "/plugins/**").permitAll() + @Bean + public SecurityFilterChain configure(HttpSecurity http) throws Exception { + http.authorizeHttpRequests((req) -> req + .requestMatchers("/bower_components/**", "/dist/**", "/plugins/**").permitAll() .anyRequest().authenticated() - .and() - .formLogin() + ) + .formLogin((formLogin) -> formLogin .failureUrl("/login?error") .loginPage("/login") .defaultSuccessUrl("/") - .permitAll() - .and() - .logout() + .permitAll()) + .logout(logout -> logout .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) .logoutSuccessUrl("/login") - .permitAll(); + .permitAll()); + return http.build(); } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - //Use Spring Boots User detailsMAnager + //Use Spring Boots User detailsManager JdbcUserDetailsManager userDetailsService = new JdbcUserDetailsManager(); //Set our Datasource to use the one defined in application.properties