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));
});
}
Aggregations