Package at.riemers.zero.base.model

Examples of at.riemers.zero.base.model.PermissionTemplate



  @Override
  public List<PermissionTemplate> getPermissionTemplates() {
    List<PermissionTemplate> objects = new ArrayList<PermissionTemplate>();
    objects.add(new PermissionTemplate(this, AUTH_USER_EDIT, false));
    PermissionTemplate userPermission = new PermissionTemplate(this, AUTH_USER, true);
   
    List<UserGroup> userGroups = userGroupDao.findAll();
    userPermission.addValue(new KeyValue("*","All Groups"));
    for(UserGroup userGroup : userGroups) {
        KeyValue v = new KeyValue(userGroup.getGroupKey(), userGroup.getGroupKey() + " - " + userGroup.getDescription());
        userPermission.addValue(v);
    }
   
    objects.add(userPermission);
   
    objects.add(new PermissionTemplate(this, AUTH_ROLE_EDIT, false));
    objects.add(new PermissionTemplate(this, AUTH_FUNCTION_LOG, false));
    objects.add(new PermissionTemplate(this, AUTH_CURRENT_USERS, false));
    objects.add(new PermissionTemplate(this, AUTH_USER_CHANGE_PWD, false));
    objects.add(new PermissionTemplate(this, AUTH_LOGIN_AS, false));
    objects.add(new ValueRangePermissionTemplate(this, AUTH_USER_TEST_VALUE_RANGE, 5, 20));
   
    return objects;
  }
View Full Code Here


            Set<Permission> permissions = (Set<Permission>) session.getAttribute("permissions");
            try {
                for (String key : selected.getSelected().keySet()) {
                    log.info("key: " + key);
                    PermissionTemplate permissionTemplate = getModuleManager().getPermissionTemplate(key);

                    if (permissionTemplate != null) {
                        Permission permission = permissionTemplate.createPermission();
                        permissions.add(permission);
                    } else {
                        log.warn("permission not found");
                    }
                }
View Full Code Here

            try {
                for (String key : selected.getSelected().keySet()) {
                    log.info("key: " + key);

                    PermissionTemplate permissionTemplate = getModuleManager().getPermissionTemplate(key);

                    if (permissionTemplate != null) {
                        for (Permission p : new ArrayList<Permission>(permissions)) {
                            if (p.getKey().equals(permissionTemplate.getKey())) {
                                permissions.remove(p);
                            }
                        }
                    } else {
                        log.warn("permission not found");
View Full Code Here

            boolean error = false;
            for (String permissionKey : roleForm.getValues().keySet()) {
                Permission permission = role.getPermission(permissionKey);
                if (permission != null) {
                    PermissionTemplate permissionTemplate = getModuleManager().getPermissionTemplate(permissionKey);
                    if (permissionTemplate != null) {
                        String value = roleForm.getValues().get(permissionKey);
                        if (permissionTemplate.isValuePermission()) {
                            if (permissionTemplate.checkValue(value)) {
                                permission.setValue(value);
                            } else {
                                if (permissionTemplate.getValueRangeMessage() != null) {
                                    view.setMessage(permissionTemplate.getValueRangeMessage());
                                    error = true;
                                }
                            }
                        }
                    }
View Full Code Here

    public static JSONArray createPermissions(Collection<Permission> permissions, ModuleManager moduleController) {

        Map<String, List<Permission>> pMap = new TreeMap();
        for (Permission permission : permissions) {
            if (moduleController != null) {
                PermissionTemplate permissionTemplate = moduleController.getPermissionTemplate(permission.getKey());
                if (permissionTemplate != null) {
                    List<Permission> ps = pMap.get(permissionTemplate.getModule().getName());
                    if (ps == null) {
                        ps = new ArrayList<Permission>();
                        pMap.put(permissionTemplate.getModule().getName(), ps);
                    }
                    ps.add(permission);
                }
            }

        }

        JSONArray jmodules = new JSONArray();
        for (String module : pMap.keySet()) {
            JSONObject jModule = new JSONObject();
            jmodules.element(jModule);
            jModule.element("name", module);
            JSONArray jpermissions = new JSONArray();
            jModule.element("permissions", jpermissions);
            Collections.sort(pMap.get(module));
            for (Permission permission : pMap.get(module)) {
                JSONObject jpermission = new JSONObject();
                jpermissions.element(jpermission);
                jpermission.element("key", permission.getKey());
                jpermission.element("value", permission.getValue());
                jpermission.element("isValuePermission", permission.isValuePermission());
                if (moduleController != null) {
                    PermissionTemplate permissionTemplate = moduleController.getPermissionTemplate(permission.getKey());
                    if (permissionTemplate != null) {
                        jpermission.element("editor", "v2js_" + permissionTemplate.getEditorTemplate());
                        if (!permissionTemplate.getValues().isEmpty()) {
                            JSONArray jvalues = new JSONArray();
                            jpermission.element("values", jvalues);
                            for (KeyValue value : permissionTemplate.getValues()) {
                                JSONObject jvalue = new JSONObject();
                                jvalues.element(jvalue);
                                jvalue.element("key", value.getKey());
                                jvalue.element("text", value.getValue());
                            }
View Full Code Here


  @Override
  public List<PermissionTemplate> getPermissionTemplates() {
    List<PermissionTemplate> objects = new ArrayList<PermissionTemplate>();
    objects.add(new PermissionTemplate(this, AUTH_RESOURCE_EDIT, false));
    objects.add(new PermissionTemplate(this, AUTH_RESOURCE_IMPORT, false));
   
    return objects;
  }
View Full Code Here

    }

    private String checkRoles(ZeroUser user) {
        for (Role role : user.getRoles()) {
            for (Permission permission : role.getPermissions()) {
                PermissionTemplate pt = getModuleManager().getPermissionTemplate(permission.getKey());
                for (String key : pt.getDependencies()) {
                    if (!user.checkAuthorisation(key)) {
                        return key;
                    }
                }
            }
View Full Code Here

TOP

Related Classes of at.riemers.zero.base.model.PermissionTemplate

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.