use of com.runwaysdk.business.rbac.SingleActorDAOIF in project geoprism-registry by terraframe.
the class HierarchyTypePermissionService method getPermissions.
public Set<CGRPermissionActionIF> getPermissions(String orgCode) {
if (// null actor is assumed to be SYSTEM
!this.hasSessionUser()) {
return new HashSet<CGRPermissionActionIF>(Arrays.asList(CGRPermissionAction.values()));
}
// final String orgCode = sht.getOrganization().getCode();
HashSet<CGRPermissionActionIF> actions = new HashSet<CGRPermissionActionIF>();
actions.add(CGRPermissionAction.READ);
if (orgCode != null) {
SingleActorDAOIF actor = this.getSessionUser();
Set<RoleDAOIF> roles = actor.authorizedRoles();
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (RegistryRole.Type.isOrgRole(roleName) && !RegistryRole.Type.isRootOrgRole(roleName)) {
String roleOrgCode = RegistryRole.Type.parseOrgCode(roleName);
if (orgCode.equals(roleOrgCode)) {
if (RegistryRole.Type.isRA_Role(roleName)) {
actions.add(CGRPermissionAction.WRITE);
actions.add(CGRPermissionAction.CREATE);
actions.add(CGRPermissionAction.DELETE);
}
}
} else if (RegistryRole.Type.isSRA_Role(roleName)) {
actions.add(CGRPermissionAction.WRITE);
actions.add(CGRPermissionAction.CREATE);
actions.add(CGRPermissionAction.DELETE);
}
}
}
return actions;
}
use of com.runwaysdk.business.rbac.SingleActorDAOIF in project geoprism-registry by terraframe.
the class RolePermissionService method getOrganization.
/**
* If the session user is an org role, this method will return the user's
* organization. Otherwise this method will return null.
*/
public String getOrganization() {
if (this.hasSessionUser()) {
SingleActorDAOIF actor = this.getSessionUser();
Set<RoleDAOIF> roles = actor.authorizedRoles();
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (RegistryRole.Type.isOrgRole(roleName) && !RegistryRole.Type.isRootOrgRole(roleName)) {
String roleOrgCode = RegistryRole.Type.parseOrgCode(roleName);
return roleOrgCode;
}
}
}
return null;
}
use of com.runwaysdk.business.rbac.SingleActorDAOIF in project geoprism-registry by terraframe.
the class RolePermissionService method isRM.
public boolean isRM(String orgCode, ServerGeoObjectType type) {
if (!this.hasSessionUser()) {
return true;
}
SingleActorDAOIF actor = this.getSessionUser();
Set<RoleDAOIF> roles = actor.authorizedRoles();
Set<String> typeCodes = this.getTypeCodes(type);
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (RegistryRole.Type.isRM_Role(roleName)) {
String roleOrgCode = RegistryRole.Type.parseOrgCode(roleName);
String roleGotCode = RegistryRole.Type.parseGotCode(roleName);
if (orgCode != null && type != null && (orgCode.equals(roleOrgCode) && typeCodes.contains(roleGotCode))) {
return true;
} else if (type == null && orgCode != null && orgCode.equals(roleOrgCode)) {
return true;
} else if (type == null && orgCode == null) {
return true;
}
}
}
return false;
}
use of com.runwaysdk.business.rbac.SingleActorDAOIF in project geoprism-registry by terraframe.
the class RolePermissionService method isRC.
public boolean isRC(String orgCode, ServerGeoObjectType type) {
if (!this.hasSessionUser()) {
return true;
}
SingleActorDAOIF actor = this.getSessionUser();
Set<RoleDAOIF> roles = actor.authorizedRoles();
Set<String> typeCodes = this.getTypeCodes(type);
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (RegistryRole.Type.isRC_Role(roleName)) {
String roleOrgCode = RegistryRole.Type.parseOrgCode(roleName);
String roleGotCode = RegistryRole.Type.parseGotCode(roleName);
if (orgCode != null && type != null && (orgCode.equals(roleOrgCode) && typeCodes.contains(roleGotCode))) {
return true;
} else if (type == null && orgCode != null && orgCode.equals(roleOrgCode)) {
return true;
} else if (type == null && orgCode == null) {
return true;
}
}
}
return false;
}
use of com.runwaysdk.business.rbac.SingleActorDAOIF in project geoprism-registry by terraframe.
the class RolePermissionService method isAC.
public boolean isAC(String orgCode, ServerGeoObjectType type) {
if (!this.hasSessionUser()) {
return true;
}
SingleActorDAOIF actor = this.getSessionUser();
Set<RoleDAOIF> roles = actor.authorizedRoles();
Set<String> typeCodes = this.getTypeCodes(type);
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (RegistryRole.Type.isAC_Role(roleName)) {
String roleOrgCode = RegistryRole.Type.parseOrgCode(roleName);
String roleGotCode = RegistryRole.Type.parseGotCode(roleName);
if (orgCode != null && type != null && (orgCode.equals(roleOrgCode) && typeCodes.contains(roleGotCode))) {
return true;
} else if (type == null && orgCode != null && orgCode.equals(roleOrgCode)) {
return true;
} else if (type == null && orgCode == null) {
return true;
}
}
}
return false;
}
Aggregations