Package be.c4j.demo.security.demo.model

Examples of be.c4j.demo.security.demo.model.Principal


    @Inject
    private PermissionService permissionService;

    @Override
    public AuthenticationInfo getAuthenticationInfo(UsernamePasswordToken token) {
        Principal principal = permissionService.getPrincipalByUserName(token.getUsername());

        if (principal == null) {
            return null;
        } else {

            AuthenticationInfoBuilder authenticationInfoBuilder = new AuthenticationInfoBuilder();
            authenticationInfoBuilder.principalId(principal.getId()).name(principal.getEmployee().getName());
            authenticationInfoBuilder.password(principal.getPassword()) ;

            authenticationInfoBuilder.addUserInfo(UserInfo.EMPLOYEE_ID, principal.getEmployee().getId());
            if (principal.getEmployee().getDepartment() != null) {

                authenticationInfoBuilder.addUserInfo(UserInfo.DEPARTMENT_ID, principal.getEmployee().getDepartment().getId());
            }

            if (principal.getEmployee().getManager() != null) {
                authenticationInfoBuilder.addUserInfo(UserInfo.MANAGER_EMPLOYEE_ID, principal.getEmployee().getManager().getId());
            }


            return authenticationInfoBuilder.build();
        }
View Full Code Here


        addPrincipal(112L, "JMURMAN", "NAMRUMJ");
        addPrincipal(113L, "LPOPP", "PPOPL");
    }

    private void addPrincipal(Long employeeId, String userName, String password) {
        Principal principal = new Principal();
        principal.setUserName(userName);
        principal.setPassword(password);
        principal.setEmployee(employees.get(employeeId));

        principals.put(userName, principal);
        principalsByUUID.put(principal.getId(), principal);
    }
View Full Code Here

    }

    private void grantDepartmentSalaryManager() {
        HRAppPermission permission = createPermissionDepartmentSalaryManager();
        for (Department department : departments.values()) {
            Principal manager = findPrincipal(department.getManager());
            if (manager.getEmployee().getId() != 100) {

                manager.addPermission(permission);
            }
        }
    }
View Full Code Here

        HRAppPermission permission = createPermissionDepartmentCreate();
        grantPermissions(permission, new Long[]{}, new Long[]{108L}, new Long[]{});
    }

    private Principal findPrincipal(Employee manager) {
        Principal result = null;
        Iterator<Principal> principalIterator = principals.values().iterator();
        while (result == null && principalIterator.hasNext()) {
            Principal principal = principalIterator.next();
            if (manager.equals(principal.getEmployee())) {
                result = principal;
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of be.c4j.demo.security.demo.model.Principal

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.