Search in sources :

Example 1 with SecurityGroupsBuilder

use of com.salesmanager.core.business.utils.SecurityGroupsBuilder in project shopizer by shopizer-ecommerce.

the class InitializationDatabaseImpl method createSecurityGroups.

private void createSecurityGroups() throws ServiceException {
    // create permissions
    // Map name object
    Map<String, Permission> permissionKeys = new HashMap<String, Permission>();
    Permission AUTH = new Permission("AUTH");
    permissionService.create(AUTH);
    permissionKeys.put(AUTH.getPermissionName(), AUTH);
    Permission SUPERADMIN = new Permission("SUPERADMIN");
    permissionService.create(SUPERADMIN);
    permissionKeys.put(SUPERADMIN.getPermissionName(), SUPERADMIN);
    Permission ADMIN = new Permission("ADMIN");
    permissionService.create(ADMIN);
    permissionKeys.put(ADMIN.getPermissionName(), ADMIN);
    Permission PRODUCTS = new Permission("PRODUCTS");
    permissionService.create(PRODUCTS);
    permissionKeys.put(PRODUCTS.getPermissionName(), PRODUCTS);
    Permission ORDER = new Permission("ORDER");
    permissionService.create(ORDER);
    permissionKeys.put(ORDER.getPermissionName(), ORDER);
    Permission CONTENT = new Permission("CONTENT");
    permissionService.create(CONTENT);
    permissionKeys.put(CONTENT.getPermissionName(), CONTENT);
    Permission STORE = new Permission("STORE");
    permissionService.create(STORE);
    permissionKeys.put(STORE.getPermissionName(), STORE);
    Permission TAX = new Permission("TAX");
    permissionService.create(TAX);
    permissionKeys.put(TAX.getPermissionName(), TAX);
    Permission PAYMENT = new Permission("PAYMENT");
    permissionService.create(PAYMENT);
    permissionKeys.put(PAYMENT.getPermissionName(), PAYMENT);
    Permission CUSTOMER = new Permission("CUSTOMER");
    permissionService.create(CUSTOMER);
    permissionKeys.put(CUSTOMER.getPermissionName(), CUSTOMER);
    Permission SHIPPING = new Permission("SHIPPING");
    permissionService.create(SHIPPING);
    permissionKeys.put(SHIPPING.getPermissionName(), SHIPPING);
    Permission AUTH_CUSTOMER = new Permission("AUTH_CUSTOMER");
    permissionService.create(AUTH_CUSTOMER);
    permissionKeys.put(AUTH_CUSTOMER.getPermissionName(), AUTH_CUSTOMER);
    SecurityGroupsBuilder groupBuilder = new SecurityGroupsBuilder();
    groupBuilder.addGroup("SUPERADMIN", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("SUPERADMIN")).addPermission(permissionKeys.get("ADMIN")).addPermission(permissionKeys.get("PRODUCTS")).addPermission(permissionKeys.get("ORDER")).addPermission(permissionKeys.get("CONTENT")).addPermission(permissionKeys.get("STORE")).addPermission(permissionKeys.get("TAX")).addPermission(permissionKeys.get("PAYMENT")).addPermission(permissionKeys.get("CUSTOMER")).addPermission(permissionKeys.get("SHIPPING")).addGroup("ADMIN", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("ADMIN")).addPermission(permissionKeys.get("PRODUCTS")).addPermission(permissionKeys.get("ORDER")).addPermission(permissionKeys.get("CONTENT")).addPermission(permissionKeys.get("STORE")).addPermission(permissionKeys.get("TAX")).addPermission(permissionKeys.get("PAYMENT")).addPermission(permissionKeys.get("CUSTOMER")).addPermission(permissionKeys.get("SHIPPING")).addGroup("ADMIN_RETAILER", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("ADMIN")).addPermission(permissionKeys.get("PRODUCTS")).addPermission(permissionKeys.get("ORDER")).addPermission(permissionKeys.get("CONTENT")).addPermission(permissionKeys.get("STORE")).addPermission(permissionKeys.get("TAX")).addPermission(permissionKeys.get("PAYMENT")).addPermission(permissionKeys.get("CUSTOMER")).addPermission(permissionKeys.get("SHIPPING")).addGroup("ADMIN_STORE", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("CONTENT")).addPermission(permissionKeys.get("STORE")).addPermission(permissionKeys.get("TAX")).addPermission(permissionKeys.get("PAYMENT")).addPermission(permissionKeys.get("CUSTOMER")).addPermission(permissionKeys.get("SHIPPING")).addGroup("ADMIN_CATALOGUE", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("PRODUCTS")).addGroup("ADMIN_ORDER", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("ORDER")).addGroup("ADMIN_CONTENT", GroupType.ADMIN).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("CONTENT")).addGroup("CUSTOMER", GroupType.CUSTOMER).addPermission(permissionKeys.get("AUTH")).addPermission(permissionKeys.get("AUTH_CUSTOMER"));
    for (Group g : groupBuilder.build()) {
        groupService.create(g);
    }
}
Also used : Group(com.salesmanager.core.model.user.Group) HashMap(java.util.HashMap) Permission(com.salesmanager.core.model.user.Permission) SecurityGroupsBuilder(com.salesmanager.core.business.utils.SecurityGroupsBuilder)

Aggregations

SecurityGroupsBuilder (com.salesmanager.core.business.utils.SecurityGroupsBuilder)1 Group (com.salesmanager.core.model.user.Group)1 Permission (com.salesmanager.core.model.user.Permission)1 HashMap (java.util.HashMap)1