org.snmp4j.agent.mo.snmp
Class VacmMIB

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

public class VacmMIB
extends java.lang.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 programatically (see MutableVACM) or via SNMP but an initial configuration must be created programatically in order to allow any access to the agent via SNMP.

Version:
1.0
Author:
Frank Fock

Nested Class Summary
static class VacmMIB.VacmContextIterator
           
 
Field Summary
static int colVacmAccessContextMatch
           
static int colVacmAccessNotifyViewName
           
static int colVacmAccessReadViewName
           
static int colVacmAccessRowStatus
           
static int colVacmAccessStorageType
           
static int colVacmAccessWriteViewName
           
static int colVacmGroupName
           
static int colVacmSecurityToGroupRowStatus
           
static int colVacmSecurityToGroupStorageType
           
static int colVacmViewTreeFamilyMask
           
static int colVacmViewTreeFamilyRowStatus
           
static int colVacmViewTreeFamilyStorageType
           
static int colVacmViewTreeFamilyType
           
static int idxVacmAccessContextMatch
           
static int idxVacmAccessContextPrefix
           
static int idxVacmAccessNotifyViewName
           
static int idxVacmAccessReadViewName
           
static int idxVacmAccessRowStatus
           
static int idxVacmAccessSecurityLevel
           
static int idxVacmAccessSecurityModel
           
static int idxVacmAccessStorageType
           
static int idxVacmAccessWriteViewName
           
static int idxVacmGroupName
           
static int idxVacmSecurityToGroupRowStatus
           
static int idxVacmSecurityToGroupStorageType
           
static int idxVacmViewTreeFamilyMask
           
static int idxVacmViewTreeFamilyRowStatus
           
static int idxVacmViewTreeFamilyStorageType
           
static int idxVacmViewTreeFamilyType
           
static int idxVacmViewTreeSubtree
           
static org.snmp4j.smi.OID vacmAccessEntryOID
           
static org.snmp4j.smi.OID vacmContextEntryOID
           
static int vacmExactMatch
           
static int vacmPrefixMatch
           
static org.snmp4j.smi.OID vacmSecurityToGroupEntryOID
           
static int vacmViewExcluded
           
static int vacmViewIncluded
           
static org.snmp4j.smi.OID vacmViewSpinLockOID
           
static org.snmp4j.smi.OID vacmViewTreeFamilyEntryOID
           
 
Fields inherited from interface org.snmp4j.agent.security.MutableVACM
VACM_MATCH_EXACT, VACM_MATCH_PREFIX, VACM_VIEW_EXCLUDED, VACM_VIEW_INCLUDED
 
Fields inherited from interface org.snmp4j.agent.security.VACM
VACM_NO_ACCESS_ENTRY, VACM_NO_GROUP_NAME, VACM_NO_SUCH_CONTEXT, VACM_NO_SUCH_VIEW, VACM_NOT_IN_VIEW, VACM_OK, VACM_OTHER_ERROR, VIEW_NOTIFY, VIEW_READ, VIEW_WRITE
 
Constructor Summary
VacmMIB(MOServer[] server)
           
 
Method Summary
 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.
 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.
 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.
 MOTable getVacmSecurityToGroupTable()
           
 org.snmp4j.smi.OctetString getViewName(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OctetString securityName, int securityModel, int securityLevel, int viewType)
          Gets the view name of the view defined by the supplied credentials.
 int isAccessAllowed(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OctetString securityName, int securityModel, int securityLevel, int viewType, org.snmp4j.smi.OID oid)
          Checks whether access is allowed in the specified context for the security name, model, level, and view type for the supplied OID.
 int isAccessAllowed(org.snmp4j.smi.OctetString viewName, org.snmp4j.smi.OID oid)
          Checks if access is allowed for the given OID within the specified view.
 void registerMOs(MOServer server, org.snmp4j.smi.OctetString context)
          Registers the managed objects of this group with the server for the supplied context.
 boolean removeAccess(org.snmp4j.smi.OctetString groupName, org.snmp4j.smi.OctetString contextPrefix, int securityModel, int securityLevel)
          Removes an access entry from this VACM.
 boolean removeGroup(int securityModel, org.snmp4j.smi.OctetString securityName)
          Removes a security model and name to group name mapping from this VACM.
 boolean removeViewTreeFamily(org.snmp4j.smi.OctetString viewName, org.snmp4j.smi.OID subtree)
          Removes a view tree family from this VACM.
 void unregisterMOs(MOServer server, org.snmp4j.smi.OctetString context)
          Unregisters the managed objects of this group from the supplied server and from the supplied context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vacmContextEntryOID

public static final org.snmp4j.smi.OID vacmContextEntryOID

colVacmGroupName

public static final int colVacmGroupName
See Also:
Constant Field Values

colVacmSecurityToGroupStorageType

public static final int colVacmSecurityToGroupStorageType
See Also:
Constant Field Values

colVacmSecurityToGroupRowStatus

public static final int colVacmSecurityToGroupRowStatus
See Also:
Constant Field Values

idxVacmGroupName

public static final int idxVacmGroupName
See Also:
Constant Field Values

idxVacmSecurityToGroupStorageType

public static final int idxVacmSecurityToGroupStorageType
See Also:
Constant Field Values

idxVacmSecurityToGroupRowStatus

public static final int idxVacmSecurityToGroupRowStatus
See Also:
Constant Field Values

vacmSecurityToGroupEntryOID

public static final org.snmp4j.smi.OID vacmSecurityToGroupEntryOID

colVacmAccessContextMatch

public static final int colVacmAccessContextMatch
See Also:
Constant Field Values

colVacmAccessReadViewName

public static final int colVacmAccessReadViewName
See Also:
Constant Field Values

colVacmAccessWriteViewName

public static final int colVacmAccessWriteViewName
See Also:
Constant Field Values

colVacmAccessNotifyViewName

public static final int colVacmAccessNotifyViewName
See Also:
Constant Field Values

colVacmAccessStorageType

public static final int colVacmAccessStorageType
See Also:
Constant Field Values

colVacmAccessRowStatus

public static final int colVacmAccessRowStatus
See Also:
Constant Field Values

idxVacmAccessContextPrefix

public static final int idxVacmAccessContextPrefix
See Also:
Constant Field Values

idxVacmAccessSecurityModel

public static final int idxVacmAccessSecurityModel
See Also:
Constant Field Values

idxVacmAccessSecurityLevel

public static final int idxVacmAccessSecurityLevel
See Also:
Constant Field Values

idxVacmAccessContextMatch

public static final int idxVacmAccessContextMatch
See Also:
Constant Field Values

idxVacmAccessReadViewName

public static final int idxVacmAccessReadViewName
See Also:
Constant Field Values

idxVacmAccessWriteViewName

public static final int idxVacmAccessWriteViewName
See Also:
Constant Field Values

idxVacmAccessNotifyViewName

public static final int idxVacmAccessNotifyViewName
See Also:
Constant Field Values

idxVacmAccessStorageType

public static final int idxVacmAccessStorageType
See Also:
Constant Field Values

idxVacmAccessRowStatus

public static final int idxVacmAccessRowStatus
See Also:
Constant Field Values

vacmAccessEntryOID

public static final org.snmp4j.smi.OID vacmAccessEntryOID

vacmExactMatch

public static final int vacmExactMatch
See Also:
Constant Field Values

vacmPrefixMatch

public static final int vacmPrefixMatch
See Also:
Constant Field Values

vacmViewSpinLockOID

public static final org.snmp4j.smi.OID vacmViewSpinLockOID

colVacmViewTreeFamilyMask

public static final int colVacmViewTreeFamilyMask
See Also:
Constant Field Values

colVacmViewTreeFamilyType

public static final int colVacmViewTreeFamilyType
See Also:
Constant Field Values

colVacmViewTreeFamilyStorageType

public static final int colVacmViewTreeFamilyStorageType
See Also:
Constant Field Values

colVacmViewTreeFamilyRowStatus

public static final int colVacmViewTreeFamilyRowStatus
See Also:
Constant Field Values

idxVacmViewTreeSubtree

public static final int idxVacmViewTreeSubtree
See Also:
Constant Field Values

idxVacmViewTreeFamilyMask

public static final int idxVacmViewTreeFamilyMask
See Also:
Constant Field Values

idxVacmViewTreeFamilyType

public static final int idxVacmViewTreeFamilyType
See Also:
Constant Field Values

idxVacmViewTreeFamilyStorageType

public static final int idxVacmViewTreeFamilyStorageType
See Also:
Constant Field Values

idxVacmViewTreeFamilyRowStatus

public static final int idxVacmViewTreeFamilyRowStatus
See Also:
Constant Field Values

vacmViewTreeFamilyEntryOID

public static final org.snmp4j.smi.OID vacmViewTreeFamilyEntryOID

vacmViewIncluded

public static final int vacmViewIncluded
See Also:
Constant Field Values

vacmViewExcluded

public static final int vacmViewExcluded
See Also:
Constant Field Values
Constructor Detail

VacmMIB

public VacmMIB(MOServer[] server)
Method Detail

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.

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.

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.

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.

getVacmSecurityToGroupTable

public MOTable getVacmSecurityToGroupTable()

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.