Interface ISecurityContext

All Superinterfaces:
ISecurity, ISynchronizableSecuritySystem

public interface ISecurityContext extends ISecurity, ISynchronizableSecuritySystem
The security context is responsible to manage users, roles and sessions.
Since:
17.05.2006
API:
This is a public API.
  • Method Details

    • roles

      Gets the role repository of this security context. Allows to find roles of this security context / application.

      Example:

      IRole manager = ivy.security.roles().find("Manager");
      
      Specified by:
      roles in interface ISecurity
      Returns:
      role repository
      Since:
      9.3
      API:
      This public API is available in Java.
    • users

      Gets the user repository of this security context. Allows to create, delete, find, query users of this security context / application.

      Example:

      IUser user = ivy.security.users().find("Ivy");
      
      Specified by:
      users in interface ISecurity
      Returns:
      user repository
      Since:
      8.0.3
      API:
      This public API is available in Java.
    • sessions

      ISessionRepository sessions()

      Gets the session repository of this security context. Allows to create, destroy, find sessions of this security context / application.

      Example:

      Number sessionCount = ivy.security.sessions().count();
      
      Specified by:
      sessions in interface ISecurity
      Returns:
      session repository
      Since:
      9.3
      API:
      This public API is available in Java.
    • getSystemUser

      IUser getSystemUser()
      API:
      This public API is available in Java.
    • hasPermission

      boolean hasPermission(ISecurityDescriptor securityDescriptor, IPermission permission)
      Checks if the current session has a certain permission on the security descriptor
      Parameters:
      securityDescriptor - the security descriptor to check for the permission
      permission - the identifier of the permission to check
      Returns:
      true if session has permission, otherwise false
      Throws:
      PersistencyException - if persistency access fails
      API:
      This public API is available in Java.
    • checkPermission

      void checkPermission(ISecurityDescriptor securityDescriptor, IPermission permission)
      Checks if the current session has a certain permission on the security descriptor
      Parameters:
      securityDescriptor - the security descriptor to check for the permission
      permission - the permission to check
      Throws:
      PersistencyException - if persistency access fails
      API:
      This public API is available in Java.
    • getCurrentSession

      @Deprecated(forRemoval=true, since="9.3") ISession getCurrentSession()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the current session. Gets the current session associated to the current thread
      Returns:
      current session or null if current thread has no session associated
      API:
      This public API is available in Java.
    • getId

      long getId()
      Gets the identifier of the security context
      Returns:
      identifier
      API:
      This public API is available in Java.
    • executeAs

      <T> T executeAs(Callable<T> callable, ISession executionContext) throws Exception
      Executes the callable in the context of the given execution context
      Type Parameters:
      T - the type of the result
      Parameters:
      callable - the callable
      executionContext - the execution context
      Returns:
      the result of the callable
      Throws:
      Exception - if callable throws an exception
      API:
      This public API is available in Java.
    • current

      static ISecurityContext current()

      Gets the current security context.

      Will return null if called out of scope. The scope is set if you call this method from an ivy process or any supported ivy environment. It is not set in non supported ivy environments (e.g. if you start your own threads, etc.).

      Returns:
      current security context or null if out of scope
      Since:
      9.3
      API:
      This public API is available in Java.