use of com.facebook.presto.spi.security.ConnectorIdentity in project presto by prestodb.
the class IcebergResourceFactory method getCatalogCacheKey.
private String getCatalogCacheKey(ConnectorSession session) {
StringBuilder sb = new StringBuilder();
ConnectorIdentity identity = session.getIdentity();
sb.append("User:");
sb.append(identity.getUser());
if (identity.getPrincipal().isPresent()) {
sb.append(",Principle:");
sb.append(identity.getPrincipal().toString());
}
if (identity.getRole().isPresent()) {
sb.append(",Role:");
sb.append(identity.getRole());
}
if (identity.getExtraCredentials() != null) {
identity.getExtraCredentials().forEach((key, value) -> {
sb.append(",");
sb.append(key);
sb.append(":");
sb.append(value);
});
}
return sb.toString();
}
use of com.facebook.presto.spi.security.ConnectorIdentity in project presto by prestodb.
the class SystemConnectorSessionUtil method toSession.
// this does not preserve any connector properties (for the system connector)
public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session) {
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
ConnectorIdentity connectorIdentity = session.getIdentity();
Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal());
return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES)).setQueryId(new QueryId(session.getQueryId())).setTransactionId(transactionId).setCatalog("catalog").setSchema("schema").setIdentity(identity).setTimeZoneKey(session.getSqlFunctionProperties().getTimeZoneKey()).setLocale(session.getLocale()).setStartTime(session.getStartTime()).build();
}
use of com.facebook.presto.spi.security.ConnectorIdentity in project presto by prestodb.
the class ThriftMetastoreUtil method listApplicableTablePrivileges.
public static Stream<HivePrivilegeInfo> listApplicableTablePrivileges(SemiTransactionalHiveMetastore metastore, ConnectorIdentity identity, MetastoreContext metastoreContext, String databaseName, String tableName, String user) {
PrestoPrincipal userPrincipal = new PrestoPrincipal(USER, user);
Stream<PrestoPrincipal> principals = Stream.concat(Stream.of(userPrincipal), listApplicableRoles(metastore, identity, userPrincipal, metastoreContext).map(role -> new PrestoPrincipal(ROLE, role)));
return listTablePrivileges(identity, metastoreContext, metastore, databaseName, tableName, principals);
}
Aggregations