Class VacmMIB

java.lang.Object
org.snmp4j.agent.mo.snmp.VacmMIB
All Implemented Interfaces:
MOGroup, MutableVACM, VACM

public class VacmMIB extends Object implements MOGroup, MutableVACM
This concrete implementation of the SNMP-VIEW-BASED-ACM-MIB (RFC 3415). The configuration of the view access model can be changed programmatically (see MutableVACM) or via SNMP but an initial configuration must be created programmatically in order to allow any access to the agent via SNMP.
Version:
3.5
Author:
Frank Fock
  • Field Details

    • vacmContextEntryOID

      public static final org.snmp4j.smi.OID vacmContextEntryOID
    • colVacmGroupName

      public static final int colVacmGroupName
      See Also:
    • colVacmSecurityToGroupStorageType

      public static final int colVacmSecurityToGroupStorageType
      See Also:
    • colVacmSecurityToGroupRowStatus

      public static final int colVacmSecurityToGroupRowStatus
      See Also:
    • idxVacmGroupName

      public static final int idxVacmGroupName
      See Also:
    • idxVacmSecurityToGroupStorageType

      public static final int idxVacmSecurityToGroupStorageType
      See Also:
    • idxVacmSecurityToGroupRowStatus

      public static final int idxVacmSecurityToGroupRowStatus
      See Also:
    • vacmSecurityToGroupEntryOID

      public static final org.snmp4j.smi.OID vacmSecurityToGroupEntryOID
    • colVacmAccessContextMatch

      public static final int colVacmAccessContextMatch
      See Also:
    • colVacmAccessReadViewName

      public static final int colVacmAccessReadViewName
      See Also:
    • colVacmAccessWriteViewName

      public static final int colVacmAccessWriteViewName
      See Also:
    • colVacmAccessNotifyViewName

      public static final int colVacmAccessNotifyViewName
      See Also:
    • colVacmAccessStorageType

      public static final int colVacmAccessStorageType
      See Also:
    • colVacmAccessRowStatus

      public static final int colVacmAccessRowStatus
      See Also:
    • idxVacmAccessContextPrefix

      public static final int idxVacmAccessContextPrefix
      See Also:
    • idxVacmAccessSecurityModel

      public static final int idxVacmAccessSecurityModel
      See Also:
    • idxVacmAccessSecurityLevel

      public static final int idxVacmAccessSecurityLevel
      See Also:
    • idxVacmAccessContextMatch

      public static final int idxVacmAccessContextMatch
      See Also:
    • idxVacmAccessReadViewName

      public static final int idxVacmAccessReadViewName
      See Also:
    • idxVacmAccessWriteViewName

      public static final int idxVacmAccessWriteViewName
      See Also:
    • idxVacmAccessNotifyViewName

      public static final int idxVacmAccessNotifyViewName
      See Also:
    • idxVacmAccessStorageType

      public static final int idxVacmAccessStorageType
      See Also:
    • idxVacmAccessRowStatus

      public static final int idxVacmAccessRowStatus
      See Also:
    • vacmAccessEntryOID

      public static final org.snmp4j.smi.OID vacmAccessEntryOID
    • vacmExactMatch

      public static final int vacmExactMatch
      See Also:
    • vacmPrefixMatch

      public static final int vacmPrefixMatch
      See Also:
    • vacmViewSpinLockOID

      public static final org.snmp4j.smi.OID vacmViewSpinLockOID
    • colVacmViewTreeFamilyMask

      public static final int colVacmViewTreeFamilyMask
      See Also:
    • colVacmViewTreeFamilyType

      public static final int colVacmViewTreeFamilyType
      See Also:
    • colVacmViewTreeFamilyStorageType

      public static final int colVacmViewTreeFamilyStorageType
      See Also:
    • colVacmViewTreeFamilyRowStatus

      public static final int colVacmViewTreeFamilyRowStatus
      See Also:
    • idxVacmViewTreeSubtree

      public static final int idxVacmViewTreeSubtree
      See Also:
    • idxVacmViewTreeFamilyMask

      public static final int idxVacmViewTreeFamilyMask
      See Also:
    • idxVacmViewTreeFamilyType

      public static final int idxVacmViewTreeFamilyType
      See Also:
    • idxVacmViewTreeFamilyStorageType

      public static final int idxVacmViewTreeFamilyStorageType
      See Also:
    • idxVacmViewTreeFamilyRowStatus

      public static final int idxVacmViewTreeFamilyRowStatus
      See Also:
    • vacmViewTreeFamilyEntryOID

      public static final org.snmp4j.smi.OID vacmViewTreeFamilyEntryOID
    • vacmViewIncluded

      public static final int vacmViewIncluded
      See Also:
    • vacmViewExcluded

      public static final int vacmViewExcluded
      See Also:
  • Constructor Details

    • VacmMIB

      public VacmMIB(MOServer[] server)
    • VacmMIB

      public VacmMIB(MOServer[] server, org.snmp4j.security.SecurityModels securityModels)
  • Method Details

    • registerMOs

      public void registerMOs(MOServer server, org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException
      Description copied from interface: MOGroup
      Registers the managed objects of this group with the server for the supplied context.
      Specified by:
      registerMOs in interface MOGroup
      Parameters:
      server - the MOServer where to register the managed objects.
      context - the context to use (may be null if no specific context is selected).
      Throws:
      DuplicateRegistrationException - if a managed object's scope (i.e. lower bound) is already registered at the server.
    • unregisterMOs

      public void unregisterMOs(MOServer server, org.snmp4j.smi.OctetString context)
      Description copied from interface: MOGroup
      Unregisters the managed objects of this group from the supplied server and from the supplied context.
      Specified by:
      unregisterMOs in interface MOGroup
      Parameters:
      server - the MOServer where to unregister the managed objects.
      context - the context to use (may be null if no specific context is selected).
    • isAccessAllowed

      public int isAccessAllowed(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OctetString securityName, int securityModel, int securityLevel, int viewType, org.snmp4j.smi.OID oid)
      Description copied from interface: VACM
      Checks whether access is allowed in the specified context for the security name, model, level, and view type for the supplied OID.
      Specified by:
      isAccessAllowed in interface VACM
      Parameters:
      context - the context for which access is requested.
      securityName - the security name.
      securityModel - the security model, see SecurityModel for possible values.
      securityLevel - the security level, see SecurityLevel for possible values.
      viewType - the requested view type, possible values are VACM.VIEW_NOTIFY, VACM.VIEW_READ, and VACM.VIEW_WRITE.
      oid - the OID of the object instance for which access is requested.
      Returns:
      VACM.VACM_OK if access is granted or one of the VACM errors defined by this interface if access is rejected.
    • getViewName

      public org.snmp4j.smi.OctetString getViewName(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OctetString securityName, int securityModel, int securityLevel, int viewType)
      Description copied from interface: VACM
      Gets the view name of the view defined by the supplied credentials.
      Specified by:
      getViewName in interface VACM
      Parameters:
      context - the context for which access is requested.
      securityName - the security name.
      securityModel - the security model, see SecurityModel for possible values.
      securityLevel - the security level, see SecurityLevel for possible values.
      viewType - the requested view type, possible values are VACM.VIEW_NOTIFY, VACM.VIEW_READ, and VACM.VIEW_WRITE.
      Returns:
      the view name if the credentials can be mapped to an existing view. Otherwise, if no such view exists then null is returned.
    • hasContext

      public boolean hasContext(org.snmp4j.smi.OctetString contextName)
      Description copied from interface: VACM
      Test if the provided context is known by this VACM or not. This method can be used to early check if a context is in general supported or not, i.e., to increase SnmpTargetMIB.snmpUnknownContexts.
      Specified by:
      hasContext in interface VACM
      Parameters:
      contextName - a SNMPv3 context name.
      Returns:
      true if the vacmContextTable contains an entry for this context name, false otherwise. By default true is returned, if this method is not implemented yet to use VacmMIB to check the provided context.
    • isAccessAllowed

      public int isAccessAllowed(org.snmp4j.smi.OctetString viewName, org.snmp4j.smi.OID oid)
      Description copied from interface: VACM
      Checks if access is allowed for the given OID within the specified view.
      Specified by:
      isAccessAllowed in interface VACM
      Parameters:
      viewName - the name of an existing view, i.e. that has bee retrieved by VACM.getViewName(org.snmp4j.smi.OctetString, org.snmp4j.smi.OctetString, int, int, int) before.
      oid - the OID of the object instance for which access is requested.
      Returns:
      VACM.VACM_OK if access is granted or one of the VACM errors defined by this interface if access is rejected.
    • addGroup

      public void addGroup(int securityModel, org.snmp4j.smi.OctetString securityName, org.snmp4j.smi.OctetString groupName, int storageType)
      Adds a security model and name to group name mapping to this VACM. Any already existing mapping for the security name and model will be silently replaced.
      Specified by:
      addGroup in interface MutableVACM
      Parameters:
      securityModel - the security model.
      securityName - the security name.
      groupName - the group name.
      storageType - the storage type for the new entry.
    • removeGroup

      public boolean removeGroup(int securityModel, org.snmp4j.smi.OctetString securityName)
      Removes a security model and name to group name mapping from this VACM.
      Specified by:
      removeGroup in interface MutableVACM
      Parameters:
      securityModel - the security model.
      securityName - the security name.
      Returns:
      true when the entry has been removed or false if such a mapping could not be found.
    • hasSecurityToGroupMapping

      public boolean hasSecurityToGroupMapping(int securityModel, org.snmp4j.smi.OctetString securityName)
      Description copied from interface: MutableVACM
      Check if there is a security mapping for the specified security model and security name.
      Specified by:
      hasSecurityToGroupMapping in interface MutableVACM
      Parameters:
      securityModel - the security model the mapping is based on, see SecurityModel for possible values.
      securityName - a security name.
      Returns:
      true if there is a mapping and false otherwise.
    • addAccess

      public void addAccess(org.snmp4j.smi.OctetString groupName, org.snmp4j.smi.OctetString contextPrefix, int securityModel, int securityLevel, int match, org.snmp4j.smi.OctetString readView, org.snmp4j.smi.OctetString writeView, org.snmp4j.smi.OctetString notifyView, int storageType)
      Adds an access entry to this VACM and thus adds access rights for a group.
      Specified by:
      addAccess in interface MutableVACM
      Parameters:
      groupName - the group for which access rights are to be added.
      contextPrefix - the context or context prefix.
      securityModel - the security model
      securityLevel - the security level
      match - indicates whether exact context match (vacmExactMatch) or prefix context match (vacmPrefixMatch) should be used by the new entry.
      readView - the view name for read access (use a zero length OctetString to disable access).
      writeView - the view name for write access (use a zero length OctetString to disable access).
      notifyView - the view name for notify access (use a zero length OctetString to disable access).
      storageType - the StorageType for this access entry.
    • removeAccess

      public boolean removeAccess(org.snmp4j.smi.OctetString groupName, org.snmp4j.smi.OctetString contextPrefix, int securityModel, int securityLevel)
      Removes an access entry from this VACM.
      Specified by:
      removeAccess in interface MutableVACM
      Parameters:
      groupName - the group for which access rights are to be added.
      contextPrefix - the context or context prefix.
      securityModel - the security model
      securityLevel - the security level
      Returns:
      true when the entry has been removed or false if no such entry could be found.
    • accessEntryCount

      public int accessEntryCount(org.snmp4j.smi.OctetString groupName)
      Description copied from interface: MutableVACM
      Counts the number of access entries for the provided group name.
      Specified by:
      accessEntryCount in interface MutableVACM
      Parameters:
      groupName - the group name for which access entries should be counted.
      Returns:
      the number of group to view(s) access entries.
    • addViewTreeFamily

      public void addViewTreeFamily(org.snmp4j.smi.OctetString viewName, org.snmp4j.smi.OID subtree, org.snmp4j.smi.OctetString mask, int type, int storageType)
      Adds a new view to this VACM. An already existing entry with the same view name and subtree OID will be replaced silently.
      Specified by:
      addViewTreeFamily in interface MutableVACM
      Parameters:
      viewName - the view name.
      subtree - the subtree OID.
      mask - the bit mask which, in combination with subtree, defines a family of view subtrees.
      type - indicates whether the view defined by subtree and mask is included (vacmViewIncluded) or excluded (@link #vacmViewExcluded}) from the MIB view.
      storageType - the StorageType for this access entry.
    • removeViewTreeFamily

      public boolean removeViewTreeFamily(org.snmp4j.smi.OctetString viewName, org.snmp4j.smi.OID subtree)
      Removes a view tree family from this VACM.
      Specified by:
      removeViewTreeFamily in interface MutableVACM
      Parameters:
      viewName - the view name.
      subtree - the subtree OID.
      Returns:
      true when the entry has been removed or false if no such entry could be found.
    • viewTreeFamilyEntryCount

      public int viewTreeFamilyEntryCount(org.snmp4j.smi.OctetString viewName)
      Description copied from interface: MutableVACM
      Counts the number of view name to tree family mapping entries in this VACM.
      Specified by:
      viewTreeFamilyEntryCount in interface MutableVACM
      Parameters:
      viewName - a VACM view name.
      Returns:
      the number of view tree family entries for this view name.
    • isBitSet

      public static boolean isBitSet(int n, org.snmp4j.smi.OctetString os)
      Checks whether bit n of the supplied OctetString is set or not.
      Parameters:
      n - denotes the bit to check starting from zero.
      os - OctetString
      Returns:
      boolean
    • getViews

      protected List<MOTableRow> getViews(org.snmp4j.smi.OctetString viewName)
    • getVacmSecurityToGroupTable