All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ebiznext.comet.schema.model.RowLevelSecurity.scala Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package com.ebiznext.comet.schema.model

/** User / Group and Service accounts rights on a subset of the table.
  * @param name : This Row Level Security unique name
  * @param predicate : The condition that goes to the WHERE clause and limitt the visible rows.
  * @param grants : user / groups / service accounts to which this security level is applied.
  *               ex : user:[email protected],group:[email protected],serviceAccount:[email protected]
  */
case class RowLevelSecurity(
  name: String,
  predicate: String = "TRUE",
  grants: Set[String]
) {

  def grantees(): Set[(UserType, String)] = {
    grants.map { user =>
      val res = user.split(':')
      assert(res.length == 2)
      (UserType.fromString(res(0).trim), res(1).trim)
    }

  }
}

object RowLevelSecurity {

  def parse(input: String): RowLevelSecurity = {
    val components = input.split('/')
    assert(components.length >= 3)
    val name = components(0)
    val filter = components(1)
    val users = components.drop(2)
    RowLevelSecurity(name, filter, users.toSet)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy