[BAEL-1411] Format code
This commit is contained in:
parent
1b7e6957bb
commit
2bac6f88e7
@ -10,6 +10,5 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@PreAuthorize("hasRole('VIEWER')")
|
@PreAuthorize("hasRole('VIEWER')")
|
||||||
public @interface IsViewer
|
public @interface IsViewer {
|
||||||
{
|
|
||||||
}
|
}
|
@ -52,7 +52,7 @@ public class UserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||||
public String getUsernameInLowerCase(){
|
public String getUsernameLC() {
|
||||||
return getUsername().toLowerCase();
|
return getUsername().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class UserRoleService {
|
|||||||
return securityContext
|
return securityContext
|
||||||
.getAuthentication()
|
.getAuthentication()
|
||||||
.getAuthorities()
|
.getAuthorities()
|
||||||
.stream().map(auth -> auth.getAuthority())
|
.stream()
|
||||||
.collect(Collectors.joining(","));
|
.map(auth -> auth.getAuthority()).collect(Collectors.joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostAuthorize("returnObject.username == authentication.principal.nickName")
|
@PostAuthorize("returnObject.username == authentication.principal.nickName")
|
||||||
@ -83,8 +83,7 @@ public class UserRoleService {
|
|||||||
|
|
||||||
@PreFilter(value = "filterObject != authentication.principal.username", filterTarget = "usernames")
|
@PreFilter(value = "filterObject != authentication.principal.username", filterTarget = "usernames")
|
||||||
public String joinUsernamesAndRoles(List<String> usernames, List<String> roles) {
|
public String joinUsernamesAndRoles(List<String> usernames, List<String> roles) {
|
||||||
return usernames.stream().collect(Collectors.joining(";"))
|
return usernames.stream().collect(Collectors.joining(";")) + ":" + roles.stream().collect(Collectors.joining(";"));
|
||||||
+":"+roles.stream().collect(Collectors.joining(";"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostFilter("filterObject != authentication.principal.username")
|
@PostFilter("filterObject != authentication.principal.username")
|
||||||
|
@ -81,7 +81,7 @@ public class TestMethodSecurity{
|
|||||||
@Test
|
@Test
|
||||||
@WithMockUser(username = "JOHN", authorities = { "SYS_ADMIN" })
|
@WithMockUser(username = "JOHN", authorities = { "SYS_ADMIN" })
|
||||||
public void givenAuthoritySysAdmin_whenCallGetUsernameInLowerCase_thenReturnUsername() {
|
public void givenAuthoritySysAdmin_whenCallGetUsernameInLowerCase_thenReturnUsername() {
|
||||||
String username = userRoleService.getUsernameInLowerCase();
|
String username = userRoleService.getUsernameLC();
|
||||||
assertEquals("john", username);
|
assertEquals("john", username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user