Package org.encuestame.persistence.domain.security

Examples of org.encuestame.persistence.domain.security.Permission


        final Collection<Permission> listPermission = getPermissionDao()
                .loadAllPermissions();
        for (Iterator<Permission> iterator = listPermission.iterator(); iterator
                .hasNext();) {
            final UnitPermission permissionBean = new UnitPermission();
            Permission permission = iterator.next();
            if (!permission.equals(EnMePermission.ENCUESTAME_USER)) { //this permissions not should be included.
                permissionBean.setId(permission.getIdPermission());
                permissionBean.setPermission(permission.getPermission().toString());
                permissionBean.setDescription(permission.getPermissionDescription());
                loadListPermission.add(permissionBean);
            }
        }
        return loadListPermission;
    }
View Full Code Here


    /**
     * Create a new Permisssion.
     * @param permissionBean {@link UnitPermission}
     */
    public void createPermission(final UnitPermission permissionBean) {
        final Permission permissionDomain = new Permission();
        permissionDomain.setPermission(EnMePermission.getPermissionString(permissionBean.getPermission()));
        permissionDomain.setPermissionDescription(permissionBean.getDescription());
        getPermissionDao().saveOrUpdate(permissionDomain);
    }
View Full Code Here

            }
            // save user
            getAccountDao().saveOrUpdate(userAccount);
            // assing first default group to user
            final UserAccount retrievedUser = getAccountDao().getUserAccountById(userAccount.getUid());
            final Permission permission = getPermissionByName(SecurityService.DEFAULT);
            if (permission != null) {
                final List<Permission> all = getPermissionDao().findAllPermissions();
                log.info("all permission "+all.size());
                log.info("default permission "+permission);
                retrievedUser.getSecUserPermissions().add(permission);
View Full Code Here

     * Get Permission by {@link EnMePermission}.
     * @param permission permission.
     * @return
     */
    public Permission getPermissionByName(final EnMePermission permission){
        final Permission permission2 = getPermissionDao().loadPermission(permission);
        return permission2;
    }
View Full Code Here

            final UserAccountBean userBean,
            final UnitPermission permissionBean)
            throws EnMeExpcetion
   {
        UserAccount userDomain = null;
        Permission permissionDomain = null;
        log.info("userBean found "+userBean.getId());
        log.info("permissionBean found "+permissionBean.getId());
        if (userBean.getId() != null) {
            userDomain = getAccountDao().getUserAccountById(userBean.getId());
            log.info("user found "+userDomain);
        }
        if (permissionBean.getId() != null) {
            permissionDomain = getPermissionDao().getPermissionById(permissionBean.getId());
            log.info("permission found "+permissionDomain);
        }
        if (userDomain != null && permissionDomain != null) {
           log.info("saving permissions");
           log.info("permission selected "+permissionDomain.getPermission());
           log.info("user selected "+userDomain.getUid());
           userDomain.getSecUserPermissions().add(permissionDomain);
           getAccountDao().saveOrUpdate(userDomain);
           log.info("saved permission "+userDomain.getSecUserPermissions().size());
        } else {
View Full Code Here

     * @param permission permission
     * @return permission bean
     */
    public UnitPermission loadBeanPermission(final EnMePermission permission) {
        UnitPermission permissionBean = null;
        final Permission permissionDomain = getPermissionDao().loadPermission(permission);
        if(permissionDomain != null){
             permissionBean = ConvertDomainBean.convertPermissionToBean(permissionDomain);
        }
        return permissionBean;
    }
View Full Code Here

    /**
     * Test Load Permission.
     */
    @Test
    public void testloadPermission(){
        final Permission retrievedPermission = getPermissionDaoImp().loadPermission(EnMePermission.ENCUESTAME_USER);
        assertEquals("should be equals", permission.getPermission(), retrievedPermission.getPermission());
    }
View Full Code Here

    /**
     *
     */
    @Test
    public void testGetPermissionById(){
        final Permission perm = getPermissionDaoImp().getPermissionById(this.permission.getIdPermission());
        assertNotNull(perm);
        assertEquals("should be equals", EnMePermission.ENCUESTAME_USER, perm.getPermission());
    }
View Full Code Here

     * Test Create Permission.
     */
    @Category(DefaultTest.class)
    @Test
    public void testCreatePermission() {
        final Permission secPerm = createPermission("writer");
        final UnitPermission permissionBean = ConvertDomainBean
                .convertPermissionToBean(secPerm);
        securityService.createPermission(permissionBean);
        final Permission permissionRetrieve = getPermissionDaoImp()
                .getPermissionById(secPerm.getIdPermission());
        assertNotNull(permissionRetrieve);
        assertEquals("should be", "writer",
                permissionRetrieve.getPermissionDescription());

    }
View Full Code Here

     * Helper to create Permission.
     * @param permissionName name
     * @return Permission
     */
    public Permission createPermission(final String permissionName){
        final Permission permission = new Permission();
        permission.setPermissionDescription(permissionName);
        permission.setPermission(EnMePermission.getPermissionString(permissionName));
        getPermissionDaoImp().saveOrUpdate(permission);
        return permission;
    }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.security.Permission

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.