Class JndiPermission

  • All Implemented Interfaces:
    Serializable, Guard

    public final class JndiPermission
    extends Permission
    Permission to access an object within the "java:" JNDI namespace.

    This permission does not span into bound nested contexts; such contexts may be governed by their own permission scheme.

    The name segment of the permission is a JNDI path whose segments are separated by / characters. The name may be preceded with the string java: for compatibility with previous schemes. A name of <<ALL BINDINGS>> is translated to - for compatibility reasons.

    See Also:
    Serialized Form
    • Field Detail

      • ACTION_BIND

        public static final int ACTION_BIND
        The bitwise encoding of the bind action.
        See Also:
        Constant Field Values
      • ACTION_REBIND

        public static final int ACTION_REBIND
        The bitwise encoding of the rebind action.
        See Also:
        Constant Field Values
      • ACTION_UNBIND

        public static final int ACTION_UNBIND
        The bitwise encoding of the unbind action.
        See Also:
        Constant Field Values
      • ACTION_LOOKUP

        public static final int ACTION_LOOKUP
        The bitwise encoding of the lookup action.
        See Also:
        Constant Field Values
      • ACTION_LIST

        public static final int ACTION_LIST
        The bitwise encoding of the list action.
        See Also:
        Constant Field Values
      • ACTION_LIST_BINDINGS

        public static final int ACTION_LIST_BINDINGS
        The bitwise encoding of the listBindings action.
        See Also:
        Constant Field Values
      • ACTION_CREATE_SUBCONTEXT

        public static final int ACTION_CREATE_SUBCONTEXT
        The bitwise encoding of the createSubcontext action.
        See Also:
        Constant Field Values
      • ACTION_DESTROY_SUBCONTEXT

        public static final int ACTION_DESTROY_SUBCONTEXT
        The bitwise encoding of the destroySubcontext action.
        See Also:
        Constant Field Values
      • ACTION_ADD_NAMING_LISTENER

        public static final int ACTION_ADD_NAMING_LISTENER
        The bitwise encoding of the addNamingListener action.
        See Also:
        Constant Field Values
      • ACTION_ALL

        public static final int ACTION_ALL
        The bitwise encoding of the * action. This value is the bitwise-OR of all of the other action bits.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JndiPermission

        public JndiPermission​(String name,
                              String actions)
        Construct a new instance.
        Parameters:
        name - the path name (must not be null)
        actions - the actions (must not be null)
      • JndiPermission

        public JndiPermission​(String name,
                              int actionBits)
        Construct a new instance using an action bitmask. If a bit in the mask falls outside of ACTION_ALL, it is stripped.
        Parameters:
        name - the path name (must not be null)
        actionBits - the action bits
    • Method Detail

      • implies

        public boolean implies​(Permission permission)
        Determine if this permission implies the other permission.
        Specified by:
        implies in class Permission
        Parameters:
        permission - the other permission
        Returns:
        true if this permission implies the other, false if it does not or permission is null
      • implies

        public boolean implies​(JndiPermission permission)
        Determine if this permission implies the other permission.
        Parameters:
        permission - the other permission
        Returns:
        true if this permission implies the other, false if it does not or permission is null
      • implies

        public boolean implies​(String name,
                               String actions)
        Determine if this permission implies the given actions on the given name.
        Parameters:
        name - the name (must not be null)
        actions - the actions (must not be null)
        Returns:
        true if this permission implies the actions on the name, false otherwise
      • implies

        public boolean implies​(String name,
                               int actionBits)
        Determine if this permission implies the given actionsBits on the given name.
        Parameters:
        name - the name (must not be null)
        actionBits - the action bits
        Returns:
        true if this permission implies the actionBits on the name, false otherwise
      • equals

        public boolean equals​(Object other)
        Determine whether this object is equal to another.
        Specified by:
        equals in class Permission
        Parameters:
        other - the other object
        Returns:
        true if they are equal, false otherwise
      • equals

        public boolean equals​(JndiPermission other)
        Determine whether this object is equal to another.
        Parameters:
        other - the other object
        Returns:
        true if they are equal, false otherwise
      • hashCode

        public int hashCode()
        Get the hash code of this permission.
        Specified by:
        hashCode in class Permission
        Returns:
        the hash code of this permission
      • getActions

        public String getActions()
        Get the actions string. The actions string will be a canonical version of the one passed in at construction.
        Specified by:
        getActions in class Permission
        Returns:
        the actions string (not null)
      • getActionBits

        public int getActionBits()
        Get the action bits.
        Returns:
        the action bits
      • withNewActions

        public JndiPermission withNewActions​(int actionBits)
        Return a permission which is equal to this one except with its actions reset to actionBits. If the given actionBits equals the current bits of this permission, then this permission instance is returned; otherwise a new permission is constructed. Any action bits which fall outside of ACTION_ALL are silently ignored.
        Parameters:
        actionBits - the action bits to use
        Returns:
        a permission with only the given action bits (not null)
      • withNewActions

        public JndiPermission withNewActions​(String actions)
        Return a permission which is equal to this one except with its actions reset to actions. If the given actions equals the current actions of this permission, then this permission instance is returned; otherwise a new permission is constructed.
        Parameters:
        actions - the actions to use (must not be null)
        Returns:
        a permission with only the given action bits (not null)
      • withActions

        public JndiPermission withActions​(int actionBits)
        Return a permission which is equal to this one except with additional action bits. If the given actionBits do not add any new actions, then this permission instance is returned; otherwise a new permission is constructed. Any action bits which fall outside of ACTION_ALL are silently ignored.
        Parameters:
        actionBits - the action bits to add
        Returns:
        a permission with the union of permissions from this instance and the given bits (not null)
      • withActions

        public JndiPermission withActions​(String actions)
        Return a permission which is equal to this one except with additional actions. If the given actionBits do not add any new actions, then this permission instance is returned; otherwise a new permission is constructed.
        Parameters:
        actions - the actions to add (must not be null)
        Returns:
        a permission with the union of permissions from this instance and the given bits (not null)
      • withoutActions

        public JndiPermission withoutActions​(int actionBits)
        Return a permission which is equal to this one except without some action bits. If the given actionBits do not remove any actions, then this permission instance is returned; otherwise a new permission is constructed. Any action bits which fall outside of ACTION_ALL are silently ignored.
        Parameters:
        actionBits - the action bits to remove
        Returns:
        a permission with the given bits subtracted from this instance (not null)
      • withoutActions

        public JndiPermission withoutActions​(String actions)
        Return a permission which is equal to this one except without some actions. If the given actions do not remove any actions, then this permission instance is returned; otherwise a new permission is constructed.
        Parameters:
        actions - the actions to remove (must not be null)
        Returns:
        a permission with the given bits subtracted from this instance (not null)