Search in sources :

Example 1 with Privilege

use of org.onebusaway.admin.model.role.Privilege in project onebusaway-application-modules by camsys.

the class AccessControlServiceImpl method init.

@PostConstruct
private void init() throws Exception {
    roleByName = new ConcurrentHashMap<String, Role>();
    List<Map<String, String>> settings = _configurationServiceClient.getItems("config", "list");
    if (settings == null)
        throw new Exception("No configuration supplied");
    for (Map<String, String> setting : settings) {
        if ((setting.containsKey("component") && privilegeComponent.equals(setting.get("component"))) && setting.containsKey("key")) {
            String roleName = setting.get("key");
            String privListString = setting.get("value");
            if (privListString.equals("*")) {
                Role role = new Role(roleName, null);
                roleByName.put(roleName, role);
                continue;
            }
            Set<Privilege> privileges = new HashSet<Privilege>();
            for (String privName : privListString.split(",")) {
                Privilege priv = new Privilege(privName);
                privileges.add(priv);
            }
            Role role = new Role(roleName, privileges);
            roleByName.put(roleName, role);
        }
    }
}
Also used : Role(org.onebusaway.admin.model.role.Role) UserRole(org.onebusaway.users.model.UserRole) Privilege(org.onebusaway.admin.model.role.Privilege) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) HashSet(java.util.HashSet) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PostConstruct (javax.annotation.PostConstruct)1 Privilege (org.onebusaway.admin.model.role.Privilege)1 Role (org.onebusaway.admin.model.role.Role)1 UserRole (org.onebusaway.users.model.UserRole)1