use of com.runwaysdk.business.rbac.RoleDAO in project geoprism-registry by terraframe.
the class AddWritePermissions method reassignPermissions.
private void reassignPermissions(ServerHierarchyType hierarchyType) {
RoleDAO maintainer = RoleDAO.findRole(RegistryConstants.REGISTRY_MAINTAINER_ROLE).getBusinessDAO();
RoleDAO consumer = RoleDAO.findRole(RegistryConstants.API_CONSUMER_ROLE).getBusinessDAO();
RoleDAO contributor = RoleDAO.findRole(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE).getBusinessDAO();
InitializationStrategyIF strategy = new InitializationStrategyIF() {
@Override
public void preApply(MdBusinessDAO mdBusiness) {
mdBusiness.setValue(MdBusinessInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
}
@Override
public void postApply(MdBusinessDAO mdBusiness) {
RoleDAO adminRole = RoleDAO.findRole(DefaultConfiguration.ADMIN).getBusinessDAO();
adminRole.grantPermission(Operation.READ, mdBusiness.getOid());
adminRole.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.CREATE, mdBusiness.getOid());
adminRole.grantPermission(Operation.DELETE, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.CREATE, mdBusiness.getOid());
maintainer.grantPermission(Operation.DELETE, mdBusiness.getOid());
consumer.grantPermission(Operation.READ, mdBusiness.getOid());
consumer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
contributor.grantPermission(Operation.READ, mdBusiness.getOid());
contributor.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
}
};
String key = GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode() + RegistryConstants.UNIVERSAL_RELATIONSHIP_POST;
if (hierarchyType.getCode().equals("LocatedIn")) {
key = GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode();
}
MdTermRelationship mdTermRelUniversal = MdTermRelationship.getByKey(key);
this.grantWritePermissionsOnMdTermRel(mdTermRelUniversal);
this.grantWritePermissionsOnMdTermRel(maintainer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(consumer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(contributor, mdTermRelUniversal);
Universal.getStrategy().initialize(mdTermRelUniversal.definesType(), strategy);
MdTermRelationship mdTermRelGeoEntity = MdTermRelationship.getByKey(GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode());
this.grantWritePermissionsOnMdTermRel(mdTermRelGeoEntity);
this.grantWritePermissionsOnMdTermRel(maintainer, mdTermRelGeoEntity);
this.grantReadPermissionsOnMdTermRel(consumer, mdTermRelGeoEntity);
this.grantReadPermissionsOnMdTermRel(contributor, mdTermRelGeoEntity);
MdEdgeDAO mdEdge = (MdEdgeDAO) MdEdgeDAO.getMdEdgeDAO(RegistryConstants.UNIVERSAL_GRAPH_PACKAGE + "." + hierarchyType.getCode());
this.grantWritePermissionsOnMdTermRel(mdEdge);
this.grantWritePermissionsOnMdTermRel(maintainer, mdEdge);
this.grantReadPermissionsOnMdTermRel(consumer, mdEdge);
this.grantReadPermissionsOnMdTermRel(contributor, mdEdge);
logger.info("Updated permissions for HierarchyType [" + hierarchyType.getCode() + "]. ");
}
use of com.runwaysdk.business.rbac.RoleDAO in project geoprism-registry by terraframe.
the class AddWritePermissions method grantWritePermissionsOnMdTermRel.
private void grantWritePermissionsOnMdTermRel(ComponentIF mdTermRelationship) {
RoleDAO adminRole = RoleDAO.findRole(DefaultConfiguration.ADMIN).getBusinessDAO();
grantWritePermissionsOnMdTermRel(adminRole, mdTermRelationship);
}
use of com.runwaysdk.business.rbac.RoleDAO in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method assign_RC_GeoObjectTypeRole.
private void assign_RC_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, MdBusiness mdBusiness, String organizationCode, String geoObjectTypeCode) {
if (organizationCode != null && !organizationCode.trim().equals("")) {
String rmRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
RoleDAO rmRole = RoleDAO.findRole(rmRoleName).getBusinessDAO();
rmRole.grantPermission(Operation.READ, mdGeoVertexDAO.getOid());
rmRole.grantPermission(Operation.READ_ALL, mdGeoVertexDAO.getOid());
rmRole.grantPermission(Operation.READ, mdBusiness.getOid());
rmRole.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
}
}
use of com.runwaysdk.business.rbac.RoleDAO in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method create_RM_GeoObjectTypeRole.
private void create_RM_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
if (organizationCode != null && !organizationCode.trim().equals("")) {
String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
Locale locale = Session.getCurrentLocale();
String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " Registry Maintainer";
Roles rmOrgRole = new Roles();
rmOrgRole.setRoleName(rmRoleName);
rmOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
rmOrgRole.apply();
String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
Roles orgRole = Roles.findRoleByName(orgRoleName);
RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
RoleDAO rmOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(rmOrgRole);
orgRoleDAO.addInheritance(rmOrgRoleDAO);
// Inherit the permissions from the root RM role
RoleDAO rootRM_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.REGISTRY_MAINTAINER_ROLE));
rootRM_DAO.addInheritance(rmOrgRoleDAO);
}
}
use of com.runwaysdk.business.rbac.RoleDAO in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method assignAllPermissions.
/**
* Assigns all permissions to the {@link ComponentIF} to the given role.
*
* Precondition: component is either a {@link MdGeoVertex} or a
* {@link MdBusiness}.
*
* @param component
* @param role
*/
private void assignAllPermissions(ComponentIF component, Roles role) {
RoleDAO roleDAO = (RoleDAO) BusinessFacade.getEntityDAO(role);
roleDAO.grantPermission(Operation.CREATE, component.getOid());
roleDAO.grantPermission(Operation.DELETE, component.getOid());
roleDAO.grantPermission(Operation.WRITE, component.getOid());
roleDAO.grantPermission(Operation.WRITE_ALL, component.getOid());
}
Aggregations