com.netgrif.application.engine.workflow.service.AbstractAuthorizationService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of application-engine Show documentation
Show all versions of application-engine Show documentation
System provides workflow management functions including user, role and data management.
package com.netgrif.application.engine.workflow.service;
import com.netgrif.application.engine.auth.domain.IUser;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public abstract class AbstractAuthorizationService {
protected boolean hasPermission(Boolean hasPermission) {
return hasPermission != null && hasPermission;
}
protected boolean hasRestrictedPermission(Boolean hasPermission) {
return hasPermission != null && !hasPermission;
}
protected Map getAggregatePermissions(IUser user, Map> permissions) {
Map aggregatePermissions = new HashMap<>();
Set userProcessRoleIDs = user.getSelfOrImpersonated().getProcessRoles().stream().map(role -> role.get_id().toString()).collect(Collectors.toSet());
for (Map.Entry> role : permissions.entrySet()) {
aggregatePermission(userProcessRoleIDs, role, aggregatePermissions);
}
return aggregatePermissions;
}
private void aggregatePermission(Set userProcessRoleIDs, Map.Entry> role, Map aggregatePermissions) {
if (userProcessRoleIDs.contains(role.getKey())) {
for (Map.Entry permission : role.getValue().entrySet()) {
if (aggregatePermissions.containsKey(permission.getKey())) {
aggregatePermissions.put(permission.getKey(), aggregatePermissions.get(permission.getKey()) && permission.getValue());
} else {
aggregatePermissions.put(permission.getKey(), permission.getValue());
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy