Merge pull request #8886 from Maiklins/JAVA-841-Standardize-packages-spring-security-mvc-boot
JAVA-841 standardize packages spring security mvc boot
This commit is contained in:
commit
af27b7f8a0
|
@ -222,10 +222,10 @@
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<start-class>org.baeldung.custom.Application</start-class>
|
<start-class>com.baeldung.roles.custom.Application</start-class>
|
||||||
<!--If you want to run the example with the voters comment the tag
|
<!--If you want to run the example with the voters comment the tag
|
||||||
above and uncomment the one below -->
|
above and uncomment the one below -->
|
||||||
<!--<start-class>org.baeldung.voter.VoterApplication</start-class> -->
|
<!--<start-class>com.baeldung.roles.voter.VoterApplication</start-class> -->
|
||||||
|
|
||||||
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung;
|
package com.baeldung.relationships;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@PropertySource({"classpath:persistence-h2.properties", "classpath:application-defaults.properties"})
|
@PropertySource({"classpath:persistence-h2.properties", "classpath:application-defaults.properties"})
|
||||||
@EnableJpaRepositories(basePackages = { "com.baeldung.data.repositories" })
|
@EnableJpaRepositories(basePackages = {"com.baeldung.relationships.repositories"})
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@Import(SpringSecurityConfig.class)
|
@Import(SpringSecurityConfig.class)
|
||||||
public class AppConfig extends WebMvcConfigurerAdapter {
|
public class AppConfig extends WebMvcConfigurerAdapter {
|
||||||
|
@ -41,7 +41,7 @@ public class AppConfig extends WebMvcConfigurerAdapter {
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||||
em.setDataSource(dataSource());
|
em.setDataSource(dataSource());
|
||||||
em.setPackagesToScan(new String[] { "com.baeldung.models" });
|
em.setPackagesToScan(new String[] { "com.baeldung.relationships.models" });
|
||||||
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
|
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
|
||||||
em.setJpaProperties(additionalProperties());
|
em.setJpaProperties(additionalProperties());
|
||||||
return em;
|
return em;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung;
|
package com.baeldung.relationships;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
@ -18,8 +18,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension;
|
import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.security.AuthenticationSuccessHandlerImpl;
|
import com.baeldung.relationships.security.AuthenticationSuccessHandlerImpl;
|
||||||
import com.baeldung.security.CustomUserDetailsService;
|
import com.baeldung.relationships.security.CustomUserDetailsService;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.models;
|
package com.baeldung.relationships.models;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.models;
|
package com.baeldung.relationships.models;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -1,11 +1,11 @@
|
||||||
package com.baeldung.data.repositories;
|
package com.baeldung.relationships.repositories;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||||
|
|
||||||
import com.baeldung.models.Tweet;
|
import com.baeldung.relationships.models.Tweet;
|
||||||
|
|
||||||
public interface TweetRepository extends PagingAndSortingRepository<Tweet, Long> {
|
public interface TweetRepository extends PagingAndSortingRepository<Tweet, Long> {
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package com.baeldung.data.repositories;
|
package com.baeldung.relationships.repositories;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.baeldung.models.AppUser;
|
import com.baeldung.relationships.models.AppUser;
|
||||||
|
|
||||||
public interface UserRepository extends CrudRepository<AppUser, Long> {
|
public interface UserRepository extends CrudRepository<AppUser, Long> {
|
||||||
AppUser findByUsername(String username);
|
AppUser findByUsername(String username);
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.security;
|
package com.baeldung.relationships.security;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
import com.baeldung.models.AppUser;
|
import com.baeldung.relationships.models.AppUser;
|
||||||
|
|
||||||
public class AppUserPrincipal implements UserDetails {
|
public class AppUserPrincipal implements UserDetails {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.security;
|
package com.baeldung.relationships.security;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -12,7 +12,7 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.baeldung.data.repositories.UserRepository;
|
import com.baeldung.relationships.repositories.UserRepository;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {
|
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.security;
|
package com.baeldung.relationships.security;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.data.repositories.UserRepository;
|
import com.baeldung.relationships.repositories.UserRepository;
|
||||||
import com.baeldung.models.AppUser;
|
import com.baeldung.relationships.models.AppUser;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CustomUserDetailsService implements UserDetailsService {
|
public class CustomUserDetailsService implements UserDetailsService {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.util;
|
package com.baeldung.relationships.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -10,8 +10,8 @@ import java.util.stream.IntStream;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
import com.baeldung.models.AppUser;
|
import com.baeldung.relationships.models.AppUser;
|
||||||
import com.baeldung.models.Tweet;
|
import com.baeldung.relationships.models.Tweet;
|
||||||
|
|
||||||
public class DummyContentUtil {
|
public class DummyContentUtil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom;
|
package com.baeldung.roles.custom;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("org.baeldung.custom")
|
@ComponentScan("com.baeldung.roles.custom")
|
||||||
@PropertySource("classpath:application-defaults.properties")
|
@PropertySource("classpath:application-defaults.properties")
|
||||||
public class Application extends SpringBootServletInitializer {
|
public class Application extends SpringBootServletInitializer {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
|
@ -1,7 +1,7 @@
|
||||||
package org.baeldung.custom.config;
|
package com.baeldung.roles.custom.config;
|
||||||
|
|
||||||
import org.baeldung.custom.security.CustomMethodSecurityExpressionHandler;
|
import com.baeldung.roles.custom.security.CustomMethodSecurityExpressionHandler;
|
||||||
import org.baeldung.custom.security.CustomPermissionEvaluator;
|
import com.baeldung.roles.custom.security.CustomPermissionEvaluator;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.config;
|
package com.baeldung.roles.custom.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.config;
|
package com.baeldung.roles.custom.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,16 +1,16 @@
|
||||||
package org.baeldung.custom.persistence;
|
package com.baeldung.roles.custom.persistence;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.dao.OrganizationRepository;
|
import com.baeldung.roles.custom.persistence.dao.OrganizationRepository;
|
||||||
import org.baeldung.custom.persistence.dao.PrivilegeRepository;
|
import com.baeldung.roles.custom.persistence.dao.PrivilegeRepository;
|
||||||
import org.baeldung.custom.persistence.dao.UserRepository;
|
import com.baeldung.roles.custom.persistence.dao.UserRepository;
|
||||||
import org.baeldung.custom.persistence.model.Organization;
|
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||||
import org.baeldung.custom.persistence.model.Privilege;
|
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.custom.persistence.dao;
|
package com.baeldung.roles.custom.persistence.dao;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.Organization;
|
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface OrganizationRepository extends JpaRepository<Organization, Long> {
|
public interface OrganizationRepository extends JpaRepository<Organization, Long> {
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.custom.persistence.dao;
|
package com.baeldung.roles.custom.persistence.dao;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.Privilege;
|
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.custom.persistence.dao;
|
package com.baeldung.roles.custom.persistence.dao;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.persistence.model;
|
package com.baeldung.roles.custom.persistence.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.persistence.model;
|
package com.baeldung.roles.custom.persistence.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.persistence.model;
|
package com.baeldung.roles.custom.persistence.model;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.persistence.model;
|
package com.baeldung.roles.custom.persistence.model;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.security.access.expression.SecurityExpressionRoot;
|
import org.springframework.security.access.expression.SecurityExpressionRoot;
|
||||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.security.access.PermissionEvaluator;
|
import org.springframework.security.access.PermissionEvaluator;
|
||||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
||||||
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
|
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
|
|
@ -1,7 +1,7 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.dao.UserRepository;
|
import com.baeldung.roles.custom.persistence.dao.UserRepository;
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
@ -1,11 +1,11 @@
|
||||||
package org.baeldung.custom.security;
|
package com.baeldung.roles.custom.security;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.Privilege;
|
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||||
import org.baeldung.custom.persistence.model.User;
|
import com.baeldung.roles.custom.persistence.model.User;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
@ -1,9 +1,9 @@
|
||||||
package org.baeldung.custom.web;
|
package com.baeldung.roles.custom.web;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.dao.OrganizationRepository;
|
import com.baeldung.roles.custom.persistence.dao.OrganizationRepository;
|
||||||
import org.baeldung.custom.persistence.model.Foo;
|
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||||
import org.baeldung.custom.persistence.model.Organization;
|
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||||
import org.baeldung.custom.security.MyUserPrincipal;
|
import com.baeldung.roles.custom.security.MyUserPrincipal;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ip;
|
package com.baeldung.roles.ip;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("org.baeldung.ip")
|
@ComponentScan("com.baeldung.ip")
|
||||||
@PropertySource("classpath:application-defaults.properties")
|
@PropertySource("classpath:application-defaults.properties")
|
||||||
public class IpApplication extends SpringBootServletInitializer {
|
public class IpApplication extends SpringBootServletInitializer {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ip.config;
|
package com.baeldung.roles.ip.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ip.config;
|
package com.baeldung.roles.ip.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ip.config;
|
package com.baeldung.roles.ip.config;
|
||||||
|
|
||||||
|
|
||||||
//@Configuration
|
//@Configuration
|
|
@ -1,11 +1,11 @@
|
||||||
package org.baeldung.ip.web;
|
package com.baeldung.roles.ip.web;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.Foo;
|
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.security.web.FilterChainProxy;
|
import org.springframework.security.web.FilterChainProxy;
|
|
@ -1,7 +1,7 @@
|
||||||
package org.baeldung.rolesauthorities;
|
package com.baeldung.roles.rolesauthorities;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
import org.baeldung.rolesauthorities.persistence.UserRepository;
|
import com.baeldung.roles.rolesauthorities.persistence.UserRepository;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities;
|
package com.baeldung.roles.rolesauthorities;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.baeldung.rolesauthorities;
|
package com.baeldung.roles.rolesauthorities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.Role;
|
import com.baeldung.roles.rolesauthorities.model.Role;
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
import org.baeldung.rolesauthorities.persistence.UserRepository;
|
import com.baeldung.roles.rolesauthorities.persistence.UserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities;
|
package com.baeldung.roles.rolesauthorities;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan("org.baeldung.rolesauthorities")
|
@ComponentScan("com.baeldung.rolesauthorities")
|
||||||
public class RolesAuthoritiesApplication extends SpringBootServletInitializer {
|
public class RolesAuthoritiesApplication extends SpringBootServletInitializer {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.setProperty("spring.profiles.default", "rolesauthorities");
|
System.setProperty("spring.profiles.default", "rolesauthorities");
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities.config;
|
package com.baeldung.roles.rolesauthorities.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,7 +1,7 @@
|
||||||
package org.baeldung.rolesauthorities.config;
|
package com.baeldung.roles.rolesauthorities.config;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.CustomAuthenticationProvider;
|
import com.baeldung.roles.rolesauthorities.CustomAuthenticationProvider;
|
||||||
import org.baeldung.rolesauthorities.persistence.UserRepository;
|
import com.baeldung.roles.rolesauthorities.persistence.UserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
@ -18,7 +18,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = { "org.baeldung.rolesauthorities" })
|
@ComponentScan(basePackages = {"com.baeldung.rolesauthorities"})
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities.model;
|
package com.baeldung.roles.rolesauthorities.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities.model;
|
package com.baeldung.roles.rolesauthorities.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.rolesauthorities.model;
|
package com.baeldung.roles.rolesauthorities.model;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
|
|
||||||
|
public interface IUserService {
|
||||||
|
|
||||||
|
User findUserByEmail(String email);
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.Privilege;
|
import com.baeldung.roles.rolesauthorities.model.Privilege;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.Role;
|
import com.baeldung.roles.rolesauthorities.model.Role;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface RoleRepository extends JpaRepository<Role, Long> {
|
public interface RoleRepository extends JpaRepository<Role, Long> {
|
|
@ -1,13 +1,13 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.Privilege;
|
import com.baeldung.roles.rolesauthorities.model.Privilege;
|
||||||
import org.baeldung.rolesauthorities.model.Role;
|
import com.baeldung.roles.rolesauthorities.model.Role;
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Long> {
|
|
@ -1,8 +1,8 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
package com.baeldung.roles.rolesauthorities.persistence;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
import com.baeldung.roles.rolesauthorities.model.User;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.voter;
|
package com.baeldung.roles.voter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.voter;
|
package com.baeldung.roles.voter;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan(basePackages = { "org.baeldung.voter" })
|
@ComponentScan(basePackages = {"com.baeldung.voter"})
|
||||||
public class VoterApplication {
|
public class VoterApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
|
@ -1,10 +1,8 @@
|
||||||
package org.baeldung.voter;
|
package com.baeldung.roles.voter;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ambrusadrianz on 30/09/2016.
|
* Created by ambrusadrianz on 30/09/2016.
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.voter;
|
package com.baeldung.roles.voter;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -15,7 +15,6 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.web.access.expression.WebExpressionVoter;
|
import org.springframework.security.web.access.expression.WebExpressionVoter;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,7 +1,4 @@
|
||||||
package org.baeldung.voter;
|
package com.baeldung.roles.voter;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.ImportResource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ambrusadrianz on 09/10/2016.
|
* Created by ambrusadrianz on 09/10/2016.
|
|
@ -1,9 +0,0 @@
|
||||||
package org.baeldung.rolesauthorities.persistence;
|
|
||||||
|
|
||||||
import org.baeldung.rolesauthorities.model.User;
|
|
||||||
|
|
||||||
public interface IUserService {
|
|
||||||
|
|
||||||
User findUserByEmail(String email);
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,12 +22,12 @@
|
||||||
<beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter"/>
|
<beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter"/>
|
||||||
<beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>
|
<beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>
|
||||||
<beans:bean class="org.springframework.security.access.vote.RoleVoter"/>
|
<beans:bean class="org.springframework.security.access.vote.RoleVoter"/>
|
||||||
<beans:bean class="org.baeldung.voter.MinuteBasedVoter"/>
|
<beans:bean class="com.baeldung.roles.voter.MinuteBasedVoter"/>
|
||||||
</beans:list>
|
</beans:list>
|
||||||
</beans:constructor-arg>
|
</beans:constructor-arg>
|
||||||
</beans:bean>
|
</beans:bean>
|
||||||
|
|
||||||
<beans:bean id="minuteBasedVoter" class="org.baeldung.voter.MinuteBasedVoter"/>
|
<beans:bean id="minuteBasedVoter" class="com.baeldung.roles.voter.MinuteBasedVoter"/>
|
||||||
|
|
||||||
<authentication-manager>
|
<authentication-manager>
|
||||||
<authentication-provider>
|
<authentication-provider>
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.baeldung.relationships;
|
package com.baeldung.relationships;
|
||||||
|
|
||||||
import com.baeldung.AppConfig;
|
import com.baeldung.relationships.repositories.TweetRepository;
|
||||||
import com.baeldung.data.repositories.TweetRepository;
|
import com.baeldung.relationships.repositories.UserRepository;
|
||||||
import com.baeldung.data.repositories.UserRepository;
|
import com.baeldung.relationships.models.AppUser;
|
||||||
import com.baeldung.models.AppUser;
|
import com.baeldung.relationships.models.Tweet;
|
||||||
import com.baeldung.models.Tweet;
|
import com.baeldung.relationships.security.AppUserPrincipal;
|
||||||
import com.baeldung.security.AppUserPrincipal;
|
import com.baeldung.relationships.util.DummyContentUtil;
|
||||||
import com.baeldung.util.DummyContentUtil;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.baeldung;
|
package com.baeldung.roles;
|
||||||
|
|
||||||
import org.baeldung.custom.Application;
|
import com.baeldung.roles.custom.Application;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@ -1,9 +1,9 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.roles.web;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.baeldung.custom.persistence.model.Foo;
|
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||||
|
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
import io.restassured.authentication.FormAuthConfig;
|
import io.restassured.authentication.FormAuthConfig;
|
||||||
|
@ -13,7 +13,7 @@ import io.restassured.specification.RequestSpecification;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
||||||
// In order to execute these tests, org.baeldung.custom.Application needs to be running.
|
// In order to execute these tests, com.baeldung.custom.Application needs to be running.
|
||||||
public class ApplicationLiveTest {
|
public class ApplicationLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.roles.web;
|
||||||
|
|
||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
@ -7,8 +7,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.http.HttpHeaders;
|
import org.apache.http.HttpHeaders;
|
||||||
import org.baeldung.custom.Application;
|
import com.baeldung.roles.custom.Application;
|
||||||
import org.baeldung.custom.persistence.model.Foo;
|
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.roles.web;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -8,7 +8,7 @@ import io.restassured.response.Response;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
// In order to execute these tests, org.baeldung.ip.IpApplication needs to be running.
|
// In order to execute these tests, com.baeldung.ip.IpApplication needs to be running.
|
||||||
public class IpLiveTest {
|
public class IpLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -222,16 +222,15 @@
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<start-class>org.baeldung.custom.Application</start-class>
|
<!-- <start-class>com.baeldung.jdbcauthentication.postgre.PostgreJdbcAuthenticationApplication</start-class>-->
|
||||||
<!--If you want to run the example with the multiple logins, comment
|
<!--This runs the example with the multiple logins application -->
|
||||||
the tag above and uncomment the one below -->
|
<start-class>com.baeldung.multiplelogin.MultipleLoginApplication</start-class>
|
||||||
<!--<start-class>org.baeldung.multiplelogin.MultipleLoginApplication</start-class> -->
|
|
||||||
<!--If you want to run the example with the multiple http elements,
|
<!--If you want to run the example with the multiple http elements,
|
||||||
comment the tag above and uncomment the one below -->
|
comment the tag above and uncomment the one below -->
|
||||||
<!--<start-class>org.baeldung.multipleentrypoints.MultipleEntryPointsApplication</start-class> -->
|
<!--<start-class>com.baeldung.multipleentrypoints.MultipleEntryPointsApplication</start-class> -->
|
||||||
<!--If you want to run the example with the Https enabled endpoints,
|
<!--If you want to run the example with the Https enabled endpoints,
|
||||||
comment the tag above and uncomment the one below -->
|
comment the tag above and uncomment the one below -->
|
||||||
<!-- <start-class>org.baeldung.ssl.HttpsEnabledApplication</start-class> -->
|
<!-- <start-class>com.baeldung.ssl.HttpsEnabledApplication</start-class> -->
|
||||||
|
|
||||||
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.h2;
|
package com.baeldung.jdbcauthentication.h2;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.h2.config;
|
package com.baeldung.jdbcauthentication.h2.config;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.h2.web;
|
package com.baeldung.jdbcauthentication.h2.web;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.mysql;
|
package com.baeldung.jdbcauthentication.mysql;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.mysql.config;
|
package com.baeldung.jdbcauthentication.mysql.config;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.mysql.web;
|
package com.baeldung.jdbcauthentication.mysql.web;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.postgre;
|
package com.baeldung.jdbcauthentication.postgre;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.postgre.config;
|
package com.baeldung.jdbcauthentication.postgre.config;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.postgre.web;
|
package com.baeldung.jdbcauthentication.postgre.web;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleauthproviders;
|
package com.baeldung.multipleauthproviders;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleauthproviders;
|
package com.baeldung.multipleauthproviders;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleauthproviders;
|
package com.baeldung.multipleauthproviders;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleauthproviders;
|
package com.baeldung.multipleauthproviders;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleentrypoints;
|
package com.baeldung.multipleentrypoints;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleentrypoints;
|
package com.baeldung.multipleentrypoints;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multipleentrypoints;
|
package com.baeldung.multipleentrypoints;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multiplelogin;
|
package com.baeldung.multiplelogin;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -7,7 +7,6 @@ import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@PropertySource("classpath:application-defaults.properties")
|
@PropertySource("classpath:application-defaults.properties")
|
||||||
@ComponentScan("org.baeldung.multiplelogin")
|
|
||||||
public class MultipleLoginApplication {
|
public class MultipleLoginApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(MultipleLoginApplication.class, args);
|
SpringApplication.run(MultipleLoginApplication.class, args);
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multiplelogin;
|
package com.baeldung.multiplelogin;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -6,14 +6,12 @@ import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
import org.springframework.web.servlet.view.JstlView;
|
import org.springframework.web.servlet.view.JstlView;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("org.baeldung.controller")
|
|
||||||
public class MultipleLoginMvcConfig implements WebMvcConfigurer {
|
public class MultipleLoginMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
public MultipleLoginMvcConfig() {
|
public MultipleLoginMvcConfig() {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multiplelogin;
|
package com.baeldung.multiplelogin;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.multiplelogin;
|
package com.baeldung.multiplelogin;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ssl;
|
package com.baeldung.ssl;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.ssl;
|
package com.baeldung.ssl;
|
||||||
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
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.EnableWebSecurity;
|
|
@ -1,8 +1,7 @@
|
||||||
package org.baeldung.ssl;
|
package com.baeldung.ssl;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WelcomeController {
|
public class WelcomeController {
|
|
@ -1,6 +1,5 @@
|
||||||
package org.baeldung.jdbcauthentication.h2;
|
package com.baeldung.jdbcauthentication.h2;
|
||||||
|
|
||||||
import org.baeldung.jdbcauthentication.h2.H2JdbcAuthenticationApplication;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.h2.web;
|
package com.baeldung.jdbcauthentication.h2.web;
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.given;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.mysql.web;
|
package com.baeldung.jdbcauthentication.mysql.web;
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.given;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.jdbcauthentication.postgre.web;
|
package com.baeldung.jdbcauthentication.postgre.web;
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.given;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.web;
|
||||||
|
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
import org.baeldung.ssl.HttpsEnabledApplication;
|
import com.baeldung.ssl.HttpsEnabledApplication;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.web;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.baeldung.multipleauthproviders.MultipleAuthProvidersApplication;
|
import com.baeldung.multipleauthproviders.MultipleAuthProvidersApplication;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web;
|
package com.baeldung.web;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -15,7 +15,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||||
|
|
||||||
import org.baeldung.multipleentrypoints.MultipleEntryPointsApplication;
|
import com.baeldung.multipleentrypoints.MultipleEntryPointsApplication;
|
||||||
|
|
||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*;
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*;
|
||||||
|
|
Loading…
Reference in New Issue