Interface CustomRestrictionPolicyContext


public interface CustomRestrictionPolicyContext
The CustomRestrictionPolicyContext interface provides access to information about the running query and the corresponding custom policy. The following information is available:
  • Running query
  • Fields of the view or stored procedure involved in the query
  • Fields types of the view or stored procedure involved in the query
  • User who executes the query and his roles
  • User agent who executes the query
  • Database where the query is executed
  • User or role who is assigned the custom policy to
  • View or stored procedure which is assigned the custom policy to
  • Platform properties in the context of the query
  • User-defined variables in the context of the query

The CustomRestrictionPolicyContext interface also provides a JMX connection to query VDP Server MBeans and logging capabilities.

  • Field Details

    • CACHE_INVALIDATE_PROPERTY

      static final String CACHE_INVALIDATE_PROPERTY
      Platform property which indicates whether the cache is invalidated. This property can take the following values: true, false.
      See Also:
    • CACHE_PRELOAD_PROPERTY

      static final String CACHE_PRELOAD_PROPERTY
      Platform property which indicates whether the results of this query is used to populate the cache of the executing view. This property can take the following values: true, false.
      See Also:
    • DELEGATE_UNNAMED_VIEWS_PROPERTY

      static final String DELEGATE_UNNAMED_VIEWS_PROPERTY
      Platform property which indicates whether unnamed views should be delegated. By default, unnamed views are delegated if possible unless they have a subview with cache enabled. This property can take the following values: yes, no.
      See Also:
    • I18N_PROPERTY

      static final String I18N_PROPERTY
      Platform property which defines the internationalization configuration that will be used for the results of the query. This property takes the name of a valid internationalization configuration as a value (e.g. es_euro ).
      See Also:
    • QUERY_LIMIT_PROPERTY

      static final String QUERY_LIMIT_PROPERTY
      Platform property which defines a limit on the number of rows obtained from the result set. This property takes a positive integer as a value.
      See Also:
    • FORCE_STRICT_QUERY_LIMIT_PROPERTY

      static final String FORCE_STRICT_QUERY_LIMIT_PROPERTY
      Platform property which forces a limit on the number of rows obtained even if there is an offset clause
      See Also:
    • QUERY_TIMEOUT_PROPERTY

      static final String QUERY_TIMEOUT_PROPERTY
      Platform property which defines the maximum time (in milliseconds) the client is prepared to wait for the statement to complete. This property takes a positive long integer as a value.
      See Also:
    • SWAP_PROPERTY

      static final String SWAP_PROPERTY
      Platform property which indicates whether swapping is enabled for the query. This property can take the following values: on, off.
      See Also:
    • SWAP_SIZE_PROPERTY

      static final String SWAP_SIZE_PROPERTY
      Platform property which defines the maximum size (in megabytes) an intermediate result obtained by running this query can reach without swapping to disk. This property takes a positive integer as a value.
      See Also:
    • USER_NAME_PROPERTY

      static final String USER_NAME_PROPERTY
      Platform property which indicates the user name used to query the view instead of the one you have used to connect to the VDP Server. This property is only taken into account when the data source has been created with the clause WITH PASS-THROUGH SESSION CREDENTIALS. This property takes a valid user name for the data source as a value.
      See Also:
    • USER_AGENT_PROPERTY

      static final String USER_AGENT_PROPERTY
      Platform property which indicates the user agent used to query the view.
      See Also:
    • MEMORY_LIMIT_PROPERTY

      static final String MEMORY_LIMIT_PROPERTY
      Platform property which defines a limit on the memory usage of the query in megabytes. This property takes a positive integer as a value or zero to set no limit.
      See Also:
  • Method Details

    • getCurrentUserName

      String getCurrentUserName()
      Returns the name of the user who executes the query
      Returns:
      the name of the user who executes the query
    • getCurrentUserAgent

      String getCurrentUserAgent()
      Returns the user agent who executes the query
      Returns:
      the user agent who executes the query
    • getAdditionalAuthenticationInformation

      Map<String,Object> getAdditionalAuthenticationInformation()
      Returns a map with extra authentication information, if it was provided by the authentication mechanism or an empty map if no information was provided.
      For each entry of the map:
      • The key is a String that represents the name of the attribute.
      • The value(which can be NULL) is an Object value that can encapsulate one of the following types:
        • Boolean
        • String
        • Number
        • List<Object>
        • Map<String, Object>
      Returns:
      a Map<String, Object> which encapsulates authentication attributes.
    • getCurrentUserRoles

      Set<String> getCurrentUserRoles()
      Returns the names of all the roles assigned to the user who executes the query. The roles assigned to the roles directly assigned to the user are also included.
      Returns:
      the names of all the roles assigned to the user who executes the query
    • getCurrentDatabaseName

      String getCurrentDatabaseName()
      Returns the name of the database to which the client application is connected.

      This can be different from the database of the queried view. For example, if the client application establishes the connection with the database admin but executes the query SELECT * FROM customer360.customer, this method will return admin, not customer360.

      Returns:
      the name of the database to which the client application is connected
    • getElementDatabase

      String getElementDatabase()
      Returns the name of the database of the element to which the policy is assigned.
      Returns:
      the name of the database of the element to which the policy is assigned
    • getPolicyCredentialsName

      String getPolicyCredentialsName()
      Returns the name of the credential which is assigned the custom policy to
      Returns:
      the name of the credential which is assigned the custom policy to
    • getPolicyCredentialsType

      Returns the type of the credential which is assigned the custom policy to
      Returns:
      the type of the credential which is assigned the custom policy to
    • getElementName

      String getElementName()
      Returns the name of the element which is assigned the custom policy to
      Returns:
      the name of the element which is assigned the custom policy to
    • getElementType

      Returns the type of the element which is assigned the custom policy to
      Returns:
      the type of the element which is assigned the custom policy to
    • getQuery

      String getQuery()
      Returns the running query
      Returns:
      the running query
    • getFieldsInQuery

      Set<String> getFieldsInQuery()
      Returns the set of fields in the view or stored procedure involved in the query.
      Returns:
      the set of fields in the view or stored procedure involved in the query.
    • getFieldTypeNames

      Map<String,String> getFieldTypeNames()
      Returns a map with the name of the type for each field from the element.
      Returns:
      a map with the name of the type for each field from the element.
    • getJmxConnection

      JmxConnection getJmxConnection()
      Returns a JMX connection to query VDP Server MBeans
      Returns:
      a JMX connection to query VDP Server MBeans
    • getProperty

      String getProperty(String name)
      Returns a textual representation of the value of a platform property present in the context of the query.
      Parameters:
      name - the name of the platform property. The following properties are supported:
      Returns:
      a textual representation of the value of a platform property present in the context of the query or null if the property is not present
      Throws:
      IllegalArgumentException - if name is not a supported property name
    • setProperty

      void setProperty(String name, String value)
      Sets the value of a platform property that is used in the context of the query.
      Parameters:
      name - the name of the platform property. The following properties are supported:
      value - a textual representation of the value of the platform property
      Throws:
      IllegalArgumentException - if name is not a supported property name
      IllegalArgumentException - if value is not a valid value for the property
    • getVariable

      String getVariable(String name)
      Returns a textual representation of the value of a user-defined variable that is present in the context of the query.
      Parameters:
      name - the name of the user-defined variable.
      Returns:
      a textual representation of the value of a user-defined variable in the context of the query or null if the variable is not present
    • setVariable

      void setVariable(String name, String value)
      Sets the value of a user-defined variable in the context of the query.
      Parameters:
      name - the name of the user-defined variable
      value - a textual representation of the value of the user-defined variable
    • isIncompatibleWithQuery

      boolean isIncompatibleWithQuery(String condition) throws ConditionEvaluationException
      Checks if the given condition is incompatible with the condition specified on a query over the view affected by this policy
      Parameters:
      condition - condition to check
      Returns:
      true if the given condition is incompatible with the condition specified on a query over the view affected by this policy
      false otherwise
      Throws:
      ConditionEvaluationException - if the condition is invalid. For example, it is syntactically incorrect.
    • log

      void log(CustomRestrictionPolicyContext.LogLevel level, String logMessage)
      Registers an event in the log of the VDP Server with the specified level.
      Parameters:
      level - the severity level of the event
      logMessage - the message to be logged
    • isLogLevelEnabled

      boolean isLogLevelEnabled(CustomRestrictionPolicyContext.LogLevel level)
      Checks if the specified level is enabled.
      Parameters:
      level - the log level to check
      Returns:
      boolean - true if the specified level is enabled, false otherwise.
    • getElementTags

      Collection<String> getElementTags()
      Returns a collection with the assigned tags to the element.
      Returns:
      a collection with the assigned tags to the element.
    • getFieldsTags

      Map<String, Collection<String>> getFieldsTags()
      Returns a map with the assigned tags to the fields from the element.
      Returns:
      a map with the assigned tags to the fields from the element.
    • getDatabaseEnvironment

      DatabaseEnvironment getDatabaseEnvironment()
      Return the implementation of the interface which defines utility methods accessible from the policy, and used to communicate with the VDP server.
      Returns:
      the implementation of the interface which defines utility methods accessible from the policy, and used to communicate with the VDP server.