Package aim.domain.security

Examples of aim.domain.security.Account


    public List<UserRoles> getUserRoles() {
        return userInfo.getUserRoles();
    }

    public Passport getUserPassport(){
        Account user = userService.getEmployeeByNickName(userInfo.getNickname());
        return user.getId();
    }
View Full Code Here


     * Provides setup of agent
     */
    public void setAgent() {
        if (agentPassportNumber != null && !agentPassportNumber.isEmpty()) {
            agentPassport = new Passport(agentPassportSerie, agentPassportNumber);
            final Account employer = userService.getAccountByPassport(agentPassport);
            agentFLP = employer.getEmployee().toString();
            agentToDisplay = new EmployeeDTO(employer.getEmployee(), employer.getAccount().getUsername(), employer.getAssociatedRoles());

            showStatistic();
        }
    }
View Full Code Here

    /**
     * {@inheritDoc }
     */
    @Override
    public Account getAccountByPassport(Passport passport) throws NoResultException {
        Account user = entityManager.find(Account.class, passport);
        if (user != null) {
            return user;
        } else {
            throw new NoResultException();
        }
View Full Code Here

    @Test
    public void testGetEmployeesByOffice() {
        final int agentFromKievCount = 1;
        final Passport firstAgentId = new Passport("АВ", "468454");
        final Account firstAgent = new Account(new Employee(firstAgentId, "Иванов", "Иван"));
        final Set<UserRoles> firstAgentUserRoles = new TreeSet<UserRoles>();
        firstAgentUserRoles.add(UserRoles.ROLE_AGENT);
        firstAgent.setAssociatedRoles(firstAgentUserRoles);
        userDAO.persist(firstAgent);
        final Office office = new Office("Kiev");
        userDAO.persist(office);
        firstAgent.getEmployee().setOffice(office);

        final Passport secondAgentId = new Passport("АУ", "468454");
        final Account secondAgent = new Account(new Employee(secondAgentId, "Иванов", "Иван"));
        final List<UserRoles> secondAgentUserRoles = new ArrayList<UserRoles>();
        secondAgentUserRoles.add(UserRoles.ROLE_AGENT);
        secondAgent.setAssociatedRoles(firstAgentUserRoles);
        userDAO.persist(secondAgent);

        final List<Account> foundAgents = userDAO.findEmployeesByCriteria(UserSearchCriteria.createCriteria().setOffice(office.getTitle()));

        assertNotNull(foundAgents);
View Full Code Here

        serie32.setPolicyType(policyType3);
        serie33.setPolicyType(policyType3);
        entityManager.persist(policyType3);


        final Account admin = new Account(new Employee(new Passport("АВ", "468454"), "Иванов", "Иван"));
        final User aimSecurityAdimn = new User("admin", "a4a88c0872bf652bb9ed803ece5fd6e82354838a9bf59ab4babb1dab322154e1");
        Set<UserRoles> userRoles = new TreeSet<UserRoles>();
        userRoles.add(UserRoles.ROLE_USER);
        userRoles.add(UserRoles.ROLE_ADMIN);
        admin.setAssociatedRoles(userRoles);
        admin.setAccount(aimSecurityAdimn);
        Office office = new Office("Центральный");
        entityManager.persist(office);
        admin.getEmployee().setOffice(office);
        entityManager.persist(admin);
 
    }
View Full Code Here

     * {@inheritDoc }
     */
    @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
    @Override
    public void updateEmployeeFromView(EmployeeDTO employeeDTO) {
        final Account oldEmployee = userDAO.getAccountByPassport(employeeDTO.getUserInfo().getId());
        oldEmployee.setAssociatedRoles(new TreeSet<UserRoles>(employeeDTO.getUserRoles()));
        Employee newEmployeeInfo = employeeDTO.getUserInfo();
        Employee oldEmployeeInfo = oldEmployee.getEmployee();
        oldEmployeeInfo.setFirstName( newEmployeeInfo.getFirstName() );
        oldEmployeeInfo.setLastName( newEmployeeInfo.getLastName() );
        oldEmployeeInfo.setParentName( newEmployeeInfo.getParentName() );
        oldEmployeeInfo.setAddress( newEmployeeInfo.getAddress() );
        oldEmployeeInfo.setEmail( newEmployeeInfo.getEmail() );
View Full Code Here

    /**
     * {@inheritDoc }
     */
    @Override
    public EmployeeDTO getEmployeeSafeInformation(String userNickname) {
        final Account employee = userDAO.getUserByNickName(userNickname);
        return new EmployeeDTO(employee.getEmployee(), userNickname, employee.getAssociatedRoles());
    }
View Full Code Here

     * {@inheritDoc }
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        User account = userService.getAccountByNickname(username);
        Account user = userService.getEmployeeByNickName(username);
        List<GrantedAuthority> grantedAuthority = new ArrayList<GrantedAuthority>();
        for (UserRoles role : user.getAssociatedRoles()) {
            grantedAuthority.add(new GrantedAuthorityImpl(role.toString()));
        }

        account.setGrantedAuthoritys((GrantedAuthority[]) grantedAuthority.toArray(new GrantedAuthority[grantedAuthority.size()]));
        return account;
View Full Code Here

    @Test
    public void testGetAllAgents() {
        final int agentCount = 2;

        final Account firstAgent = new Account(new Employee(new Passport("АВ", "468454"), "Иванов", "Иван"));
        final Set<UserRoles> firstAgentUserRoles = new TreeSet<UserRoles>();
        firstAgentUserRoles.add(UserRoles.ROLE_AGENT);
        firstAgent.setAssociatedRoles(firstAgentUserRoles);
        userDAO.persist(firstAgent);

        final Account secondAgent = new Account(new Employee(new Passport("АП", "468454"), "Иванов", "Иван"));
        final Set<UserRoles> secondAgentUserRoles = new TreeSet<UserRoles>();
        secondAgentUserRoles.add(UserRoles.ROLE_AGENT);
        secondAgent.setAssociatedRoles(secondAgentUserRoles);
        userDAO.persist(secondAgent);

        final List<Employee> agents = agentDAO.getAllAgents();
        assertNotNull(agents);
        assertEquals(agentCount, agents.size());
View Full Code Here

    @Test
    public void testGetAgentPolicy() {
        final Passport agentId = new Passport("АВ", "468454");
        final Employee employee = new Employee(agentId, "Иванов", "Иван");
        final Account agent = new Account(employee);
        final Set<UserRoles> firstAgentUserRoles = new TreeSet<UserRoles>();
        firstAgentUserRoles.add(UserRoles.ROLE_AGENT);
        agent.setAssociatedRoles(firstAgentUserRoles);
        userDAO.persist(agent);
        final PolicySeries serie = new PolicySeries("dasdas");
        final PolicyType type = new PolicyType("AUTOS", "for auto insurance");
        type.getTypeSeries().add(serie);
        serie.setPolicyType(type);
View Full Code Here

TOP

Related Classes of aim.domain.security.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.