Search in sources :

Example 6 with RoleDAO

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() + "]. ");
}
Also used : RoleDAO(com.runwaysdk.business.rbac.RoleDAO) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) InitializationStrategyIF(com.runwaysdk.business.ontology.InitializationStrategyIF) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) MdTermRelationship(com.runwaysdk.system.metadata.MdTermRelationship)

Example 7 with RoleDAO

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);
}
Also used : RoleDAO(com.runwaysdk.business.rbac.RoleDAO)

Example 8 with RoleDAO

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());
    }
}
Also used : RoleDAO(com.runwaysdk.business.rbac.RoleDAO)

Example 9 with RoleDAO

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);
    }
}
Also used : Locale(java.util.Locale) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) Roles(com.runwaysdk.system.Roles)

Example 10 with RoleDAO

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());
}
Also used : RoleDAO(com.runwaysdk.business.rbac.RoleDAO)

Aggregations

RoleDAO (com.runwaysdk.business.rbac.RoleDAO)20 Roles (com.runwaysdk.system.Roles)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)5 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)3 Locale (java.util.Locale)3 InitializationStrategyIF (com.runwaysdk.business.ontology.InitializationStrategyIF)2 AttributeValueException (com.runwaysdk.dataaccess.attributes.AttributeValueException)2 MdAttributeDateTimeDAO (com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO)2 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)2 MdTermRelationship (com.runwaysdk.system.metadata.MdTermRelationship)2 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)2 ComponentIF (com.runwaysdk.ComponentIF)1 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)1 UserDAOIF (com.runwaysdk.business.rbac.UserDAOIF)1 MdAttributeCharacterDAO (com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO)1 MdAttributeGraphReferenceDAO (com.runwaysdk.dataaccess.metadata.MdAttributeGraphReferenceDAO)1 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)1 QueryFactory (com.runwaysdk.query.QueryFactory)1