This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "USERS") | |
public class User implements Serializable | |
{ | |
private static final long serialVersionUID = 1L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
@Column(name = "user_id") | |
private Integer id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.data</groupId> | |
<artifactId>spring-data-jpa</artifactId> | |
<version>1.5.0.RELEASE</version> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.data</groupId> | |
<artifactId>spring-data-rest-webmvc</artifactId> | |
<version>2.0.0.RELEASE</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Email: <sec:authentication property="name"/></h3> | |
<h3> | |
<sec:authorize access="hasRole('ROLE_ADMIN')"> | |
<a href="admin">Administration</a> | |
</sec:authorize> | |
</h3> | |
<p> <a href="logout">Logout</a></p> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> | |
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %> | |
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> | |
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> | |
<c:url var="rootURL" value="/"/> | |
<html> | |
<head> | |
<title>Login</title> | |
<link href="${rootURL}resources/bootstrap/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SpringWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer | |
{ | |
@Override | |
protected Class<?>[] getRootConfigClasses() | |
{ | |
return new Class<?>[] { AppConfig.class}; | |
//As we have SecurityConfig.java in same package as AppConfig.java and enabled ComponentScan to scan "com.sivalabs.springapp.config" we don't need to explicitely configure it. | |
//otherwise we should add SecurityConfig.class to getRootConfigClasses() | |
//return new Class<?>[] { AppConfig.class, SecurityConfig.class}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.springapp.config; | |
import javax.sql.DataSource; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.springapp.config; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.security.core.userdetails.UserDetails; | |
import org.springframework.security.core.userdetails.UserDetailsService; | |
import org.springframework.security.core.userdetails.UsernameNotFoundException; | |
import org.springframework.stereotype.Component; | |
import com.sivalabs.springapp.entities.User; | |
import com.sivalabs.springapp.services.UserService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.springapp.web.config; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Set; | |
import org.springframework.security.core.GrantedAuthority; | |
import org.springframework.security.core.authority.SimpleGrantedAuthority; | |
import org.springframework.security.core.userdetails.UserDetails; | |
import com.sivalabs.springapp.entities.Role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.springapp.web.config; | |
import javax.servlet.Filter; | |
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter; | |
import org.springframework.web.filter.DelegatingFilterProxy; | |
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; | |
import com.sivalabs.springapp.config.AppConfig; | |
public class SpringWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.springapp.web.config; | |
import java.util.Properties; | |
import org.springframework.context.MessageSource; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.support.ReloadableResourceBundleMessageSource; | |
import org.springframework.web.servlet.ViewResolver; |