Interface RegRole

All Superinterfaces:
CatalogObject, CatalogObject.AccessControlled<CatalogObject.Grant.OnRole>, CatalogObject.Addressed<RegRole>, CatalogObject.Named<Lexicals.Identifier.Simple>
All Known Subinterfaces:
RegRole.Grantee

Model of a PostgreSQL role.

In addition to the methods returning the information in the pg_authid system catalog, there are methods to return four different flavors of RolePrincipal, all representing this role.

The ...Principal() methods should not be confused with environment accessors returning actual information about the execution context. Each of the methods simply returns an instance of the corresponding class that would be appropriate to find in the execution context if this role were, respectively, the authenticated, session, outer, or current role.

RolePrincipal.Current implements the UserPrincipal/GroupPrincipal interfaces of java.nio.file.attribute, so currentPrincipal() can also be used to obtain Principals that will work in the Java NIO.2 filesystem API.

The ...Principal methods only succeed when name() does, therefore not when isValid is false. The RegRole.Grantee representing PUBLIC is, for all other purposes, not a valid role, including for its ...Principal methods.

  • Field Details

    • CLASSID

      static final RegClass.Known<RegRole> CLASSID
    • PUBLIC

      static final RegRole.Grantee PUBLIC
      A RegRole.Grantee representing PUBLIC; not a valid RegRole for other purposes.
  • Method Details

    • authenticatedPrincipal

      default RolePrincipal.Authenticated authenticatedPrincipal()
      Return a RolePrincipal that would represent this role as a session's authenticated identity (which was established at connection time and will not change for the life of a session).
    • sessionPrincipal

      default RolePrincipal.Session sessionPrincipal()
      Return a RolePrincipal that would represent this role as a session's "session" identity (which can be changed during a session by SET SESSION AUTHORIZATION).
    • outerPrincipal

      default RolePrincipal.Outer outerPrincipal()
      Return a RolePrincipal that would represent this role as the one last established by SET ROLE, and outside of any SECURITY DEFINER function.
    • currentPrincipal

      default RolePrincipal.Current currentPrincipal()
      Return a RolePrincipal that would represent this role as the effective one for normal privilege checks, usually the same as the session or outer, but changed during SECURITY DEFINER functions.

      This method can also be used to obtain a Principal that will work in the Java NIO.2 filesystem API.

    • memberOf

      List<RegRole> memberOf()
      Roles of which this role is directly a member.

      For the other direction, see grants().

    • superuser

      boolean superuser()
    • inherit

      boolean inherit()
    • createRole

      boolean createRole()
    • createDB

      boolean createDB()
    • canLogIn

      boolean canLogIn()
    • replication

      boolean replication()
    • bypassRLS

      boolean bypassRLS()
    • connectionLimit

      int connectionLimit()