[BAEL1411-tlinh2110] Add Class Level Security Example

This commit is contained in:
linhvovn
2017-12-31 22:56:35 +08:00
parent 0d84b1f0c1
commit 1b7e6957bb
5 changed files with 85 additions and 3 deletions
@@ -0,0 +1,18 @@
package org.baeldung.methodsecurity.service;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
@Service
@PreAuthorize("hasRole('ROLE_ADMIN')")
public class SystemService {
public String getSystemYear(){
return "2017";
}
public String getSystemDate(){
return "31-12-2017";
}
}
@@ -103,5 +103,5 @@ public class UserRoleService {
public CustomUser securedLoadUserDetail(String username){
return userRoleRepository.loadUserByUserName(username);
}
}