// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/model/Role.java
// public enum Role {
//     GUEST, USER, ADMIN, SYSTEM;
// }
// 
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/service/AccountDao.java
// @Service
// public class AccountDao extends AbstractDao {
//     public Account getAccount(String username) {
//         List<?> result = getEntityManager()
//             .createQuery("SELECT A FROM Account A WHERE A.user.username = :username")
//             .setParameter("username", username)
//             .getResultList();
//         
//         if (result.size() == 0) {
//             return null;
//         }
//         return (Account)result.get(0);
//     }
//     
//     @Transactional
//     public void addAccount(Account account) {
//         getEntityManager().persist(account);
//     }
// }
// 
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/service/UserDao.java
// @Service
// public class UserDao extends AbstractDao {
//     
//     public List<User> getUsers() {
//         return castList(getEntityManager().createQuery("SELECT U FROM User U").getResultList(), User.class);
//     }
//     
//     @Transactional
//     public void addUser(User user) {
//         getEntityManager().persist(user);
//     }
//     
// }


import com.coverity.security.pie.example.model.Role;
import com.coverity.security.pie.example.service.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.coverity.security.pie.example.service.UserDao;
// (c) 2014 Coverity, Inc. All rights reserved worldwide.
package com.coverity.security.pie.example.controller;



@Controller
public class HelloWorldController {
    
    @Autowired
    private UserDao userDao;
    
    @Autowired
    private AccountDao accountDao;
    
    @RequestMapping("getUsers")
    public ModelMap getUsers() {
        
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/model/Role.java
// public enum Role {
//     GUEST, USER, ADMIN, SYSTEM;
// }
// 
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/service/AccountDao.java
// @Service
// public class AccountDao extends AbstractDao {
//     public Account getAccount(String username) {
//         List<?> result = getEntityManager()
//             .createQuery("SELECT A FROM Account A WHERE A.user.username = :username")
//             .setParameter("username", username)
//             .getResultList();
//         
//         if (result.size() == 0) {
//             return null;
//         }
//         return (Account)result.get(0);
//     }
//     
//     @Transactional
//     public void addAccount(Account account) {
//         getEntityManager().persist(account);
//     }
// }
// 
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/service/UserDao.java
// @Service
// public class UserDao extends AbstractDao {
//     
//     public List<User> getUsers() {
//         return castList(getEntityManager().createQuery("SELECT U FROM User U").getResultList(), User.class);
//     }
//     
//     @Transactional
//     public void addUser(User user) {
//         getEntityManager().persist(user);
//     }
//     
// }


// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/controller/HelloWorldController.java
import com.coverity.security.pie.example.model.Role;
import com.coverity.security.pie.example.service.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.coverity.security.pie.example.service.UserDao;

// (c) 2014 Coverity, Inc. All rights reserved worldwide.
package com.coverity.security.pie.example.controller;



@Controller
public class HelloWorldController {
    
    @Autowired
    private UserDao userDao;
    
    @Autowired
    private AccountDao accountDao;
    
    @RequestMapping("getUsers")
    public ModelMap getUsers() {
        
        if (!SecurityContextHolder.getContext().getAuthentication().getAuthorities()