当前位置: 首页>>代码示例>>Java>>正文


Java SnmpStatusException.snmpRspAuthorizationError方法代码示例

本文整理汇总了Java中com.sun.jmx.snmp.SnmpStatusException.snmpRspAuthorizationError方法的典型用法代码示例。如果您正苦于以下问题:Java SnmpStatusException.snmpRspAuthorizationError方法的具体用法?Java SnmpStatusException.snmpRspAuthorizationError怎么用?Java SnmpStatusException.snmpRspAuthorizationError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jmx.snmp.SnmpStatusException的用法示例。


在下文中一共展示了SnmpStatusException.snmpRspAuthorizationError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapGetException

import com.sun.jmx.snmp.SnmpStatusException; //导入方法依赖的package包/类
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:82,代码来源:SnmpRequestTree.java


注:本文中的com.sun.jmx.snmp.SnmpStatusException.snmpRspAuthorizationError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。