Search in sources :

Example 1 with JcrConnector

use of com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnector in project kylo by Teradata.

the class AccessControlConfigurator method ensureCatalogAccessControl.

/**
 * Ensures that the entity-level access control is setup up for the entities introduced by the connector architecture.
 */
public void ensureCatalogAccessControl() {
    List<Connector> connectors = connectorProvider.findAll(true);
    List<SecurityRole> conntorRoles = this.roleProvider.getEntityRoles(SecurityRole.CONNECTOR);
    Optional<AllowedActions> connectorActions = this.actionsProvider.getAvailableActions(AllowedActions.CONNECTOR);
    connectors.stream().forEach(conn -> {
        Principal owner = conn.getOwner() != null ? conn.getOwner() : JcrMetadataAccess.getActiveUser();
        connectorActions.ifPresent(actions -> ((JcrConnector) conn).enableAccessControl((JcrAllowedActions) actions, owner, conntorRoles));
    });
    List<DataSource> dataSources = dataSourceProvider.findAll();
    List<SecurityRole> dataSourceRoles = this.roleProvider.getEntityRoles(SecurityRole.DATASOURCE);
    Optional<AllowedActions> dataSourceActions = this.actionsProvider.getAvailableActions(AllowedActions.DATASOURCE);
    dataSources.stream().map(JcrDataSource.class::cast).forEach(dataSource -> {
        Principal owner = dataSource.getOwner() != null ? dataSource.getOwner() : JcrMetadataAccess.getActiveUser();
        dataSourceActions.ifPresent(actions -> dataSource.enableAccessControl((JcrAllowedActions) actions, owner, dataSourceRoles));
    });
}
Also used : JcrConnector(com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnector) Connector(com.thinkbiganalytics.metadata.api.catalog.Connector) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Principal(java.security.Principal) JcrDataSource(com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSource) DataSource(com.thinkbiganalytics.metadata.api.catalog.DataSource)

Aggregations

Connector (com.thinkbiganalytics.metadata.api.catalog.Connector)1 DataSource (com.thinkbiganalytics.metadata.api.catalog.DataSource)1 JcrConnector (com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnector)1 JcrDataSource (com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSource)1 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)1 AllowedActions (com.thinkbiganalytics.security.action.AllowedActions)1 SecurityRole (com.thinkbiganalytics.security.role.SecurityRole)1 Principal (java.security.Principal)1