Add Source Code Linter Pipeline
This commit is contained in:
parent
0d0e7140c4
commit
d252f6ef50
313 changed files with 36277 additions and 0 deletions
36
screwdriver-3.5.6/box/snippets/java/UserAuthorityUtils.java
Normal file
36
screwdriver-3.5.6/box/snippets/java/UserAuthorityUtils.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package +zoccolo+.web.authentication.authority;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
|
||||
import +tabposition+.+tabella+;
|
||||
|
||||
/**
|
||||
* A utility class used for creating the {@link GrantedAuthority}'s given a {@link +tabella+}. In a real solution
|
||||
* this would be looked up in the existing system, but for simplicity our original system had no notion of authorities.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*
|
||||
*/
|
||||
public final class UserAuthorityUtils {
|
||||
|
||||
private static final List<GrantedAuthority> ADMIN_ROLES = AuthorityUtils.createAuthorityList("ROLE_ADMIN",
|
||||
"ROLE_USER");
|
||||
private static final List<GrantedAuthority> USER_ROLES = AuthorityUtils.createAuthorityList("ROLE_USER");
|
||||
|
||||
private UserAuthorityUtils() {
|
||||
|
||||
}
|
||||
|
||||
public static Collection<? extends GrantedAuthority> createAuthorities(+tabella+ user) {
|
||||
String username = user.getChiave();
|
||||
// NON CANCELLARE
|
||||
if (username.startsWith("admin")) {
|
||||
return ADMIN_ROLES;
|
||||
}
|
||||
return USER_ROLES;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue